Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

[RESOLVED] VBS To check if registry key exists if so delete if not then move on

$
0
0
Hi all,

Ive been tearing my hair out trying to work this one out. I had it working (if the key exists) its when the key doesnt exist its a problem. Im trying to delete the proxy server registry key as per

Code:

Option Explicit

Dim WSHNetwork, DomainString, UserString, UserObj, GroupObj, wshShell, regValue, regKey

Set wshShell = WScript.CreateObject("Wscript.Shell")

wshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD"

regKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"

If IsNull(regKey) then
        End IF
Else
        wsShell.RegDelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"
End sub

Set WSHNetwork = CreateObject("WScript.Network")
DomainString = WSHNetwork.UserDomain
UserString = WSHNetwork.UserName
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

My code then goes on to check group membership and map drives. But I cant seem to get the first section to check if the reg key exists then go onto the next task.

Am I being a muppet? Thanks :)

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>