Created
November 24, 2019 14:06
-
-
Save pradishb/a3ae4e7514b951aa185994c474dde156 to your computer and use it in GitHub Desktop.
VMware Workstation tool to clone, run and set environment variables in a batch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set vmrun=C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe | |
set mothervm=C:\Users\Pradish\Documents\Virtual Machines\Windows 7 x64\Windows 7 x64.vmx | |
set workerdirectory=C:\workers | |
set start=1 | |
set end=10 | |
set guestusername=Administrator | |
set guestpassword=ease | |
echo All bots will be cloned again and existing data in %workerdirectory% will be wiped. Are you sure? | |
pause | |
echo --------------------------------------------------------------------------------------------------- | |
echo Cleaning up %workerdirectory% ... | |
rmdir /s /q "%workerdirectory%" | |
echo --------------------------------------------------------------------------------------------------- | |
for /l %%i in (%start%, 1, %end%) do ( | |
echo Cloning to %workerdirectory%\worker%%i\worker%%i.vmx\ ... | |
"%vmrun%" -T ws clone "%mothervm%" "%workerdirectory%\worker%%i\worker%%i.vmx" linked -cloneName=worker%%i | |
) | |
echo --------------------------------------------------------------------------------------------------- | |
echo All bots will be started. Are you sure? | |
pause | |
echo --------------------------------------------------------------------------------------------------- | |
for /l %%i in (%start%, 1, %end%) do ( | |
echo Starting %workerdirectory%\worker%%i\worker%%i.vmx\ ... | |
"%vmrun%" start "%workerdirectory%\worker%%i\worker%%i.vmx" | |
"%vmrun%" -gu %guestusername% -gp %guestpassword% writeVariable "%workerdirectory%\worker%%i\worker%%i.vmx" guestEnv WORKER %%i | |
"%vmrun%" -gu %guestusername% -gp %guestpassword% writeVariable "%workerdirectory%\worker%%i\worker%%i.vmx" guestEnv SERVER %ComputerName% | |
) | |
echo --------------------------------------------------------------------------------------------------- | |
echo Script completed successfully. | |
echo --------------------------------------------------------------------------------------------------- | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment