Thursday, April 20, 2023

command to check vmrun. if not start it

 "C:\Program Files (x86)\VMware\VMware Player\vmrun.exe" list>run.txt

find  "Test.vmx" run.txt >nul

if %errorlevel%==0 (echo active is true) else (("C:\Program Files (x86)\VMware\VMware Player\vmrun.exe" -T player start "c:\VirtualBox VMs\vmware\test\Test.vmx" nogui) & (echo Logged time = %time% %date%>> d:\log.txt))

::pause

del run.txt

timeout /t 120




meaning

program1 & program2    --> run program1 until finish and run program2

program1 && program2 --> run program1 and program2 together

::  ---> comment on dos

if (ifcondition) (true command) else ( false command)


find  "Test.vmx" run.txt >nul

errorlevel

0 found

1 notfound

2 ???

auto start/stop when onboot/shudown/logon/logoff

In addition to Dan Williams' answer, if you want to add a Startup/Shutdown script, you need to be looking for Windows Settings under Computer Configuration. If you want to add a Logon/Logoff script, you need to be looking for Windows Settings under User Configuration.

So to reiterate what Dan said with this information included,

For Startup/Shutdown:

  1. Run gpedit.msc (Local Policies)
  2. Computer Configuration -> Windows Settings -> Scripts -> Startup or Shutdown -> Properties -> Add

For Logon/Logoff:

  1. Run gpedit.msc (Local Policies)
  2. User Configuration -> Windows Settings -> Scripts -> Logon or Logoff -> Properties -> Add
cr.
https://stackoverflow.com/questions/101647/how-to-schedule-a-task-to-run-when-shutting-down-windows

for only one user
window+R
shell:startup
paste program in folder