Answered Powershell - launching .exe

  • Wednesday, January 04, 2012 3:34 PM
     
     

    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.

All Replies

  • Wednesday, January 04, 2012 3:38 PM
     
     
    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 6:43 PM
    Moderator
     
     Answered

    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 7:35 PM
     
     Answered
    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.