I'm curious as to why you are starting PowerShell as a new process rather
than hosting it within the application as shown here
http://msdn2.microsoft.com/en-us/lib...42(VS.85).aspx
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog:
http://richardsiddaway.spaces.live.com/
PowerShell User Group:
http://www.get-psuguk.org.uk
"luke.quinane@xxxxxx" wrote:
| Quote: |  | |
|
> Hi All,
>
> I'm trying to wrap Powershell in C# for a SSH server implementation
> but I am getting the following message:
>
> Windows PowerShell terminated with the following error:
> Access is denied. (Exception from HRESULT: 0x80070005
> (E_ACCESSDENIED))
>
>
> To start Powershell I am impersonating another user like so:
>
> WindowsIdentity windowsIdentity = (WindowsIdentity)
> identity;
> windowsIdentity.Impersonate();
>
> ProcessStartInfo psi = new ProcessStartInfo()
> {
> WindowStyle = ProcessWindowStyle.Hidden,
> CreateNoWindow = true,
> RedirectStandardError = true,
> RedirectStandardOutput = true,
> RedirectStandardInput = true,
> UseShellExecute = false,
> ErrorDialog = false,
> WorkingDirectory = @"C:\windows
> \system32\WindowsPowerShell\v1.0\",
> FileName = @"C:\windows\system32\WindowsPowerShell
> \v1.0\powershell.exe",
> Arguments = "-i Text -NoExit -Command -"
> };
>
> _childProcess = Process.Start(psi);
>
> Does anyone have any idea why this is not working? What sort of
> permission would Powershell be requiring to start up?
>
>
> Thanks in advance,
>
>
> Luke
>
| |
| | |