Service 如何在VBScript中的字符串部分周围添加引号,该脚本编辑注册表服务以包含文件路径周围的引号
此代码输出以下字符串: ImagePath(REG_EXPAND_SZ)=“C:\Windows\system32\svchost.exe-k netsvcs-p ImagePath(REG_EXPAND_SZ)=“C:\Windows\system32\svchost.exe-k netsvcs-p ImagePath(REG_EXPAND_SZ)=“\SystemRoot\System32\drivers\xboxgip.sys 如何在字符串具有提供此输出的.exe或.sys的位置向每个字符串添加另一个引号 ImagePath(REG_EXPAND_SZ)=“C:\Windows\system32\svchost.exe”-k netsvcs-p ImagePath(REG_EXPAND_SZ)=“C:\Windows\system32\svchost.exe”-k netsvcs-p ImagePath(REG_EXPAND_SZ)=“\SystemRoot\System32\drivers\xboxgip.sys”Service 如何在VBScript中的字符串部分周围添加引号,该脚本编辑注册表服务以包含文件路径周围的引号,service,vbscript,registry,Service,Vbscript,Registry,此代码输出以下字符串: ImagePath(REG_EXPAND_SZ)=“C:\Windows\system32\svchost.exe-k netsvcs-p ImagePath(REG_EXPAND_SZ)=“C:\Windows\system32\svchost.exe-k netsvcs-p ImagePath(REG_EXPAND_SZ)=“\SystemRoot\System32\drivers\xboxgip.sys 如何在字符串具有提供此输出的.exe或.sys的位置向每个字符
此代码用于修复Windows安全漏洞。如果您只是尝试在文件扩展名后添加另一个引号,请尝试以下操作:
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_EXPAND_SZ = 2
strComputer = "." ' Use . for current machine
hDefKey = HKEY_LOCAL_MACHINE
strKeyPath = "SYSTEM\CurrentControlSet\Services"
On Error Resume Next
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
oReg.EnumKey hDefKey, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
strSubKeyPath = strKeyPath & "\" & strSubkey
oReg.EnumValues hDefKey, strSubKeyPath, arrValueNames, arrTypes
For i = LBound(arrValueNames) To UBound(arrValueNames)
strValueName = arrValueNames(i)
Select Case arrTypes(i)
Case REG_EXPAND_SZ
oReg.GetStringValue hDefKey, strSubKeyPath, strValueName, strValue
If InStr(1, strValue, Chr(34), 1) = 0 Then
strValueTemp = Chr(34) & strValue
wscript.echo " " & strValueName & " (REG_EXPAND_SZ) = " & strValueTemp
End IF
End Select
Next
Next
请注意,Chr(34)对应一个双引号。将要替换的文本保留为“.exe”并加上空格也很重要,因为空格意味着字符串中已缺少引号。的可能重复项
strValueTemp = replace(strValueTemp,".exe ",".exe" & Chr(34) & " ")
strValueTemp = replace(strValueTemp,".sys ",".sys" & Chr(34) & " ")