Johannes
Johannes

Reputation: 33

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.

Upvotes: 1

Views: 1229

Answers (1)

Johannes
Johannes

Reputation: 33

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

Upvotes: 2

Related Questions