如何在一个批处理文件中运行多个命令?

时间:2015-09-23 07:31:36

标签: windows batch-file cmd

我想在一个批处理文件中运行多个命令。

我尝试了&,&&,start,/ wait,call,:begin和goto begin命令,但没有运气。

以下是我的命令:

C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

sc config remoteregistry start= auto 

sc start remoteregistry 

sc config Schedule start=auto 

sc start Schedule 

sc stop McAfeeFramework

sc configure McAfeeFramework startup= disabled

sc stop  McShield

sc configure  McShield startup= disabled

sc stop McTaskManager 

sc configure McTaskManager startup= disabled

netsh advfirewall set AllProfiles state off 

sc stop MpsSvc

sc config MpsSvc start= disabled

2 个答案:

答案 0 :(得分:1)

C:\Windows\System32\cmd.exe /k <command>

启动执行的新cmd上下文,但/k保持新上下文打开。您希望在执行后关闭它,因此可以执行原始上下文中的其他命令。使用/c代替/k来执行此操作。

cmd /?

中描述

答案 1 :(得分:0)

好吧,默认情况下批处理脚本已经这样做了,但是我猜您在 cmd.exe 上使用 /K 是不必要且有害的,即使 A / C 可以完成这项工作,请记住,这不是必需的.

File1.bat*

C:\Windows\System32\cmd.exe /c %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

sc config remoteregistry start= auto 

sc start remoteregistry 

sc config Schedule start=auto 

sc start Schedule 

sc stop McAfeeFramework

sc configure McAfeeFramework startup= disabled

sc stop  McShield

sc configure  McShield startup= disabled

sc stop McTaskManager 

sc configure McTaskManager startup= disabled

netsh advfirewall set AllProfiles state off 

sc stop MpsSvc

sc config MpsSvc start= disabled