When running powershell from other programs,
powershell does not exit. For example if i run powershell -command dir from msdeploy, it executes dir command but then powershell process wait (for sth?) till timeout. I'll paste output at the end. The similar issue are experiencing others, like
http://www.vistax64.com/powershell/...exits.html http://www.vistax64.com/powershell/...shell.html I suspect it would be the same when running powershell in c# using Process
I'm using windows 7, included powershell v2.
Exploring powershell process with ProcessExplorer shows that powerhsell is in Wait:Executive state and thread stack is this:
ntoskrnl.exe!SeAccessCheckWithHint+0xb4a
ntoskrnl.exe!KeAcquireSpinLockAtDpcLevel+0x682
ntoskrnl.exe!KeWaitForMutexObject+0x19f
ntoskrnl.exe!PsIsSystemProcess+0x68
ntoskrnl.exe!KeStackAttachProcess+0x11b9
ntoskrnl.exe!KeAcquireSpinLockAtDpcLevel+0x88d
ntoskrnl.exe!KeWaitForMutexObject+0x19f
ntoskrnl.exe!IoRemoveShareAccess+0x319
ntoskrnl.exe!NtReadFile+0x633
ntoskrnl.exe!KeSynchronizeExecution+0x3a43
ntdll.dll!ZwReadFile+0xa
KERNELBASE.dll!ReadFile+0x7a
kernel32.dll!ReadFile+0x59
mscorwks.dll!IEE+0xb743
And here is output when executing powershell with msdeploy:
C:\Program Files\IIS\Microsoft Web Deploy>msdeploy -verb:sync -source:runCommand="powershell -command dir c:\help" -dest:Auto Info: Updating runCommand (powershell -command dir c:\help).
Info:
Info:
Info: Directory: Microsoft.PowerShell.Core\FileSystem::C:\help
Info:
Info: Mode LastWriteTime Length Name
Info:
Info: ---- ------------- ------ ----
Info: -a--- 17.12.2009 10:50 0 me.txt
Info:
Info:
Info: Warning: The process 'C:\Windows\system32\cmd.exe' (command line '/c "powershell -command dir c:\help"') is still running. Waiting for 1000 ms (attempt 1 of 5).
Warning: The process 'C:\Windows\system32\cmd.exe' (command line '/c "powershell -command dir c:\help"') is still running. Waiting for 1000 ms (attempt 2 of 5).
Warning: The process 'C:\Windows\system32\cmd.exe' (command line '/c "powershell -command dir c:\help"') is still running. Waiting for 1000 ms (attempt 3 of 5).
Warning: The process 'C:\Windows\system32\cmd.exe' (command line '/c "powershell -command dir c:\help"') is still running. Waiting for 1000 ms (attempt 4 of 5).
Warning: The process 'C:\Windows\system32\cmd.exe' (command line '/c "powershell -command dir c:\help"') is still running. Waiting for 1000 ms (attempt 5 of 5).
Error: The process 'C:\Windows\system32\cmd.exe' (command line '/c "powershell -command dir c:\help"') was terminated because it exceeded the wait time.
Error count: 1.
C:\Program Files\IIS\Microsoft Web Deploy>
Thank you for answer