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 ""e&"MyApp.lnk""e&" on the Windows desktop." & cr & \
" sub CreateShortCut()" & cr & \
" dim objShell, strDesktopPath, objLink" & cr & \
" set objShell = CreateObject(""e&"WScript.Shell""e&")" & cr & \
" strDesktopPath = objShell.SpecialFolders(""e&"Desktop""e&")" & cr & \
" set objLink = objShell.CreateShortcut(strDesktopPath & ""e&"\MyApp.lnk""e&")" & cr & \
" objLink.Arguments = ""e&"-param1""e&"" & cr & \
" objLink.Description = ""e&"Shortcut to MyApp.exe""e&"" & cr & \
" objLink.TargetPath = ""e&"C:\Users\%username%\Desktop\MyApp.exe" "e&"" & cr & \
" objLink.WindowStyle = 1" & cr & \
" objLink.WorkingDirectory = ""e&"c:\windows""e&"" & cr & \
" objLink.Save" & cr & \
" end sub" & cr & \
"" & cr & \
" ' Program starts running here." & cr & \
" call CreateShortCut()" into tVbs
do tVbs as VBscript
end mouseUp
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.