本文共 7179 字,大约阅读时间需要 23 分钟。
“VM6辅助启动.bat”是一个在需要使用VMware6时打开所有功能,不需要时关闭所有功能(包括其进程)的,帮助人民群众节省系统资源的批处理。
“VM6辅助启动.bat”生成器.hta 是“VM6辅助启动.bat”的GUI生成工具。
:新增“可以直接在文框输入路径”。
< html > < head > < title > “VM6辅助启动.bat”生成器 </ title > < ! -- Author: t0nsha < LiaoDunxia@Gmail.com > , Update@ 20080329 --> < style > body { background - color:#cccccc;font - size:16px;} </ style > < HTA:APPLICATION ID = " “VM6辅助启动.bat”生成器 " APPLICATIONNAME = " “VM6辅助启动.bat”生成器 " SCROLL = " no " SINGLEINSTANCE = " yes " WINDOWSTATE = " normal " ShowInTaskBar = " yes " MaximizeButton = " no " MinimizeButton = " no " SCROLL = " no " NAVIGABLE = " yes " BORDER = " thin " ICON = " %SystemRoot%/system32/mobsync.exe " > </ head > < SCRIPT Language = " VBScript " > window.resizeTo 640 , 480 ileft = (window.screen.width - 640 ) / 2 itop = (window.screen.height - 480 ) / 2 window.moveTo ileft,itop On Error Resume Next Dim strBat()nLines = 51 ReDim strBat(nLines)strBat( 0 ) = " @echo off " strBat( 1 ) = " color 17 " strBat( 2 ) = " title VM6辅助启动.bat " strBat( 3 ) = " rem Author: t0nsha <LiaoDunxia@Gmail.com>, Update@20080329 " strBat( 4 ) = " mode con cols=66 lines=8 " strBat( 5 ) = " :menu " strBat( 6 ) = " cls & set op= " & Chr ( 34 ) & Chr ( 34 )strBat( 7 ) = " set /p op=输入1回车启动VM,2停止,q退出此脚本(注意:使用时请先将此脚本置于VMware.exe所在的目录;停止会终止VMware.exe进程,请先保存好数据): " strBat( 8 ) = " if %op%==1 ( " strBat( 9 ) = " goto start " strBat( 10 ) = " ) else if %op%==2 ( " strBat( 11 ) = " goto stop " strBat( 12 ) = " ) else if " & Chr ( 34 ) & " %op% " & Chr ( 34 ) & " == " & Chr ( 34 ) & " q " & Chr ( 34 ) & " ( " strBat( 13 ) = " exit " strBat( 14 ) = " ) else ( " strBat( 15 ) = " goto menu " strBat( 16 ) = " ) " strBat( 17 ) = " :start " strBat( 18 ) = " set starttype=auto " strBat( 19 ) = " set startnow=Start " strBat( 20 ) = " set startVMnetAdapter=Enable " strBat( 21 ) = " goto Exec " strBat( 22 ) = " :stop " strBat( 23 ) = " set starttype=demand " strBat( 24 ) = " set startnow=Stop " strBat( 25 ) = " set startVMnetAdapter=Disable " strBat( 26 ) = " goto Exec " strBat( 27 ) = " :Exec " strBat( 28 ) = " echo (1/3) %startnow%ing services ... " strBat( 29 ) = " (sc config ufad-ws60 start= demand " strBat( 30 ) = " net stop " & "" & Chr ( 34 ) & " VMware Agent Service " & Chr ( 34 )strBat( 31 ) = " sc config VMAuthdService start= %starttype% " strBat( 32 ) = " net %startnow% " & Chr ( 34 ) & " VMware Authorization Service " & Chr ( 34 )strBat( 33 ) = " sc config VMnetDHCP start= %starttype% " strBat( 34 ) = " net %startnow% " & Chr ( 34 ) & " VMware DHCP Service " & Chr ( 34 )strBat( 35 ) = " sc config " & Chr ( 34 ) & " VMware NAT Service " & Chr ( 34 ) & " start= %starttype% " strBat( 36 ) = " net %startnow% " & Chr ( 34 ) & " VMware NAT Service " & Chr ( 34 ) strBat( 37 ) = " sc config vmount2 start= %starttype% " strBat( 38 ) = " net %startnow% " & Chr ( 34 ) & " VMware Virtual Mount Manager Extended " & Chr ( 34 ) strBat( 39 ) = " ) >nul 2>nul " strBat( 40 ) = " echo (2/3) %startVMnetAdapter%ing VMnetAdapters ... " strBat( 41 ) = " devcon %startVMnetAdapter% *VMnetAdapter* >nul 2>nul " strBat( 42 ) = " if " & Chr ( 34 ) & " %startnow% " & Chr ( 34 ) & " == " & Chr ( 34 ) & " Start " & Chr ( 34 ) & " ( " strBat( 43 ) = " echo ^(3/3^) Starting Processes ... " strBat( 44 ) = " start hqtray.exe & start vmware.exe " strBat( 45 ) = " ) else ( " strBat( 46 ) = " echo ^(3/3^) Killing Processes ... " strBat( 47 ) = " TASKKILL /F /IM hqtray.exe >nul 2>nul " strBat( 48 ) = " TASKKILL /F /FI " & Chr ( 34 ) & " IMAGENAME eq vm* " & Chr ( 34 ) & " >nul 2>nul " strBat( 49 ) = " ) " strBat( 50 ) = " echo :) DONE AND QUIT! & ping 127.1>nul " Function SplitVMPath ' Cut out "vmware.exe" from the VMPath for i = 1 to Len (T_VMPATH.value) j = right (T_VMPATH.value,i) if mid (j, 1 , 1 ) = " / " then j = mid (T_VMPATH.value, 1 , Len (T_VMPATH.value) - i + 1 ) SplitVMPath = j exit Function end if next SplitVMPath = T_VMPATH.value End Function Function IsVMwareDotExe ' Search For "vmware.exe" Set objFSO = CreateObject ( " Scripting.FileSystemObject " ) If SplitVMPath = T_VMPATH.value Then IsVMwareDotExe = False Exit Function Else Set f = objFSO.GetFolder(SplitVMPath) End If Set fc = f.Files For Each f1 in fc If " vmware.exe " = f1.name Then IsVMwareDotExe = True Exit Function End If Next IsVMwareDotExe = False End Function Function VMPathFind ' Display something depend on VMPath If T_VMPATH.value = "" Then S_VM.InnerHTML = " <center><font color=#ff0000>vmware.exe未找到!</font><center> " TA_STRBAT.value = "" VMPathFind = False ElseIf Not IsVMwareDotExe Then S_VM.InnerHTML = " <center><font color=#0000ff>想骗我? " & SplitVMPath & " 目录下哪有vmware.exe!</font><center> " TA_STRBAT.value = "" VMPathFind = False Else S_VM.InnerHTML = " <center><font color=#00ff00>vmware.exe已找到!</font><center> " temp = strBat( 0 ) For i = 1 to nLines temp = temp & vbCrLf & strBat(i) Next TA_STRBAT.value = temp VMPathFind = True End If End Function Sub GetVMPath ' Get the VMPath by browse Set objDialog = CreateObject ( " UserAccounts.CommonDialog " ) objDialog.Filter = " vmware.exe|vmware.exe " ' 设定显示的文件格式 set WshShell = CreateObject ( " WScript.Shell " ) strPrograms = WshShell.SpecialFolders( " Programs " ) objDialog.InitialDir = strPrograms & " /VMware/VMware Workstation/ " ' 设定打开时初始的目录 intResult = objDialog.Showopen ' 执行打开命令 T_VMPATH.value = objDialog.FileName ' 返回选中的文件路径 If Not VMPathFind Then Exit Sub End Sub Sub WriteToBat ' Write array of strBat to "VM6辅助启动.bat" If Not VMPathFind Then Exit Sub Set objFSO = CreateObject ( " Scripting.FileSystemObject " ) Set objFile = objFSO.CreateTextFile( " VM6辅助启动.bat " , true ) For i = 0 to nLines - 1 objFile.WriteLine(strBat(i)) Next objFile.Close Set objFSO = Nothing If C_SHORTCUT.checked Then ' set WshShell = WScript.CreateObject("WScript.Shell") ERR set WshShell = CreateObject ( " WScript.Shell " ) strDesktop = WshShell.SpecialFolders( " Desktop " ) set oShellLink = WshShell.CreateShortcut(strDesktop & " /VM6辅助启动.lnk " ) oShellLink.TargetPath = SplitVMPath & " VM6辅助启动.bat " oShellLink.WindowStyle = 1 oShellLink.Hotkey = " CTRL+SHIFT+V " oShellLink.IconLocation = T_VMPATH.value oShellLink.Description = " 欢迎访问我的博客:http://blog.csdn.net/t0nsha/ " oShellLink.WorkingDirectory = SplitVMPath oShellLink.Save End If S_VM.InnerHTML = " <center><font color=#00ff00>“VM6辅助启动.bat”已生成,谢谢使用!</font><center> " End Sub </ SCRIPT > < body OnLoad = " VMPathFind " > < h5 align = " center " > “VM6辅助启动.bat”生成器 </ h5 > 定位vmware.exe: < input type = " text " name = " T_VMPATH " size = " 52 " OnChange = " VMPathFind " > < input type = " button " value = " 浏览(B) " onclick = " GetVMPath " accesskey = B > < br /> < textarea name = " TA_STRBAT " rows = " 18 " cols = " 80 " ></ textarea > < br /> < input type = " checkbox " name = " C_SHORTCUT " value = " 1 " checked accesskey = D > 添加桌面快捷方式(D) < input type = " button " value = " 生成“VM6辅助启动.bat”(C) " onClick = " WriteToBat " accesskey = C > < input type = " button " value = " 退出(Alt+Q) " onClick = " self.close() " accesskey = Q > < span id = S_VM >< center ></ center ></ span > < p align = " center " >& copy; < a href = " http://blog.csdn.net/t0nsha/ " target = " blank " > t0nsha </ a href > </ p > </ body > </ html > 图: