воскресенье, 26 мая 2019 г.

Running 2 commands in a batch file

Suppose you have some conditions for running commands in CMD.

Firstly you want to run two commands one after another and then exit from a CMD window. I mean that both commands will continue to run, but a black window will disappear.
In addition, you want the second command is being executed 30 sec after the first command.
And another condition - the script should run automatically with turning on my laptop.

I really had this need. I wanted that my VPN client will run and connect me to my work and then (and only then) RDP client will connect me to the server at work.

How I made this done? Here is the little nice batch script.

:: START OF THE SCRIPT

start "" "C:\Users\User\Documents\RDP\FortiClient.LNK" /k
timeout 30
cmd /c start mstsc C:\Users\User\Documents\RDP\Vlad2016.rdp

EXIT /B 0
GOTO:EOF
taskkill /F /IM cmd.exe

:: END OF THE SCRIPT

In the end, I put the script to the startup folder on my Windows and from then both command are running automatically one after another.



Комментариев нет:

Отправить комментарий