Norm-al
asked on
Script to create application link on desktop
I have pulled out what stubble I have as hair trying to figure this. I have some code that deletes an old desktop link and creates a new one however, the link I want created has in it's target a command and switch. Normal creation this works fine, script it and the quotes that are required are passed. Adding code to eliminate quotes results in no space between application executable and switch, add code to inject a space in ANY format results in the preceding and ending quotes showing up again... clues?
Code as follows:
Code as follows:
'begin shortcut creation function
strWorkDir ="C:\Directory"
strAppPath = "c:\Directory\File.exe dbserver=server\instance"
strIconPath ="C:\Directory\File.exe"
'
Set objShell = CreateObject("WScript.Shell")
objDesktop = objShell.SpecialFolders("Desktop")
Set objLink = objShell.CreateShortcut(objDesktop & "\File.lnk")
'
objLink.Description = "File"
objLink.IconLocation = strIconPath
objLink.TargetPath = strAppPath
objLink.WindowStyle = 3
objLink.WorkingDirectory = strWorkDir
objLink.Save
'end function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you itguy565, this is how the code played out in the end:
Code as follows:
'begin shortcut creation function
strWorkDir ="C:\Directory"
strAppPath = "c:\Directory\File.exe"
strArgument = "dbserver=server\instance"
strIconPath ="C:\Directory\File.exe"
'
Set objShell = CreateObject("WScript.Shel l")
objDesktop = objShell.SpecialFolders("D esktop")
Set objLink = objShell.CreateShortcut(ob jDesktop & "\File.lnk")
'
objLink.Description = "File"
objLink.IconLocation = strIconPath
objLink.TargetPath = strAppPath
objLink.Argument = strArgument
objLink.WindowStyle = 3
objLink.WorkingDirectory = strWorkDir
objLink.Save
'end function
Code as follows:
'begin shortcut creation function
strWorkDir ="C:\Directory"
strAppPath = "c:\Directory\File.exe"
strArgument = "dbserver=server\instance"
strIconPath ="C:\Directory\File.exe"
'
Set objShell = CreateObject("WScript.Shel
objDesktop = objShell.SpecialFolders("D
Set objLink = objShell.CreateShortcut(ob
'
objLink.Description = "File"
objLink.IconLocation = strIconPath
objLink.TargetPath = strAppPath
objLink.Argument = strArgument
objLink.WindowStyle = 3
objLink.WorkingDirectory = strWorkDir
objLink.Save
'end function
ASKER