Armand Peens
Armand Peens

Reputation: 31

How to run multiple commands in one batch file?

I want to run multiple commands in one batch file.

I tried the &, &&, start, /wait, call, :begin and goto begin commands but no luck.

Here are my commands:

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

Upvotes: 1

Views: 12545

Answers (2)

user15732390
user15732390

Reputation:

Well, batch scripts already do it by default, but i guess that your usage of /K on cmd.exe it was unnecessary and harmful, and A / C could have done the job even though, remembering, it is not necessary.

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

Upvotes: 0

Stephan
Stephan

Reputation: 56228

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

starts a new cmd context where is executed, but /k keeps that new context open. You want to close it after executing , so further commands from the original context can be executed. Use /c instead of /k to do so.

described in cmd /?

Upvotes: 2

Related Questions