var processStartInfo = new ProcessStartInfo();
processStartInfo.WorkingDirectory = @"c:\temp";
processStartInfo.FileName = "cmd.exe";
processStartInfo.UseShellExecute = false;
processStartInfo.RedirectStandardInput = true;
// set additional properties
Process proc = Process.Start(processStartInfo);
//process.StandardInput.WriteLine("c:");
proc.StandardInput.WriteLine("powershell -ExecutionPolicy Bypass c:\\temp\\autologin.ps1");
proc.StandardInput.Close();
Powershell
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
Set-ItemProperty $RegPath "AutoAdminLogon" -Value "0" -type String
Set-ItemProperty $RegPath "DefaultUsername" -Value " " -type String
Set-ItemProperty $RegPath "DefaultPassword" -Value " " -type String
I've been trying to run a powershell script that my program writes. I can't just run the powershell commands in the program because I will be rebooting the computers and accessing that powershell program again.
Any ideas? Currently it will run the commands but not make the changes to the registry but if i enter the commands myself into CMD it works perfectly. So I'm a little stuck the only thing I need is for C# to run that powershell script for me.
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
reg keys for reference
NEW EDIT: program is executing but putting the registry keys in WOW6432Node