Search code examples
batch-filevmwarewindows-task-schedulervmware-workstation

Open and close Virtual Machines in windows10 from task scheduler


Basically im trying to open and close a virtual machine from windows 10 pro task scheduler, but im not able. Start script

SET maxvalue=200
SET minvalue=0

SET /A rand=((%RANDOM%)%%(%maxvalue%))+(%minvalue%)
ping 127.0.0.1 -n %rand% > nul

cmd.exe /C "C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" -T ws start 5.vmx nogui

Stop script

SET maxvalue=200
SET minvalue=0

SET /A rand=((%RANDOM%)%%(%maxvalue%))+(%minvalue%)
ping 127.0.0.1 -n %rand% > nul
"C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" stop 5.vmx

im not even able to start it, the script if i open it by myself it works, but in task scheduler it dosnt. i run it with highest permissions.

both scripts are in the same path thath the virtual machine file (where .vmx) is.


Solution

  • I solved it. It was that easy to put the full path of the *.vmx file,

    The point of randomizing when opening is that I want a random interval between virtual machine start, that's all.

    https://communities.vmware.com/thread/588283