Solved

Create Shortcut with passed parameter

Posted on 2002-06-11
2
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using "ScreenUpdating" 6 86
VBA: Select SQL query based on a config Sheet v2 11 55
Excel Automation VBA 19 116
Export PDF Form fields to Access  or Excel  in Tab order 16 128
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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

734 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