How to start a virtual machine via a scheduled task?

0

I want to "start" a virtual machine (it may be powered down or hibernating) via a scheduled task in Windows 7. I cannot figure the correct way to do this.

I tried scheduling the cmd task, which works if I run it manually.

cmd "x:\test1.vmcx"

None of the applications in the Virtual PC area of system32 seem to be working with arguments.

c:\windows\system32\vpc.exe "x:\test1.vmcx"
c:\windows\system32\vmwindow.exe "test1"
c:\windows\system32\vmwindow.exe "x:\test1.vmcx"

And I tried the VMSal command described here, without an application argument (I used my machine's 2nd param, not one listed in the command).

c:\Windows\System32\VMSal.exe "test1" "||2073a9cc"

Anthony Mastrean

Posted 2009-12-14T16:24:11.463

Reputation: 525

Answers

0

I managed to get a batch file to work. The batch file leans on Explorer.

x:\test1.vmcx

I just make it the "program" in the Scheduled Task action.

x:\start-test1.bat

Anthony Mastrean

Posted 2009-12-14T16:24:11.463

Reputation: 525

I can't get the command window to disappear after execution... any thoughts? – Anthony Mastrean – 2009-12-15T16:20:17.710

0

Make a batch file with this in it:

"C:\path\to\VMWindow.exe" -file "C:\full\path\to\file.vmcx"

Replace values accordingly, as I do not know where your Virtual PC installation is situated. Keep the quotes just in case, as any path with spaces in it will break your batch script (ie: Virtual PC).

Save this and run the .bat file from task scheduler.

John T

Posted 2009-12-14T16:24:11.463

Reputation: 149 037

There is no virtualpc.exe in Windows Virtual PC (for Windows 7). There is a vpc.exe (the process that shows in Task Manager when VPC is running). The Start Menu shortcut "Windows Virtual PC" goes to vmwindow.exe. And XP Mode style application shortcuts are vmsal.exe. – Anthony Mastrean – 2009-12-14T17:12:52.890

You'll want vmwindow – John T – 2009-12-14T17:34:56.010

I can execute the batch file from the command line, but it is not working from Scheduled Tasks even with highest privileges. – Anthony Mastrean – 2009-12-14T21:24:11.133

0

I managed to create a PowerShell script that would execute the *.vmcx file in the Explorer registered application.

& 'x:\test1.vmcx'

I then registered the PowerShell executable as my task "action" and the path to this script as an "argument".

<path-to-ps>\powershell.exe x:\start-test1.ps1

Anthony Mastrean

Posted 2009-12-14T16:24:11.463

Reputation: 525

Using just the script as the task "program" opens in Notepad... even though it has a PowerShell icon. I don't want to mess with this behavior, so I use the PowerShell program and argument. – Anthony Mastrean – 2009-12-14T22:28:48.303

The command window closes after execution using the PS script! – Anthony Mastrean – 2009-12-15T16:30:59.343