Home > Software design >  Running an exe file just by giving it's name to cmd
Running an exe file just by giving it's name to cmd

Time:01-18

I am running an exe file created with python from the powershell.

I am running it by doing

& C\users\rey\.....\main.exe

what I want to is to just pass the main.exe to the command prompt to run the exe file but when I do that now I get the error that:

"main.exe is not recognized as a cmdlet function, function, script type ...."

How would I go about doing this?

CodePudding user response:

maybe because of missing Apostrophe ('), try this :

& 'C:\users\rey\.....\main.exe'

CodePudding user response:

Keep the path of the file or the path of the folder containing the file in system environment variables. Then you can use it directly.

CodePudding user response:

Either powershell or cmd need to know the complete path to your file, but if you don't want to repeatedly type that long & C:\users\rey\.....\folder\main.exe every time, you could set your powershell to work from your folder with:

cd C:\users\rey\.....\folder\

Then call the .exe with .\main.exe

  •  Tags:  
  • Related