I have a program I am trying to run on logon which is dependent on files that are in the same directory that it resides. By manually running the program from the command line, which I have cd'd to, everything runs as it should. However, if I schedule a task to run the program I get an error from my program that complains about not finding a file it needs. So my question(s) is/are: 1.) Is the working directory of a scheduled task the location of the program? 2.) If not, how would I set the working directory to the location of the program?
Here is the code I am using the schedule my task:
SCHTASKS /Create /TN "Test" /TR $MyLocation\Test.exe /sc onlogon /RL Highest
Where "$MyLocation" is a powershell variable that I set to reference the directory of my program.