Re: CreateShortcut problem
- From: "Dave Patrick" <DSPatrick@xxxxxxxxxxxxxxxx>
- Date: Mon, 27 Mar 2006 16:27:45 -0700
You'll want to use the Arguments property.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/15b932ee-9d9d-41f0-81ed-f6575e0d067b.asp
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
"Jason Gurtz" wrote:
| 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: Jason Gurtz
- Re: CreateShortcut problem
- References:
- CreateShortcut problem
- From: Jason Gurtz
- CreateShortcut problem
- Prev by Date: Re: Understanding WMI coding
- Next by Date: Re: bug? function returns string-array with one element as strin
- Previous by thread: CreateShortcut problem
- Next by thread: Re: CreateShortcut problem
- Index(es):
Relevant Pages
|