无法使用此Windows Powershell运行此简单的.exe文件

Jac*_*ker 6 powershell

我是编码的新手,所以我不了解该论坛上的大多数类似文章。

我正在做一个简单的C编程课程,并且需要从Powershell运行一个notepad ++文件。该文件仅包含以下内容:

#include <stdio.h> 

 int main()
  {
    int num = 931;

    printf("The number 'num' is %d\n", num);
    return 0; 
}   
Run Code Online (Sandbox Code Playgroud)

我调用了文件:Variables.c,然后将其放入Powershell:

PS C:\Users\Raven\Desktop\C Programming> gcc Variables.c -o Variables.exe 
Run Code Online (Sandbox Code Playgroud)

其次是:

PS C:\Users\Raven\Desktop\C Programming> Variables.exe
Run Code Online (Sandbox Code Playgroud)

然后,我得到以下错误:

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
Run Code Online (Sandbox Code Playgroud)

这里发生了什么??

提前谢谢了!

Itc*_*don 7

要在PowerShell中运行exe,您需要包括.\ 确保您位于正确的目录中,然后尝试执行以下操作:

 .\Variables.exe
Run Code Online (Sandbox Code Playgroud)

  • 哦!是的当然。这是 Powershell 最常见和最令人恼火的怪癖之一。 (2认同)
  • 哇,非常感谢!你让我很快乐 :) (2认同)