Failed to start process from PowerShell

People

I am trying to call a batch script from a power shell file and the call works fine if executed manually.

Start-Process C:\USR\test.bat 

However, I created a service in C # that can delete and write logs using the powershell script, but just ignores this step and nothing happens. Is it because this script is being called by the windows service?

 if (Test-Path \\xxxsharepathfullper\FileWatcher\target\watcher.mon) { echo "File removed" >> C:\USR\logger.txt Start-Process C:\USR\test.bat Remove-Item \\xxxsharepathfullper\FileWatcher\target\watcher.mon } else { } 
  • The execution policy is not limited.
+7
windows-services
source share
2 answers

Check access rights on a shared resource; your administrator may not have access rights to it.

+1
source share

You can try to start the process as an administrator and register any error:

 Start-Process -FilePath "C:\USR\test.bat" -RedirectStandardError "testError.txt" -verb RunAs 
0
source share

All Articles