简体   繁体   中英

How to pass variable from batch file into task scheduler

I have verified that my variable is in my batch file via -

echo %1

So this is the next command in my batch file -

schtasks /run /TN 7fd19ac6-6e5f-4bf9-8313-2ed6ee474fa0

Which has been setup previously. In this setup I have set the Program to run as -

dec.ahk

and the argument as

%1

This is obviously running an autohotkey script and I'm trying to pass that %1 from my batch file. When I run the above I have a message box in autohotkey telling me the value of %1, and in this case it returns "%1", not the file name I initially clicked on and want to pass. So how to get the value of this filename into schtasks argument properly?

Adding to the schtasks command line like this does not work -

schtasks /run /TN 7fd19ac6-6e5f-4bf9-8313-2ed6ee474fa0 %1

the filename can have no spaces in it. change the scheduled task argument to %zdec%

setx zdec %1
schtasks /run /TN 7fd19ac6-6e5f-4bf9-8313-2ed6ee474fa0
reg delete HKEY_CURRENT_USER\Environment /v zdec /f

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM