1

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.

Community
  • 1
  • 1
Johannes
  • 33
  • 1
  • 8
  • 1
    What version of windows are you running? upwards from win 8? https://technet.microsoft.com/en-us/library/dn593707(v=ws.11).aspx – Fuzzybear Dec 08 '16 at 13:26
  • windows 10. If I open a command prompt normally the exe is there. Just not in the command prompt opened from my code – Johannes Dec 08 '16 at 13:28
  • 1
    In the command prompt you open normally, is it as an administrator or normal user? – TheLethalCoder Dec 08 '16 at 13:29
  • While i dont have one of those in my windows\system32 area using any other exe in there I had no issues. What exactly are you having issues with? – BugFinder Dec 08 '16 at 13:30
  • I do not open it as administrator. The issue is that the command prompt I open from my code does not find the exe I want to run.(but it does exist) – Johannes Dec 08 '16 at 13:33
  • You need to add to the process arguments for the options. – jdweng Dec 08 '16 at 13:54
  • Hmm I do not understand, where and how would I go about doing that? And just to make clear will this make the exe visible from the command line created from the code? – Johannes Dec 08 '16 at 13:59

1 Answers1

2

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

Community
  • 1
  • 1
Johannes
  • 33
  • 1
  • 8