【问题标题】:Batch script to open command prompt but not execute the command打开命令提示符但不执行命令的批处理脚本
【发布时间】:2015-12-10 11:43:19
【问题描述】:

谁能建议我如何创建一个可以打开命令窗口但只需键入我指定的命令的批处理文件。只有当我手动输入时它才会被执行。例如,我创建了以下 .bat 文件:

test.bat

cmd.exe /K "cd D:\Code_Home && D: && cls && dir"

现在的问题是它打开了命令窗口并列出了目录内容,而我只希望 dir 命令留在那里而不列出目录内容,直到我手动按 Enter 键。请建议是否有办法做到这一点

【问题讨论】:

标签: windows batch-file cmd


【解决方案1】:

我在How can I run cmd from batch file and add text to line without executing? 处复制了已接受的答案并稍作调整以解决此问题:

@if (@CodeSection == @Batch) @then

@echo off
rem Enter the prefill value in the keyboard buffer
CScript //nologo //E:JScript "%~F0" "cd D:\Code_Home & D: & cls & dir"
cmd.exe
goto :EOF

@end

WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));

在给定链接上的更多详细信息。

【讨论】:

    猜你喜欢
    • 2012-08-30
    • 1970-01-01
    • 2023-02-26
    • 1970-01-01
    • 2013-03-12
    • 2012-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多