Ich versuche, WMIC als Admin über mein Programm zu starten, mit dem folgenden Code funktioniert, aber nur wenn WMIC.exe bereits als Administrator ausgeführt wird, sonst wird nur ein zurückgeben leeres HTML. Ich kann nicht scheinen, ein in Verbindung stehendes Problem auf stackoverflow oder anderswo zu finden ... Sieht jemand das Problem hier?Process.start() WMIC.exe Passwort Problem
Meine Methode der Secure zum Umwandeln:
SecureString secureString = new SecureString();
foreach (char ch in str)
{
secureString.AppendChar(ch);
}
secureString.MakeReadOnly();
return secureString;
Startcode:
string path = @"C:\Temp\";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.UseShellExecute = false;
startInfo.FileName = "cmd";
startInfo.Domain = "EU";
startInfo.Verb = "runas";
startInfo.UserName = "Username";
startInfo.Password = GetSecureString("Password");
startInfo.Arguments = @"/k wmic.exe /node: " + "\"" + txt_input_computers.Text + "\" " + "/output:" + path + @"\" + txt_input_computers.Text + ".html " + DDL_WMIC.Text
+ " list full /format:hform";
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
Process.Start(path + @"\" + txt_input_computers.Text + ".html");
Ihre Frage ist nicht klar. Wenn es WMI ist, lassen Sie mich Ihnen sagen, dass WMI im Admin-Modus ausgeführt werden muss. Starten Sie Visual Studio im Admin-Modus – Apoorv
Entschuldigung, ich habe meine Frage umformuliert, siehe oben – DaBeast