Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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!

like image 359
Jacintha Avatar asked Sep 07 '17 11:09

Jacintha


Video Answer


1 Answers

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
like image 128
Itchydon Avatar answered Sep 24 '22 20:09

Itchydon