Reputation: 45
I updated my autohotkey from v1 to v2
appskey::run,Wscript C:\folder\script.vbs "netsh wlan disconnect"
return
the above command working good in v1 to break in v2 I tried :
appskey::run "Wscript C:\folder\script.vbs" "netsh wlan disconnect"
throws error -there is no script engine for file extension ".vsnetsh"
appskey::Run "Wscript C:\folder\script.vbs netsh wlan disconnect"
it open in background but not working
Please correct the above code so that it run for multiple parameter.
Upvotes: 1
Views: 1337
Reputation: 6489
In v2 everything is evaluated as an expression.
What you're doing in your run command here:
run "Wscript C:\folder\script.vbs" "netsh wlan disconnect"
is concatenating two string together, so the first (and only) argument the Run
function receives is:
"Wscript C:\folder\script.vbsnetsh wlan disconnect"
.
So you're trying to run a file called script.vbsnetsh
and pass in two arguments into it, wlan
and disconnect
.
And here:
Run "Wscript C:\folder\script.vbs netsh wlan disconnect"
You're running the correct script, but you're passing in three arguments, netsh
, wlan
and disconnect
.
What you're trying to do, is run a file called script.vbs
, and pass in just one argument into it, that argument being netsh wlan disconnect
.
Your argument contains spaces, so you have to wrap the argument around in "
s to indicate it's just one argument, just as you do in your v1 legacy script.
So the correct version would be:
Run "Wscript `"C:\folder\script.vbs`" `"netsh wlan disconnect`""
You escape quotation marks with `"
in v2(docs).
And the added quotation marks around your file path aren't needed because your file path doesn't have spaces in it, but it very easily could have, so I added them in for a better demonstration.
Upvotes: 2