1

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
5
  • Not sure what you mean - aren't those multiple commands? Do you mean at the same time? Commented Sep 23, 2015 at 7: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. Commented Sep 23, 2015 at 7:37
  • Running the first line only? See cmd /?. Take a special look to /k versus /c Commented Sep 23, 2015 at 8:20
  • Thanks I managed I just put start only in the beginning of each parallel command :) Commented Sep 23, 2015 at 9: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... Commented Sep 23, 2015 at 12:45

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks but I managed but it is still good to know other things.
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.