0

I have two batch files as below, and I want to merge them in to one btach file? (I don't want to run them seperately want to one click to run) First one delete and copy file, second one is opens chrome and login. These batch files working properly one by one when I clicked. But I need one batch file.

Thanks for your help..

First one is:

@echo off
del "C:\web.config"
copy "C:\\Web - New.config" "C:\web.config"

Second one one is:

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

@echo off

rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
START CHROME "http://localhost:15000/"
rem the script only works if the application in question is the active window. Set a 
timer to wait for it to load!
timeout /t 2
rem use the tab key to move the cursor to the login and password inputs. Most htmls 
interact nicely with the tab key being pressed to access quick links.
rem %SendKeys% "{TAB}"
rem now you can have it send the actual username/password to input box

%SendKeys% "admin"
%SendKeys% "{TAB}"
%SendKeys% "1234"
%SendKeys% "{ENTER}"

goto :EOF

@end
// JScript section

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));

1 Answers1

0

When you have two batchfiles, batch1.bat and batch2.bat and you want both of them to run in one batchfile, the simpliest solution is to create this batchfile:

call batch1.bat
call batch2.bat

There's absolutely no problem running a batchfile from another batchfile!

Dominique
  • 16,450
  • 15
  • 56
  • 112
  • You're going to want to use `call batch1.bat` and `call batch2.bat` so that flow returns to the main script after `batch1.bat` ends; otherwise `batch2.bat` will never run. – SomethingDark Mar 23 '22 at 12:57
  • I need one .bat file like merging my example. Because Two bat files can work in to new one but after that I have 3 files. Similar this I have 76 files will be 228 files and hard manage later. Btw thanks for your advise but I knew to run two files in one bat file as well. – Techno BAKKAL Mar 23 '22 at 13:00
  • @TechnoBAKKAL: and why do you need 76 up to 228 files? Are you aware of the passing of arguments to batchfiles, as explained in this URL: https://stackoverflow.com/questions/26551/how-can-i-pass-arguments-to-a-batch-file – Dominique Mar 23 '22 at 13:03
  • I found similar examples but not worked. That’s waht I need help. Thanks. – Techno BAKKAL Mar 23 '22 at 13:05
  • @TechnoBAKKAL: do you mean your problem is solved? If not, please elaborate the question. – Dominique Mar 23 '22 at 13:10
  • Not solved. I need 2 giles merging to one file still. – Techno BAKKAL Mar 23 '22 at 13:11
  • 1
    @TechnoBAKKAL - This solution scales indefinitely. If running multiple scripts one after the other doesn't solve your problem, then what are you _actually_ asking? – SomethingDark Mar 23 '22 at 13:31
  • There is no solution right now. I asked question that if it is possible to run 2 files in one time. Because I need what I asked. If u have a solution example or modify my code for working this will be solve my problem. A.bat and B.bat files con be merge into C.bat is my question? Is it clear? If I have C.bat I will delete A.bat and B.bat and use C.bat only. Will reduce %66,6 files traffic in my sidr. – Techno BAKKAL Mar 23 '22 at 13:43
  • There is absolutely no problem merging both batchfiles into one. – Dominique Mar 23 '22 at 13:50
  • Chrome opens but login items not pasting. – Techno BAKKAL Mar 24 '22 at 04:57