I'm trying to schedule a command in a PowerShell script to run using Windows scheduler. This command relies on a user specific environment variable, and since scheduled tasks do not have access to these I have decided to try and just set the variable inside the PowerShell script itself.
The normal environment variable configuration looks like this:
And in order to replicate this in the script, I tried using:
$env:DCRCLIFILE = "C:\Users\pzsr7z\Desktop\DCRCLIFILE.txt"
But for some reason the program will not work properly when I set things up this way, even though it works perfectly fine when I run the program using the "normal" user environment variable.
Program execution using the PowerShell initiated environment variable
Program execution using the "normal" environment variable:
Is there anything that I should be doing differently when setting the environment variable in the PowerShell script? I'm not sure why this isn't working. I've verified that the environment variable actually gets created, so it's not like the PowerShell command is failing.


