I recently started trying scripting and made several toolbar buttons, e.g. 7-zip extract and archive, rename by search and replace, and using Hitman Pro to scan the current path for malware, etc. I encountered a difficulty, however to run programs with command-line options, e.g. in the case of Hitman Pro, I'm aware of a working alternative: put it in my catalog with the following location:
"C:\Users\Wedung\AppData\Local\SurfRight\HitmanPro35.exe" /scanonly /ews
this works perfectly. However, I want to add a right-click script to the button I just mentioned in order to do a quick scan (using the option /quick instead of /ews). I tried many forms but none worked:
::open "C:\Users\Wedung\AppData\Local\SurfRight\HitmanPro35.exe" "/scanonly" "/quick" (error shows "Division by zero, what does that mean??")
::open "C:\Users\Wedung\AppData\Local\SurfRight\HitmanPro35.exe" "/scanonly /quick" (program runs but only one file is scanned, so sth is wrong)
I know this is rather specific, but I guess my problem is independent of this particular program.
The left-click script of the button is the following and works OK
::open "C:\Users\Wedung\AppData\Local\SurfRight\HitmanPro35.exe" "<curpath>\";
But when dealing with /scanonly /quick, the scanner does not work properly. So in general, do you see what my problem is here? It's much simpler to use the catalog item without scripts, in which case the multiple arguments work well, but when I try scripts, it does not work. Please help!
Thanks you very much.
question about running a program with command-line options
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: question about running a program with command-line options
Hi and Welcome,Huidong wrote:I recently started trying scripting and made several toolbar buttons, e.g. 7-zip extract and archive, rename by search and replace, and using Hitman Pro to scan the current path for malware, etc. I encountered a difficulty, however to run programs with command-line options, e.g. in the case of Hitman Pro, I'm aware of a working alternative: put it in my catalog with the following location:
"C:\Users\Wedung\AppData\Local\SurfRight\HitmanPro35.exe" /scanonly /ews
this works perfectly. However, I want to add a right-click script to the button I just mentioned in order to do a quick scan (using the option /quick instead of /ews). I tried many forms but none worked:
::open "C:\Users\Wedung\AppData\Local\SurfRight\HitmanPro35.exe" "/scanonly" "/quick" (error shows "Division by zero, what does that mean??")
::open "C:\Users\Wedung\AppData\Local\SurfRight\HitmanPro35.exe" "/scanonly /quick" (program runs but only one file is scanned, so sth is wrong)
I know this is rather specific, but I guess my problem is independent of this particular program.
The left-click script of the button is the following and works OK
::open "C:\Users\Wedung\AppData\Local\SurfRight\HitmanPro35.exe" "<curpath>\";
But when dealing with /scanonly /quick, the scanner does not work properly. So in general, do you see what my problem is here? It's much simpler to use the catalog item without scripts, in which case the multiple arguments work well, but when I try scripts, it does not work. Please help!
Thanks you very much.
Try the command "openwith":
Code: Select all
::openwith """C:\Users\Wedung\AppData\Local\SurfRight\HitmanPro35.exe"" /scanonly /quick";-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: question about running a program with command-line options
Solved! Thank you so much, serendipity! So neither open nor run works with command-line options? Rather strange, since I thought openwith is mainly used to specify a program to open a file or so... Any idea why openwith is designated to deal with command-line options instead of open or run? Or this is just arbitrary?
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: question about running a program with command-line options
How silly of me! I just tried your code, but using open or run instead of openwith, and both worked! Hence my mistake was all about using quotes. Thanks!
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: question about running a program with command-line options
You are right, in your case both run and open will work too. I try to use openwith because it has the option of passing items to single or multiple instance of the program. Anyway, glad its solved.Huidong wrote:How silly of me! I just tried your code, but using open or run instead of openwith, and both worked! Hence my mistake was all about using quotes. Thanks!
-
Huidong
- Posts: 213
- Joined: 18 May 2011 21:55
Re: question about running a program with command-line options
Good point! So I tried openwith with mode m, unfortunately Hitman Pro does not support multiple instances. But I just learned another piece! Thanks again.
XYplorer Beta Club