|
|
本帖最后由 窄口牛 于 2026-6-7 20:44 编辑
Option Explicit
Dim objFSO, objFile, strFilePath
Dim strContent, strNewContent
Function BrowseForFileByHtaInput()
Dim wShell, oExec
Set wShell = CreateObject("WScript.Shell")
Set oExec = wShell.Exec("mshta.exe ""about:<input type=file id=f>" & _
"<script>moveTo(0,-9999);resizeTo(0,0);f.click();" & _
"new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1)." & _
"WriteLine(f.value);close();</script>""")
BrowseForFileByHtaInput = oExec.StdOut.ReadLine
End Function
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFilePath = BrowseForFileByHtaInput()
If strFilePath = "" Then
WScript.Echo "未选择文件,脚本退出。"
WScript.Quit
End If
If Not objFSO.FileExists(strFilePath) Then
WScript.Echo "文件不存在: " & strFilePath
WScript.Quit
End If
If LCase(objFSO.GetExtensionName(strFilePath)) <> "vmx" Then
WScript.Echo "选择的文件不是.vmx文件,请重新选择。"
WScript.Quit
End If
Set objFile = objFSO.OpenTextFile(strFilePath, 1) ' ForReading
strContent = objFile.ReadAll
objFile.Close
strNewContent = Replace(strContent, "vmci0.present = ""TRUE""", "vmci0.present = ""FALSE""", 1, -1, vbTextCompare)
If strNewContent = strContent Then
WScript.Echo "未在文件中找到 'vmci0.present = " & Chr(34) & "TRUE" & Chr(34) & "' 这一行,未作任何修改。"
Else
Set objFile = objFSO.OpenTextFile(strFilePath, 2) ' ForWriting
objFile.Write strNewContent
objFile.Close
WScript.Echo "修改成功!已将 '" & strFilePath & "' 中的 vmci0.present = " & Chr(34) & "TRUE" & Chr(34) & " 改为 " & Chr(34) & "FALSE" & Chr(34) & "。"
End If
Set objFile = Nothing
Set objFSO = Nothing
修改vmci0.present参数.rar
(885 Bytes, 下载次数: 3)
运行vbs,选择要修改的文件即可。
|
|