Solved

Create Shortcut with passed parameter

Posted on 2002-06-11
2
325 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 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

25 Experts available now in Live!

Get 1:1 Help Now