简体   繁体   中英

C# command prompt commands not found

I am trying to call tpmvscmgr.exe located in C:\\Windows\\System32 from my c# application. I found this code:

       string strCmdText;
       strCmdText = @"/C Robocopy C:\Users\Johannes\test1 C:\Users\Johannes\test2";         
        System.Diagnostics.Process.Start("CMD.exe", strCmdText);

here Run Command Prompt Commands and it works good.

However when I try to change it to

  strCmdText = "/C Tpmvscmgr.exe create /name tpmvsc /pin default /adminkey random /generate ";

This does not work. In fact when I debug and look around in the command prompt opened by the code I can not find the tpmvscmgr.exe in windows/system32. Im guessing it is opened as a different user or with other priviledges or something but can this be fixed? I really would need to run a tpmvscmgr.exe command from code.

OK I figured something out. In my visual studio c# project I had "Any CPU" marked for the project. Apparently this means the console opens as win32. When I changed the c# project to x86 I could run tpmvscmgr.exe Pretty tricky stuff.

C# cmd prompt cannot see telnet.exe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM