Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

Create Shortcut with passed parameter

I need to create a shortcut that passes a command line parameter to my app.  I can create the shortcut no problem, but when I try to pass the parameter, here's what I get for the target:

"C:\Program Files\ZipFiler\ZipFiler.exe Parameter"

but I need:

"C:\Program Files\ZipFiler\ZipFiler.exe" Parameter

Here's the code:

Set lnkShortcut = wshShell.CreateShortcut(sPath & "ZipFiler.lnk")

With lnkShortcut
   .Description = "ZipFiler"
   .TargetPath = sPath & "ZipFiler.exe " & sParameter
   .WorkingDirectory = sPath
   .IconLocation = sPath & "ZipFiler.ico"
   .Save
End With
0
northeyk
Asked:
northeyk
  • 2
1 Solution
 
MonchangerCommented:
Try adding this line inside the With statement:

.Arguments = sParameter

It works for me when creating shortcuts VBScript, so I guess that it should work as well.

If not, try this:

.TargetPath = """" & sPath & "ZipFiler.exe """ & sParameter

which is the correct syntax for a shortcut's Target Path including an argument.
0
 
MonchangerCommented:
Oops - add a space between Zipfilter.exe and sParameter
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now