SunQuest
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old November 3rd, 2003, 06:02 AM
jaharul_alam jaharul_alam is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Pune(India)
Posts: 13 jaharul_alam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem in creating Desktop Short from my VB Application

I have an VB application that when starts checks for a shortcut of itsself on the desktop. If it doesnot find ,that means for the very first time the application will create the shortcut. I have written the following lines of code for the functionality.....

01:If Dir(wShell.SpecialFolders.Item(0) & "\" & App.Title & ".lnk") = "" Then
02: Set wShortcut = wShell.CreateShortcut(wShell.SpecialFolders.Item(0) & "\" & App.Title & ".lnk")
03: wShortcut.TargetPath = App.Path & "\" & App.EXEName & ".exe"
04: wShortcut.Save
End If

05:If Dir(wShell.SpecialFolders.Item(11) & "\" & App.Title & ".lnk") = "" Then
06: Set wShortcut = wShell.CreateShortcut(wShell.SpecialFolders.Item(11) & "\" & App.Title & ".lnk")
07: wShortcut.TargetPath = App.Path & "\" & App.EXEName & ".exe"
08: wShortcut.Arguments = "\Systray"
09: wShortcut.Save
10:End If

These lines of code works successfully and creates the shortcut too but only in case of Windows 2000/NT but fails with Windows98 . If I run my application on win98 then it gives an error like.... "ActiveX cannot create object." at line no. 01

I am confused how to tackle with this problem... Can any one help me out ? Thanks in advance....

Reply With Quote
  #2  
Old November 3rd, 2003, 07:56 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Maybe your Window Script doesn't support your method in win98...Which version do u use in win98??Or U don't install Window Script in win98??U can upgrade window Script from:
http://msdn.microsoft.com/library/d...list/webdev.asp

HOWTO: Create a Desktop Shortcut with the Windows Script Host
SUMMARY
The Microsoft Windows Script Host (WSH) is a tool that allows you to run Microsoft Visual Basic Scripting Edition and JScript natively within the base Operating System, either on Windows 95 or Windows NT 4.0. It also includes several COM automation methods that allow you to do several tasks easily through the Windows Script Host Object Model. The Microsoft Windows Script Host is integrated into Windows 98 and Windows 2000. It is available for Windows NT 4.0 from within the Windows NT 4.0 Option Pack. It is also available for download from:

http://www.msdn.microsoft.com/scripting
MORE INFORMATION
This program demonstrates how to use the Windows Script Host to create a shortcut on the Windows Desktop. In order to run this example, you must have the Windows Script Host installed on your computer. To run one of these examples, copy the code below into a new program file and run it.

Example 1WshShell = CreateObject("Wscript.shell")
strDesktop = WshShell.SpecialFolders("Desktop")
oMyShortcut = WshShell.CreateShortcut(strDesktop + "\Sample.lnk")
oMyShortcut.WindowStyle = 3 &&Maximized 7=Minimized 4=Normal
oMyShortcut.IconLocation = "C:\myicon.ico"
OMyShortcut.TargetPath = "%windir%\notepad.exe"
oMyShortCut.Hotkey = "ALT+CTRL+F"
oMyShortCut.Save

Example 2

(Add a command line argument) WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
oMyShortCut= WshShell.CreateShortcut(strDesktop+"\Foxtest.lnk")
oMyShortCut.WindowStyle = 7 &&Minimized 0=Maximized 4=Normal
oMyShortcut.IconLocation = home()+"wizards\graphics\builder.ico"
oMyShortCut.TargetPath = "c:\Program Files\Microsoft Visual Studio\VFP98\vfp6.exe"
oMyShortCut.Arguments = '-c'+'"'+Home()+'config.fpw'+'"'
oMyShortCut.WorkingDirectory = "c:\"
oMyShortCut.Save

Example 3

(Add a URL Shortcut to the desktop) WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
oUrlLink = WshShell.CreateShortcut(strDesktop+"\Microsoft Web Site.URL")
oUrlLink.TargetPath = "http://www.microsoft.com"
oUrlLink.Save

Please note that all methods must be passed valid parameters for the shortcut to be created. No error appears if one of the parameters is incorrect.

Last edited by cleverpig : November 3rd, 2003 at 07:59 AM.

Reply With Quote
  #3  
Old November 4th, 2003, 12:12 AM
jaharul_alam jaharul_alam is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Pune(India)
Posts: 13 jaharul_alam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Cleverpig

Thanks for your assistance .I tried the code but I got and error in the very first line.........

WshShell = CreateObject("Wscript.shell")

Its says the object does not support this property or method..

Would please help me out .. I am waiting for ur reply

Reply With Quote
  #4  
Old November 4th, 2003, 08:32 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
U can try to upgrade the window script shell on win98...Hope it is a way to resolve this problem..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Problem in creating Desktop Short from my VB Application


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway