windows - schtasks: setting a working directory? -
i have program trying run on logon dependent on files in same directory resides. manually running program command line, have cd'd to, runs should. however, if schedule task run program error program complains not finding file needs. question(s) is/are: 1.) working directory of scheduled task location of program? 2.) if not, how set working directory location of program?
here code using schedule task:
schtasks /create /tn "test" /tr $mylocation\test.exe /sc onlogon /rl highest where "$mylocation" powershell variable set reference directory of program.
i've got around in past using batch file. there's neat trick can use in batch file give directory tha batch file located in. so, can run app want. create batch file following contents , place in directory next app, set it's path value /tr argument.
%~dp0\test.exe strictly speaking, backslash isn't required %~dp0 includes trailing backslash anyway. think makes batch file bit more readable though.
Comments
Post a Comment