i trying run wmic admin via program, using following code works, if wmic.exe allready run administrator, otherwise return empty html. can't seem find related issue on stackoverflow or elsewhere... see issue here?
my method converting securestring:
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");
found problem, due win7 bug of wmic. fix this, can copy *.xsl files of c:\windows\system32\wbem\en-us application startup path (or elsewhere) , link this:
startinfo.arguments = @"/k wmic.exe /node: " + "\"" + "computername" + "\" " + "/output:" + @"c:\temp\outputfile.html " + "wmiattrib" + " list full /format:\"" + application.startuppath + "\\hform\"";
possible dupe wmic error (invalid xsl format) in windows7
Comments
Post a Comment