Творчески переработано
Взято в https://social.technet.microsoft.com/Forums/ru-RU/53702db7-e6f2-401e-b793-05c09936a91d/10551086108010891082-10741077109010821080?forum=scrlangru
Запуск от имени админа в командной строке
cscript имя_файла.vbs
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
set oWsh = createobject("wscript.shell")
dim i
i = 1
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\" _
& strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
if isArray(arrSubKeys) then
sMatch = "MTS-RUS "
For Each subkey In arrSubKeys
on error resume next
net_del.vbs
1.3 KB
sDisplayName = oWsh.Regread("HKLM\" & strKeyPath & "\" & subkey & "\ProfileName")
if err.number = 0 then
on error goto 0
if instr(sDisplayName, sMatch) > 0 then
On Error Resume Next
If Err.Number = 0 Then
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey, arrValueNames, arrValueTypes
' For i2 = 0 To UBound(arrValueNames)
' msgbox "Value Name: " & arrValueNames(i2)
' Next
if isArray(arrValueNames) then
For Each subkeyParam In arrValueNames
oWsh.RegDelete "HKLM\" & strKeyPath & "\" & subkey & "\" & subkeyParam
Next
Else
msgbox "arrValueNames is not array"
End If
i = i + 1
oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey
End If
On Error GoTo 0
end if
end if
Next
else
msgbox "arrSubKeys isnt array: " & arrSubKeys
end if 'isArray
on error goto 0