Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Desktop Shortcuts 2

Status
Not open for further replies.

aquias

MIS
Jun 13, 2003
820
US
Howdy!

I'm working with my login script and need to add several new shortcuts to my users desktops. That in and of itself is simple enough. I'm using the following code:

Code:
SET oFSO = Wscript.CreateObject("Scripting.FileSystemObject")
    strDsk = WshShell.SpecialFolders("Desktop")
    strshortcut = strDsk & "\Optimum Clinicals.lnk"
If Not oFSO.FileExists(strshortcut) Then
    SET oUrlLink = WshShell.CreateShortcut(strshortcut)
    oUrlLink.TargetPath = "\\Fnhc_adlsrv\adl2\ADLOptClinicals.exe"
    oUrlLink.WorkingDirectory = "\\Fnhc_adlsrv\adl2"
    oUrlLink.Save
End If

My problem is that I need to create a desktop shortcut with a command line argument. The [red]target pat[/red] would need to end up looking like the following

Code:
\\Fnhc_adlsrv\adl2\ADLOptClinicals.exe -upCNA

I've done the following.

Code:
oUrlLink.TargetPath = "\\Fnhc_adlsrv\adl2\ADLOptClinicals.exe" & "-upCNA"

[red]oUrlLink.TargetPath = "\\Fnhc_adlsrv\adl2\ADLOptClinicals.exe" & " -upCNA"[/red]

And several variants of those codes therein. The target path is put into the shortcut with the "" at the start and finish or no space is put between my path and my command line argument.

For the shortcuts to work the path must display as

\\Fnhc_adlsrv\adl2\ADLOptClinicals.exe -upCNA (with the space).

What am I missing?

Thanks for taking the time to read and for any help
 
Aquias,

There are actually a few more attributes you can use with your script. Below is the code that I use to create my shortcuts.

Set oWS = WScript.CreateObject("WScript.Shell")
sFile = "C:\MikeShortcut.LNK"
Set oMLink = oWS.CreateShortcut(sFile)

oMLink.TargetPath = "C:\Program Files\anyprogram.exe"
oMLink.Arguments = "-lll"
oMLink.Save


You can also just add the argument that you need for your application right in the TargetPath between the quotes. Some of the other attributes are:

oMLink.Arguments = ""
oMLink.Description = ""
oMLink.HotKey = ""
oMLink.IconLocation = ""
oMLink.WindowStyle = ""
oMLink.WorkingDirectory = ""


Hope this helps.

Mike Walton
Network+ CCENT
Free Tech Articles at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top