Hyper-V Windows 10 Batch file to start/stop VM on command


  1. Posts : 6
    Windows 10
       #1

    Hyper-V Windows 10 Batch file to start/stop VM on command


    I am running Hyper-V on Windows 10.

    I am using the PC for media playback / gaming in big screen and rarely see the desktop. I have an service running and APP on my phone, so i can start batch files and programs without the need for a KB/M.

    I have just setup a VM, but i dont want it running all the time, i just want to use it to do some video rendering or whatever when i need it to, i especially don't want it to be running when playing games.

    so is there a way i could write a batch file or VBS to start the VM (not connect) then i could connect to VM via remote desktop on my laptop (or other machine)

    and another batch file to turn it off, when i want to do some gaming?

    i have googled for about an hour but came up empty
      My Computer


  2. Posts : 17,661
    Windows 10 Pro
       #2

    The script shown in this video does exactly that:

      My Computer


  3. Posts : 4,802
    Windows 10 ProWorkstation -- Whichever is highest build number.
       #3

    When you make Kari's powershell script put this
    Code:
    Stop-Process -processname powershell
    as the last line, and powershell will exit when you close the Virtual Machine window!
      My Computer


  4. Posts : 17,661
    Windows 10 Pro
       #4

    flybynite said:
    When you make Kari's powershell script put this
    Code:
    Stop-Process -processname powershell
    as the last line, and powershell will exit when you close the Virtual Machine window!
    Totally unnecessary.

    The video shows two ways to launch the PowerShell script, a normal shortcut and a bit more "elegant" VB script. Both ways will terminate the PowerShell process as soon as the user has closed vm window and the script has shut down the vm.

    If any additional commands would have been needed, I had added them in my instructions.
    Last edited by Kari; 29 Mar 2016 at 02:21. Reason: Typos
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:41.
Find Us




Windows 10 Forums