Win7 the VHD file to the right button to enhance the implementation code (vbs+ registry) _vbs

Source: Internet
Author: User
Tags stdin

1, save the following code to: C:\windows\system32\vdm.vbs

Copy Code code as follows:

Dim Args
Set Args = wscript.arguments
Tranargs = ""
For i = 0 to Args.count-1
Tranargs = Tranargs & "" "& Args (i) &" "" & ""
Next

If Args (0) <> "-hflag" Then
 if Args (0) <> "-hwind" Then
  createobject (" Shell.Application "). ShellExecute "Wscript.exe", _
    "" "& Wscript.scriptfullname &" "" & "-hwind" & Tra Nargs, "", "RunAs", 1
  wscript.quit (5)
 else
  createobject ("Wscript.Shell"). Run "cscript.exe" & _
    "" "& Wscript.scriptfullname &" "" & Replace (Tranargs, "-HW IND ","-hflag "), 0, TRUE
  wscript.quit (1)
 end If
Else
  ' Add Your codes
  Dim Objshell, objexec
 set objshell = WScript.CreateObject ("Wscript.Shell")
 set objexec = Objshell.exec ("C:\windows\system32\diskpart.exe")

 objexec.stdin.writeline "select Vdisk file=" " & WScript.Arguments (2) & ""

Select case Args (1)
Case "/M"
ObjExec.StdIn.WriteLine "Attach Vdisk"
ObjExec.StdIn.WriteLine "Exit"
Wscript.Quit (0)

Case "/d"
ObjExec.StdIn.WriteLine "Detach Vdisk"
ObjExec.StdIn.WriteLine "Exit"
Wscript.Quit (0)

Case Else
' Other
Wscript.Quit (0)
End Select

Wscript.Quit (0)
End If

2. Import registry files:

Copy Code code as follows:

Windows Registry Editor Version 5.00

[Hkey_local_machine\software\classes\virtual.machine.hd\shell]
@= "None"
[Hkey_local_machine\software\classes\virtual.machine.hd\shell\dismount]
@= "Detach VHD (&d)"
[Hkey_local_machine\software\classes\virtual.machine.hd\shell\dismount\command]
@= "\" c:\\windows\\system32\\wscript.exe\ "c:\\windows\\system32\\vdm.vbs/d \"%1\ ""
[Hkey_local_machine\software\classes\virtual.machine.hd\shell\mount]
@= "Mount VHD (&m)"
[Hkey_local_machine\software\classes\virtual.machine.hd\shell\mount\command]
@= "\" c:\\windows\\system32\\wscript.exe\ "c:\\windows\\system32\\vdm.vbs/m \"%1\ ""
[HKEY_CLASSES_ROOT\.VHD]
@= "Virtual.Machine.HD"

File Packaged Downloads: VHD Right-enhanced

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.