paul1149 Posted May 11, 2011 Share Posted May 11, 2011 Hi, I'd like to create a shell context menu command to create a desktop shortcut to a selected file. Here's what I have for an au3 script: $target = "C:\users\paul\desktop\" & %1 FileCreateShortcut($target, %1) And here's the command in the Registry: "C:\utilities\AutoIt3\AutoIt3_x64.exe c:\systools\test.au3" %1 Win7 asks me what program I want to use to start the Selected file. Does anyone have a way to do this, or a better way to achieve what I want? Thanks p. Behold, I will allure her, I will lead her into the wilderness and speak tenderly to her - Ho. 2.14 Link to comment Share on other sites More sharing options...
wakillon Posted May 12, 2011 Share Posted May 12, 2011 Compile it and add this command in the Registry "c:\systools\test.exe" "%1" AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
paul1149 Posted May 12, 2011 Author Share Posted May 12, 2011 Thanks for your reply. That sounds like a good plan, but the problem of passing the name of the target file to the script remains. And indeed, the script will not parse as-is. p. Behold, I will allure her, I will lead her into the wilderness and speak tenderly to her - Ho. 2.14 Link to comment Share on other sites More sharing options...
hannes08 Posted May 12, 2011 Share Posted May 12, 2011 Hi paul1149, $i_pos = StringInStr(StringReplace($CmdLineRaw, '"', ""), "\",0,-1) $file = StringMid(StringReplace($CmdLineRaw, '"', ""), $i_pos + 1) $rc = FileCreateShortcut(StringReplace($CmdLineRaw, '"', ""), @DesktopDir & "\" & StringTrimRight($file,3) & "lnk") First two lines are used to find only the filename from the full path. With "%1" as parameter it seems I have a quote at the beginning of the string but not at the end. Maybe I#m doing it wrong or there's a better way to do it at all. Alternatively to $CmdLineRaw you could use $CmdLine[1] or $CmdLine[$cmdLine[0]]. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
paul1149 Posted May 13, 2011 Author Share Posted May 13, 2011 Hi Hannes, Thanks for that. I understand the string manipulation intuitively, but unfortunately, I'm not following the rest - specifically, how to get the file name into the $CmdLineRaw variable. p. Behold, I will allure her, I will lead her into the wilderness and speak tenderly to her - Ho. 2.14 Link to comment Share on other sites More sharing options...
hannes08 Posted May 13, 2011 Share Posted May 13, 2011 Hi Hannes, Thanks for that. I understand the string manipulation intuitively, but unfortunately, I'm not following the rest - specifically, how to get the file name into the $CmdLineRaw variable. p. Hi Paul, The $CmdLineRaw and $CmdLine[x] variables / Constants are filled automatically when your script is started. You can look the helpfile under "Running Scripts" for further information. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
paul1149 Posted May 13, 2011 Author Share Posted May 13, 2011 Hannes, I compiled it, and it is working perfectly via the Explorer context menu. Much thanks for your kind help, this should be a big help in file management around here, and I hope I can learn from it as well! Be blessed, p. Behold, I will allure her, I will lead her into the wilderness and speak tenderly to her - Ho. 2.14 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now