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 {
}
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.
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.
Check access rights on a share, maybe your admin user don't have rights to access it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With