Re: CreateShortcut problem



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
|
| --


.



Relevant Pages

  • CreateShortcut problem
    ... I'm trying to create a shortcut that starts up an app with a single ... Plains v8\Dynamics.exe" ... In the properties of the created shortcut I verify that the Target field is: ...
    (microsoft.public.windows.server.scripting)
  • Re: Time to CounterSPam ?
    ... "Utilisateur PC Libre Service" wrote in message ... businesses to become a target of a DOS attack. ... my educated guess is that most of these spam websites are running on ... hacked PCs (personal or business), and the owners have no idea it's running. ...
    (comp.programming)
  • Re: Creating user-level security with MS Access file on a network
    ... I would modify this target to ... > problem isn't that I am trying to open the mdw shortcut in Acess 2003 ... > on the computers with Access 2002 to reflect the 2002 status. ...
    (microsoft.public.access.security)
  • RE: Adding a shortcut to start menu
    ... On my target system the TargetPath resolved to a folder on D: ... Then Target Designer nolonger reported an error with my shortcut. ...
    (microsoft.public.windowsxp.embedded)
  • Re: Why cant I delete a user?
    ... The target of the shortcut would have the following in it ... I have tried creating a shortcut, where the "Target" field of the Properties ... The wizard is flawed in 2000, so you should secure it manually. ...
    (microsoft.public.access.security)