Create Shortcut of Hyper-V Virtual Machine in Windows  

Page 3 of 3 FirstFirst 123

  1. Posts : 4
    Windows 10
       #20

    I don't need that code, but I have my shortcut (or task) set to run as admin.

    If you always shut down the VM, your code is much simpler. I pop on and off of my VM frequently, so I close the connection but want to pause or save it for quicker restart. My code gives me the option of how to exit each time without having to do it through the connection window menus. But yours is probably better for many people's applications.
      My Computer

  2. MetalSaint's Avatar
    Posts : 17
    Windows 10 Pro
       #21

    It worked for me and there was no need to create Task with admin rights.
      My Computers

  3. Kari's Avatar
    Posts : 17,119
    Windows 10 Pro
    Thread Starter
       #22

    I've added a new video to tutorial:



    Video shows a more elegant method to create a Hyper-V VM shortcut than this tutorial. It shows how to create a single shortcut which when clicked, starts the VM, opens its VM Connection window, and when VM connection is closed, automatically shuts down the VM.

    For this method, you will need one simple PowerShell script (extension .ps1), and one simple Visual Basic script (extension .vbs).

    PowerShell script AnyName.ps1:

    Code:
    Start-VM "VM_Name"
    C:\Windows\System32\vmconnect.exe localhost "VM_Name" | Out-Null
    Stop-VM "VM_Name"

    Visual Basic script AnyName.vbs:

    Code:
    command = "powershell.exe -nologo -command PathAndNameOfPowerShellScript.ps1"
    set shell = CreateObject("WScript.Shell")
    shell.Run command,0
    Kari
      My Computer


 

Tutorial Categories

Create Shortcut of Hyper-V Virtual Machine in Windows Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


Related Threads
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 05:46.
Find Us




Windows 10 Forums