ndandy 0 Posted April 19, 2010 If I launch a program by a shortcut (.lnk), how can I retrieve the shortcut name? @scriptname return the .exe filename, not the .lnk Share this post Link to post Share on other sites
blckpythn 2 Posted April 19, 2010 How are you running it without knowing the shortcut name to begin with? Share this post Link to post Share on other sites
ndandy 0 Posted April 19, 2010 How are you running it without knowing the shortcut name to begin with?The user know the shortcut name, but the application no I need to retrieve the shortcut name that was used for launching the app. Share this post Link to post Share on other sites
crashdemons 2 Posted April 19, 2010 I'm not aware of an *easy* way to do what you are asking... What are you seeking to accomplish in your program? If you want to associate different actions of the same program between different shortcuts you can use "Command Line Parameters" in your shortcuts. For example: a shortcut to "C:\pathto\program.exe" /dosomething And in the script you can check $CmdLineRaw or $CmdLine[element]. See "Running Scripts" in the AutoIt Help File. My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.) Share this post Link to post Share on other sites
ndandy 0 Posted April 20, 2010 Yes, this is the main problem! I tried to use $CmdLineRaw, but probably it is for CUI, with my app(GUI) it returns /AutoIt3ExecuteScript "filename.exe" and I don't see params passed. So I need to use the FileGetShortcut function to get params, but I need to know the .lnk filename FileGetShortcut ( "lnk" ) Share this post Link to post Share on other sites
99ojo 0 Posted April 20, 2010 Hi, you might use your app to let the user choose the LNK, and then launch it. ;only needed for _ArrayDisplay #include <array.au3> ;Open Dialog with lnk filter $lnk = FileOpenDialog ("Select Shortcut to run", @DesktopDir, "LNK (*.lnk)") If $lnk <> "" Then ;if you need properties $arlnkprop = FileGetShortcut ($lnk) ;show properties _ArrayDisplay ($arlnkprop) ;Execute lnk ShellExecute ($lnk) EndIf Share this post Link to post Share on other sites
Makaule 0 Posted April 20, 2010 Why do you need it? As i know if you have Test.exe and create Shortcut, shortcut would just launch Test.exe and it would work from Test.exe dir. Shortcut is just a shorter way to your exe. Share this post Link to post Share on other sites
ndandy 0 Posted April 20, 2010 Because with shortcut you can pass parameters to GUI app, but without have the shortcut name you cannot retrieve params with FileGetShortcut (probably). Share this post Link to post Share on other sites
therks 33 Posted April 20, 2010 I'm pretty sure what you're asking for specifically can't be done. Try this. Compile this script: MsgBox(0, '', $CmdLineRaw) Then run it from a shortcut with the target set as such ["c:\whatever the path to the file is\compiled.exe" "this is a parameter"] The message box should say "this is a parameter" (including quotation marks). My AutoIt Stuff | My Github Share this post Link to post Share on other sites
ndandy 0 Posted April 20, 2010 Ok, with your support I found the problem. I used the AutoItErrorHandler_UDF, so when I include it $CmdLineRaw is: /AutoIt3ExecuteScript "filename.exe" instead without it, $CmdLineRaw returns the correct parameters. Do I have to disable AutoItErrorHandler_UDF in order to read parameters? Share this post Link to post Share on other sites
therks 33 Posted April 21, 2010 (edited) It's possible, I'm not familiar with the AutoItErrorHandler_UDF. *Edit: Although with a quick search I found this post: http://www.autoitscript.com/forum/index.php?showtopic=88420&st=0&p=635423&hl=AutoItErrorHandler_UDF%20&fromsearch=1&#entry635423 He seems to be handling the same issue you are, perhaps his tweak will help you? Edited April 21, 2010 by RobSaunders My AutoIt Stuff | My Github Share this post Link to post Share on other sites
ndandy 0 Posted April 21, 2010 It's possible, I'm not familiar with the AutoItErrorHandler_UDF.*Edit: Although with a quick search I found this post: http://www.autoitscript.com/forum/index.php?showtopic=88420&st=0&p=635423&hl=AutoItErrorHandler_UDF%20&fromsearch=1&#entry635423He seems to be handling the same issue you are, perhaps his tweak will help you?Ok, thanks to all! Share this post Link to post Share on other sites