Page 1 of 1

Create alias with parameters

Posted: Wed Mar 13, 2013 1:08 am
by hwbehrens
Hi guys,

Just wondering if any of you have been able to use 'create alias' to create an alias that includes a parameter?

For example:

Code: Select all

set the directory to specialFolderPath("Desktop")
create alias "MyApp.lnk" to file "MyApp.exe"
This code will create an alias on the desktop for my executable, which is also on the desktop. When viewing the Shortcut Properties, the Target would in this case be:

Code: Select all

"C:\Users\hwbehrens\Desktop\MyApp.exe"
If I would also like to include a command line argument, for example if I wanted to change the Target to this:

Code: Select all

"C:\Users\hwbehrens\Desktop\MyApp.exe" -param1
How would I need to change my first example script in order to make this happen?

Thanks for the help!

Re: Create alias with parameters

Posted: Wed Mar 13, 2013 1:41 am
by Simon
Any chance of using a .bat file instead?
start C:\Users\hwbehrens\Desktop\MyApp.exe -param1
LC can create that for you easy.

Simon

Re: Create alias with parameters

Posted: Wed Mar 13, 2013 4:35 am
by Simon
OK I have a better answer, don't use "create alias" use vbs.

Code: Select all

on mouseUp
   put "' Make sure variables are declared." & cr & \
"  option explicit" & cr & \
"" & cr & \
"  ' Routine to create "&quote&"MyApp.lnk"&quote&" on the Windows desktop." & cr & \
"  sub CreateShortCut()" & cr & \
"    dim objShell, strDesktopPath, objLink" & cr & \
"    set objShell = CreateObject("&quote&"WScript.Shell"&quote&")" & cr & \
"    strDesktopPath = objShell.SpecialFolders("&quote&"Desktop"&quote&")" & cr & \
"    set objLink = objShell.CreateShortcut(strDesktopPath & "&quote&"\MyApp.lnk"&quote&")" & cr & \
"    objLink.Arguments = "&quote&"-param1"&quote&"" & cr & \
"    objLink.Description = "&quote&"Shortcut to MyApp.exe"&quote&"" & cr & \
"    objLink.TargetPath = "&quote&"C:\Users\%username%\Desktop\MyApp.exe" &quote&"" & cr & \
"    objLink.WindowStyle = 1" & cr & \
"    objLink.WorkingDirectory = "&quote&"c:\windows"&quote&"" & cr & \
"    objLink.Save" & cr & \
"  end sub" & cr & \
"" & cr & \
"  ' Program starts running here." & cr & \
         "  call CreateShortCut()" into tVbs
   do tVbs as VBscript
end mouseUp
:D :D
Just have to change all the MyApp in there.

Simon

Re: Create alias with parameters

Posted: Wed Mar 13, 2013 4:04 pm
by hwbehrens
Thanks, Simon! I'll give that a shot.