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

Source: Internet
Author: User
Tags exit stdin
This article mainly introduced the Win7 under the VHD file right key enhancement realization method, needs the friend may refer to under

1, save the following code to: C:windowssystem32vdm.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.app Lication "). 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
 di M Objshell, objexec
 set objshell = WScript.CreateObject ("Wscript.Shell")
 set objexec = objShell.Exec ("C:windowssystem32diskpart.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_MACHINESOFTWAREClassesVirtual.Machine.HDShell]
@= "None"
[HKEY_LOCAL_MACHINESOFTWAREClassesVirtual.Machine.HDShellDismount]
@= "Detach VHD (&d)"
[Hkey_local_ MACHINESOFTWAREClassesVirtual.Machine.HDShellDismountcommand]
@= "" C:windowssystem32wscript.exe "C: windowssystem32vdm.vbs/d "%1" "
[HKEY_LOCAL_MACHINESOFTWAREClassesVirtual.Machine.HDShellMount]
@=" Mounts the VHD ( &M) "
[HKEY_LOCAL_MACHINESOFTWAREClassesVirtual.Machine.HDShellMountcommand]
@=" "C: Windowssystem32wscript.exe "c:windowssystem32vdm.vbs/m" "%1" "
[Hkey_classes_root.vhd]
@=" Virtual.Machine.HD "

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.