I have a powershell script to do a backup and use 7zip to compress the files and folders. The program works very well when it runs directly from the powershell window but it doesn't from the task scheduler. In the task scheduler, I right click the task and click run to prove, the task manager shows that the powershell begins but the 7z.exe appears for a moment but stops and the history of the task sched. shows that everything is ok. I have another windows server and there everything works very well. I compared the settings of both servers and they are equal, I mean the task scheduler settings, the security settings of files, where could be the problem?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found where was the problem. The problem was in the powershell script. In order to improve the organization I mapped the working folder with a letter and that letter was the origin of data for the 7zip.exe. This works when you run the script from the powershell prompt but it doesn't work when you run the script from the task scheduler, I had to replace the letter, in this case T:\, by the whole path, in this case c:\users\public\myfolder. Please, pay attention to this, i have wasted a lot of time looking for the solution. I don't know why it happends but this is the difference.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Encountered this as well, where the file ran fine if done manually, but when it ran under scheduler--in my case--it would not find the target items, so the archives were essentially 1-byte files (which should have been a quick clue that it wasn't finding the target... it should have been). But when I replaced the "mapped drive" locations with the exact share locations, works fine under scheduler. I'm sure there is a good reason why; one that I should know about. If anyone knows, please let me in on the secret.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's probably just a matter of a different user context.
If a scheduler task runs "elevated" it cannot see mapped network drives that were created with your "normal" user account.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a powershell script to do a backup and use 7zip to compress the files and folders. The program works very well when it runs directly from the powershell window but it doesn't from the task scheduler. In the task scheduler, I right click the task and click run to prove, the task manager shows that the powershell begins but the 7z.exe appears for a moment but stops and the history of the task sched. shows that everything is ok. I have another windows server and there everything works very well. I compared the settings of both servers and they are equal, I mean the task scheduler settings, the security settings of files, where could be the problem?
I found where was the problem. The problem was in the powershell script. In order to improve the organization I mapped the working folder with a letter and that letter was the origin of data for the 7zip.exe. This works when you run the script from the powershell prompt but it doesn't work when you run the script from the task scheduler, I had to replace the letter, in this case T:\, by the whole path, in this case c:\users\public\myfolder. Please, pay attention to this, i have wasted a lot of time looking for the solution. I don't know why it happends but this is the difference.
Encountered this as well, where the file ran fine if done manually, but when it ran under scheduler--in my case--it would not find the target items, so the archives were essentially 1-byte files (which should have been a quick clue that it wasn't finding the target... it should have been). But when I replaced the "mapped drive" locations with the exact share locations, works fine under scheduler. I'm sure there is a good reason why; one that I should know about. If anyone knows, please let me in on the secret.
It's probably just a matter of a different user context.
If a scheduler task runs "elevated" it cannot see mapped network drives that were created with your "normal" user account.