Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to start process from powershell

Folks

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

   Start-Process C:\USR\test.bat

However i created a service in C# which is able to delete and write logs using the powershell script however it simply ignores this step and nothing happens. Is it because this script is invoked by a 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 {

}
  • Execution policy is unrestricted
like image 820
Sudheej Avatar asked Feb 03 '17 16:02

Sudheej


People also ask

How do I run a process in PowerShell?

The Get-Process cmdlet gets the processes on a local or remote computer. Without parameters, this cmdlet gets all of the processes on the local computer. You can also specify a particular process by process name or process ID (PID) or pass a process object through the pipeline to this cmdlet.

What is process in PowerShell?

The process block is where the work is done in a PowerShell advanced function. There are two different approaches we need to keep in mind and account for. The first is how you handle parameters and the second is pipeline input into your function.


1 Answers

Check access rights on a share, maybe your admin user don't have rights to access it.

like image 150
Tarcus Avatar answered Oct 26 '22 08:10

Tarcus