谢谢分享 |
谢谢分享 |
进来学习 |
学习学习 |
学习学习 |
nttwqz 发表于 2023-11-22 17:37 百度 VBS代码在线格式化美化工具 就搞定了,bat太费劲了 |
观摩学习 |
szwp 发表于 2023-11-23 10:39 是的,当是随便从论坛扒了一个代码复制出来 |
折腾啥。 windows 处理空行和换行都麻烦。 正则 "^ " 替换成 "" 不就行了。 |
观摩学习,感谢各位大佬解题! 我其实也有个想要的功能,就是删除所有空行(非空格),一直没研究成功。 |
进来学习 |
nfans 发表于 2023-11-22 17:31 你原文本就多空格 |
感谢各位朋友热心帮助测试,综合使用9、17、18楼代码仍有明显bug,有条件请用 Beyond Compare 比对测试。 |
楼上已有最佳答案
|
你代码的第三行,改成
|
高手如云 |
学习学习 |
newyun 发表于 2023-11-22 15:42 先用findstr /n给原文件加行号,再去掉,就能留空行了。 在9楼基础上改改试试。 |
nfans 发表于 2023-11-22 15:39 Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}\\.\root\cimv2") Set colItems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem") For Each objItem in colItems OSA = objItem.OSArchitecture Next Const HKLM = &H80000002 Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}StdRegProv") If OSA = "64-bit" Then oReg.GetStringValue HKLM,"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\XReplace","UninstallString",UninstallString If Not IsNull(UninstallString) Then InstallLocation = Replace(UninstallString,"uninstall","XReplace") Else oReg.GetStringValue HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\XReplace","UninstallString",UninstallString If Not IsNull(UninstallString) Then InstallLocation = Replace(UninstallString,"uninstall","XReplace") End If Set WshShell = WScript.CreateObject("WScript.Shell") If IsNull(InstallLocation) Then WshShell.Popup "杞欢鏈畨瑁咃紒", 5, "閿欒", 0 WScript.Quit End If Name = Array("XReplace.exe") Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Debug)}\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process") For Each objProcess In colProcessList For Each Process In Name If LCase(objProcess.Name) = LCase(Process) Then objProcess.Terminate() End If Next Next Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists(InstallLocation) Then Set ado_stream = CreateObject("ADODB.Stream") ado_stream.Type = 1 ado_stream.open ado_stream.LoadFromFile InstallLocation ado_stream.position = 215133 ado_stream.Write HexToByte("E9B701000090") ado_stream.position = 256771 ado_stream.Write HexToByte("E9CE02000090") ado_stream.position = 277094 ado_stream.Write HexToByte("01") ado_stream.position = 313599 ado_stream.Write HexToByte("B80100") ado_stream.position = 313855 ado_stream.Write HexToByte("B80100") ado_stream.position = 314442 ado_stream.Write HexToByte("B80100") ado_stream.position = 314901 ado_stream.Write HexToByte("B80100") ado_stream.SaveToFile InstallLocation, 2 ado_stream.Close Set ado_stream = Nothing End If WshShell.Popup "瓒呯骇瀛楃涓叉壒閲忔浛鎹㈠伐鍏?v4.2.5 鐮磋В琛ヤ竵" & vbnewline & vbnewline & "鍒朵綔锛欳hiShingChan 缂栫▼璇█锛歏BScript",10,"瀹屾垚",0 Function HexToByte(hexStr) Set xmldom = Wscript.CreateObject("Microsoft.XMLDOM") Set byteObj= xmldom.createElement("byteObj") byteObj.dataType = "bin.hex" byteObj.nodeTypedValue = hexStr HexToByte=byteObj.nodeTypedValue End Function 这是 测试过来的结果,会把空行也处理掉,我想不出更好的办法了。我没转成ANSI所以中文乱码了。你注意下就行了 |
newyun 发表于 2023-11-22 15:28 是删所有行行首,并保留空格,请注意审题,所以结果还不正确 空格与空行别弄混了 |
nfans 发表于 2023-11-22 15:32 这个功能需要flash |
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.