用户登录
用户注册

分享至

Win7下VHD文件右键增强实现代码(vbs+注册表)

  • 作者: 獬豸烤肉
  • 来源: 51数据库
  • 2021-09-22

1、保存以下代码到:c:\windows\system32\vdm.vbs

复制代码 代码如下:

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" & tranargs, "", "runas", 1
  wscript.quit(5)
 else
  createobject("wscript.shell").run "cscript.exe " & _
   """" & wscript.scriptfullname & """" & replace(tranargs, "-hwind", "-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、导入注册表文件:

复制代码 代码如下:

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]
@="分离 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]
@="挂载 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"

文件打包下载:vhd 右键增强

软件
前端设计
程序设计
Java相关