Jacintha
Jacintha

Reputation: 175

Can't run this simple .exe file with this Windows Powershell

I'm a complete newbie to coding, so I don't understand most of the similar posts on this forum.

I'm doing a simple C programming course, and I need to run a notepad++ file from the Powershell. The file only contains this:

#include <stdio.h> 

 int main()
  {
    int num = 931;

    printf("The number 'num' is %d\n", num);
    return 0; 
}   

I called the file: Variables.c then I put this into the Powershell:

PS C:\Users\Raven\Desktop\C Programming> gcc Variables.c -o Variables.exe 

Followed by:

PS C:\Users\Raven\Desktop\C Programming> Variables.exe

I then get the following error:

Variables.exe : The term 'Variables.exe' is not recognized as the name of a cmdlet, funct ion, script file, or operable program. Check the spelling of the name, or if a path was i ncluded, verify that the path is correct and try again. At line:1 char:1
+ Variables.exe
+ ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Variables.exe:String) [], CommandNotFound     Exception
    + FullyQualifiedErrorId : CommandNotFoundException

What is going on here??

Many thanks in advance!

Upvotes: 17

Views: 23468

Answers (2)

Itchydon
Itchydon

Reputation: 2596

To run an exe in PowerShell you need to either provide the full path to the exe or the relative path by preceding the filename with .\ Ensure you are in the correct directory and try:

 .\Variables.exe

Upvotes: 26

Rumado
Rumado

Reputation: 327

The case is you are using windows powershell. You can execute that fileName.exe command in windows cmd (in the exe file stored path).

Upvotes: 1

Related Questions