Create alias with parameters

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
hwbehrens
Posts: 19
Joined: Fri Mar 19, 2010 9:10 pm

Create alias with parameters

Post by hwbehrens » Wed Mar 13, 2013 1:08 am

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!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Create alias with parameters

Post by Simon » Wed Mar 13, 2013 1:41 am

Any chance of using a .bat file instead?
start C:\Users\hwbehrens\Desktop\MyApp.exe -param1
LC can create that for you easy.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Create alias with parameters

Post by Simon » Wed Mar 13, 2013 4:35 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

hwbehrens
Posts: 19
Joined: Fri Mar 19, 2010 9:10 pm

Re: Create alias with parameters

Post by hwbehrens » Wed Mar 13, 2013 4:04 pm

Thanks, Simon! I'll give that a shot.

Post Reply

Return to “Windows”