visual-studio 在 vs2008 中产生 cmd.exe 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/892636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:31:43  来源:igfitidea点击:

spawning cmd.exe error in vs2008

visual-studiovisual-studio-2008visual-c++

提问by Cute

I have created a simple vc++ console application and try to print "Hello World". I am using Windows Server 2003 machine.

我创建了一个简单的 vc++ 控制台应用程序并尝试打印“Hello World”。我使用的是 Windows Server 2003 机器。

When I try to build this project I got the error as Error: spawning cmd.exe

当我尝试构建这个项目时,我收到错误消息:生成 cmd.exe

How do I fix this?

我该如何解决?

采纳答案by Cute

yes i hav found where the proble. I unable to locate path of cmd.exe so go to visualstudio tools->options->projects and ->vc++ directories and specify ($SystemRoot)/system32 then it working fine.

是的,我找到了问题所在。我无法找到 cmd.exe 的路径,所以转到visualstudio tools->options->projects 和->vc++ 目录并指定 ($SystemRoot)/system32 然后它工作正常。

回答by aJ.

Check if cmd.exe is in <Path>environment variable?

检查 cmd.exe 是否在<Path>环境变量中?

I just did a small test by removing the %SystemRoot%\system32from pathenvironment variable and I got the same problem what you are facing.

我只是通过删除%SystemRoot%\system32frompath环境变量做了一个小测试,我遇到了你所面临的同样问题。

Error 4 Error spawning 'cmd.exe'. Project SEH

错误 4 生成“cmd.exe”时出错。SEH计划

If it is the path issue then try adding below to Projects and Solutions -> VC++ Directories:

如果是路径问题,请尝试将以下内容添加到Projects and Solutions -> VC++ Directories

$(SystemRoot)\System32

$(SystemRoot)\System32

回答by silwar

If you get error like this

如果你得到这样的错误

Just open Tools –> Options –> Projects and Solutions –> VC++ Directories

只需打开工具 –> 选项 –> 项目和解决方案 –> VC++ 目录

and add these lines :

并添加这些行:

  1. $(SystemRoot)\System32
  2. $(SystemRoot)
  3. $(SystemRoot)\System32\wbem
  1. $(SystemRoot)\System32
  2. $(SystemRoot)
  3. $(SystemRoot)\System32\wbem

回答by blueskin

Yep. (Another weird windows error) Projects and Solutions -> VC++ Directories -> Executable Files Add $(SystemRoot)\System32 it works

是的。(另一个奇怪的 Windows 错误)项目和解决方案 -> VC++ 目录 -> 可执行文件添加 $(SystemRoot)\System32 它有效

回答by Priti Biyani

It was giving error for me because cmd.exewas not accessible with the current user. What I did to solve this problem :

它给了我错误,因为当前用户无法访问cmd.exe。我做了什么来解决这个问题:

  1. Close current Visual Studio.
  2. Reopen Visual Studio by right clicking on visual studio and select 'Run as administrator'
  3. Now run The project.
  1. 关闭当前的 Visual Studio。
  2. 通过右键单击 Visual Studio 并选择“以管理员身份运行”重新打开 Visual Studio
  3. 现在运行该项目。

Why It works

为什么有效

To access cmd.exe application must have privilege to run this. It doesn't have permission to access this and hence it works next time when you tries to access it normally(without running application as Administrator)

要访问 cmd.exe 应用程序必须具有运行它的权限。它无权访问它,因此下次您尝试正常访问它时它可以工作(无需以管理员身份运行应用程序)

Operating SystemWindows 7

操作系统Windows 7

回答by Peter Mourfield

Are you running on Vista? Could this be a case of needing to run Visual Studio as Administrator?

你在 Vista 上运行吗?这可能是需要以管理员身份运行 Visual Studio 的情况吗?

回答by Jeremy

I believe cmd.exe is not runnable by a non administrative user by default on Windows Server 2003, so I would check its permissions. That of course assumes you are not running it as Administrator already.

我相信 cmd.exe 在 Windows Server 2003 上默认情况下不能由非管理用户运行,所以我会检查它的权限。这当然假设您尚未以管理员身份运行它。