none
Powershell - launching .exe

    Question

  • Can someone please explain why I can't run .exe files in Powershell? I've tried just typing the command like I do in CMD, I've tried invoke-item and invoke-expression and each time I get 'Cannot find path'.. 'because it does not exist.'  The .exe file exists, I type in the full path, it works in a DOS prompt, but not in Powershell.

    c:\windows\system32\calc.exe works just fine; however, other .exe files such as dnscmd.exe cannot be found, even though they are there in the same folder.

    Wednesday, January 04, 2012 3:34 PM

Answers

  • Hi Olsonta,

    You should be able to run any EXE within powershell....'

    Example:

     


    Thanks, Wilson Souza - MSFT This posting is provided "AS IS" with no warranties, and confers no rights
    Wednesday, January 04, 2012 6:43 PM
  • Good to know!  Though, your mileage may vary on some .exe files.  As it turns out I was using the x32 bit version of Powershell ISE, which in turn must launch the x32 version of Powershell.  Once I switched to the x64 version I could run the .exe I wanted.
    Wednesday, January 04, 2012 7:35 PM

All replies

  • Wow, if I change to the directory and type dir *.exe the file isn't listed, but if I go into cmd and do the same thing it is listed.  Ok, why can't Powershell find some .exe files?  The file permissions are the same. Are they blocked or hidden for security sake? If so, how can I tell PS to allow the .exe? 
    Wednesday, January 04, 2012 3:38 PM
  • Hi Olsonta,

    You should be able to run any EXE within powershell....'

    Example:

     


    Thanks, Wilson Souza - MSFT This posting is provided "AS IS" with no warranties, and confers no rights
    Wednesday, January 04, 2012 6:43 PM
  • Good to know!  Though, your mileage may vary on some .exe files.  As it turns out I was using the x32 bit version of Powershell ISE, which in turn must launch the x32 version of Powershell.  Once I switched to the x64 version I could run the .exe I wanted.
    Wednesday, January 04, 2012 7:35 PM