for / f立即关闭cmd提示 [英] for /f closes cmd prompt immediately

查看:233
本文介绍了for / f立即关闭cmd提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我打开cmd.exe并键入第一行,然后按ENTER,它工作正常。当我输入另一行并按ENTER键,它立即关闭。

When I open cmd.exe and type that first line and push ENTER, it works fine. When I input that other line and push ENTER, it closes immediately.

我可以改变('a')到('asdfgh')然后同样的问题。或者%q到%f同样的问题。

I can change ('a') to ('asdfgh') then same problem. or %q to %f same problem.

不同的是/ f,由于某种原因FOR / F与cmd.exe关闭。

The difference is the /f, for some reason the FOR /F with ('......') causes cmd.exe to close.

这发生在我的一个系统上,而不是另一个

This happens on one of my systems and not another

C:\>for %q in ('a') do echo %q   <ENTER>

C:\>echo 'a'
'a'

C:\>for /f %q in ('a') do echo %q <ENTER>


推荐答案

这家伙似乎已成功解决了一个非常相似的问题:

This guy seems to have solved a very similar problem successfully:

立即关闭cmd窗口

这种情况下的问题是与 COMSPEC 环境变量有关,最初被错误地设置,似乎。该用户已将登出Windows帐户并退回。

The problem in that case turned out to have to do with the COMSPEC environment variable, it being incorrectly set initially, as it seems. The guy applied logging out of the Windows account and back in.

这篇关于for / f立即关闭cmd提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆