Solved

Create Shortcut with passed parameter

Posted on 2002-06-11
2
323 Views
Last Modified: 2012-06-27
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
Comment
Question by:northeyk
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
Monchanger earned 100 total points
ID: 7069859
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
 
LVL 4

Expert Comment

by:Monchanger
ID: 7069867
Oops - add a space between Zipfilter.exe and sParameter
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now