|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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.... |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
U can try to upgrade the window script shell on win98...Hope it is a way to resolve this problem..
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Problem in creating Desktop Short from my VB Application |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|