CreateShortcut problem
- From: Jason Gurtz <jasonNOgurtz@xxxxxxxxxxxxxxx>
- Date: Mon, 27 Mar 2006 15:01:57 -0500
I'm trying to create a shortcut that starts up an app with a single
argument. The code does produce a correct *looking* shortcut (Target
string is correct), but when I try to launch the shortcut, the shell
complains that it can't find the file referenced in the argument.
Here is the script (Long strings are actually on single line)
'---------- Start makeShortcut.vbs ----------
Set shell = CreateObject("WScript.Shell")
Set oEnv = shell.Environment("PROCESS")
usrProf = oEnv("USERPROFILE")
targetProg = "C:\Program Files\Microsoft Business Solutions\Great
Plains v8\Dynamics.exe"
targetArg = "C:\Program Files\Microsoft Business Solutions\Great
Plains v8\Dynamics.set"
vbSpace = ChrW(32) 'A space char
vbDblQuote = ChrW(34) 'A double quote char
sName = usrProf & "\Desktop\Great Plains v8.lnk"
sTarget= vbDblQuote & targetProg & vbDblQuote & vbSpace & vbDblQuote &
targetArg & vbDblQuote
sDir = "C:\Program Files\Microsoft Business Solutions\Great Plains v8"
sIcon = "C:\Program Files\Microsoft Business Solutions\Great Plains
v8\Dynamics.exe, 8"
Set sCut= Shell.CreateShortcut(sName)
sCut.TargetPath = sTarget
sCut.WorkingDirectory = sDir
sCut.WindowStyle = 3
sCut.IconLocation = shell.ExpandEnvironmentStrings(sIcon)
sCut.Save
'---------- End makeShortcut.vbs ----------
In the properties of the created shortcut I verify that the Target field is:
"C:\Program Files\Microsoft Business Solutions\Great Plains
v8\Dynamics.exe" "C:\Program Files\Microsoft Business Solutions\Great
Plains v8\Dynamics.set"
Yet it displays the error message. Now here's the *really* odd part.
If I edit the target string and remove any single char, apply, then
change it back and apply, the shortcut works just fine!
What gives!? I'm trying to get from an error prone, manual, several
thousand step (not really!) install of the Great Plains app to at least
a semi-automated install. ;)
~Jason
--
.
- Follow-Ups:
- Re: CreateShortcut problem
- From: Dave Patrick
- Re: CreateShortcut problem
- Prev by Date: Re: Pulling Domain Information Into A VB Script
- Next by Date: Out of Memory Dumping Event Logs to a database
- Previous by thread: Re: Need Help. Beginner in Scripting
- Next by thread: Re: CreateShortcut problem
- Index(es):
Relevant Pages
|