I have a strange issue on a Windows Server 2012 R2 here that just does not make any sense to me at all.
I've got a PowerShell script that basically has the following structure:
Function Something-Different
{
[...]
}
Function Start-Some-Batch
{
Start-Process "K:\Path\To\Batch.cmd"
}
Function Something-Else
{
[...]
}
Something-Different
Start-Some-Batch
Something-Else
However the batch file K:\Path\To\Batch.cmd
never ever gets executed!
Some more information and facts:
- All actions are performed with the same domain user
- PowerShell version is 4.0
- The batch file can be executed without any issues when double-clicking it within Windows Explorer
- The PowerShell script does not provide any error output
- Executing
Start-Process "K:\Path\To\Batch.cmd"
directly from a PowerShell console does also not provide any output nor does it kick of the batch script $error[0]
is empty after the execution- The function
Something-Else
is executing just fine (which meansStart-Some-Batch
is not preventing the PS-script from finishing its execution) - Running the PowerShell script elevated does not change a thing
- Calling the batch script from a cmd.exe prompt does also not start it (elevated or not)
- I am suspecting any of the hundred
Security Settings
that come via group-policy
What could cause such a strange behaviour? I am running out of ideas here.
Start-Process cmd "/c K:\Path\To\Batch.cmd"
?-WorkingDirectory
parameter. Sometimes I miss the forest for the trees...cmd
prompt. Are you unable to run it incmd
because you're not in the same directory as the .cmd file? You should post your resolution as an answer below so you can mark it as accepted. Answering your own questions is strongly encouraged.