I have a need to launch a Windows Virtual PC on Windows 7 as a scheduled task overnight, so that it can get Microsoft patches and antivirus updates. This needs to happen while nobody is logged onto the host system. I get Access Denied when I try to run a task to do this.
migrated from serverfault.com Mar 2 '12 at 16:47
This question came from our site for system and network administrators.
Below are the steps I went through to get this working. Thanks to Zdenek Brydl for his breakthrough post on the Windows forums, which set me in the right direction. http://social.technet.microsoft.com/Forums/en/w7itprovirt/thread/2e83b9fc-a6f4-4c4f-b89f-d6cf756f18d2
By default, Virtual PC is locked down so that it can only be run by an interactive user. This means you won’t be able to launch it as a background task without modifying the DCOM configuration.
After making these changes then you will be able to setup a scheduled task to launch a VM as the local Administrator or other account you’ve configured. There are several ways to do this, but it’s easiest to create a batch file that simply launches the .VMCX file (VM configuration file) for the VM that you want. Then your scheduled task will just run that batch file. Alternatively you can put it in a Powershell script (PS1) file and have the task run Powershell with that script as the argument. I went with that option.
Caveat / Warning
Once your scheduled task has launched the VM, it will become unavailable to any other users who happen to log onto the host machine interactively and want to use it. So, you’ll want to make sure you do this during slow hours, and you will also want to set up a scheduled task on the VM to have it shut itself down after a certain period. If you leave it running it will continue to eat up system resources on the host, and will be useless to the interactive users.
You can setup a scheduled task to run Virtual PC.exe (whether user is logged in our not).
Step one is to build the command line to start the VM: http://letitknow.wordpress.com/2012/02/29/command-line-reference-for-microsoft-virtual-pc/
Step two is to build the command line to stop the VM
Step three is to schedule the two scripts. Be sure to set the authenticating user & password and to use highest privileges available. http://windows.microsoft.com/en-US/windows7/schedule-a-task