0

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
halfer
  • 19,824
  • 17
  • 99
  • 186
Armand Peens
  • 21
  • 1
  • 2
  • 8
  • Not sure what you mean - aren't those multiple commands? Do you mean at the same time? – Pekka Sep 23 '15 at 07:32
  • 1
    Yes cmd doesn't want to run them all when you double click it or run it as admin but it only runs the first one. – Armand Peens Sep 23 '15 at 07:37
  • Running the first line only? See `cmd /?`. Take a special look to `/k` versus `/c` – Stephan Sep 23 '15 at 08:20
  • Thanks I managed I just put start only in the beginning of each parallel command :) – Armand Peens Sep 23 '15 at 09:05
  • 1
    I suggest that @Stephan convert its comment into an answer and the OP select it, so the rest of us know that this question was already solved... – Aacini Sep 23 '15 at 12:45

2 Answers2

2
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 /?

Stephan
  • 53,940
  • 10
  • 58
  • 91
0

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