I have a problem with starting a powershell inside a batch script with C#:
I wan't to replace the EnvironmentVariable "CLIENTNAME"for the Process so i did it like this:
ProcessStartInfo pi = new ProcessStartInfo();
pi.FileName = Environment.ExpandEnvironmentVariables("test.bat");
pi.UseShellExecute = false;
pi.EnvironmentVariables["clientname"] = clientname;
Process.Start(pi);
My "test.bat" looks like this:
powershell %logonserver%\netlogon\test.ps1
pause
The result is that I get this exception:
Windows PowerShell terminated with the following error:
Invalid Signature. (Exception from HRESULT: 0x80090006)
If I start the test.bat with doubleclick everything works fine... Why?
Thanks for your help.
now I have the answer to my question:
Environment.SetEnvironmentVariable("clientname", clientname);
ProcessStartInfo pi = new ProcessStartInfo();
pi.FileName = Environment.ExpandEnvironmentVariables("test.bat");
pi.UseShellExecute = true;
Process.Start(pi);
User contributions licensed under CC BY-SA 3.0