Hope you can help. I am trying to create a script that will tell me if a registry entry changes (ie the proxy server on the PC) changes. Everything I need the script to do is working fine...but the problem is if the registry entry is completed deleted (or if some characters are removed from the proxy server to make it incorrect)...the script does not recognize the change.
The proxy server entry in registry is: http://tws-testproxy-shantodomain.org:8000
If for instance the port number chances to: http://tws-testproxy-shantodomain.org:8999
The popup comes up fine signifying the change. However if some characters are removed: http://tws-testproxy-shantodomain.org:80
The script does register that the registry entry as changed. Completely removing this reg key also does not register anything. Would anyone have any ideas? Here is the script below - many thanks for any assistance you can provide...
Code: Select all
start:
sleep, 1000
;This reads the DATA value (proxy URL) in the registry under Name "AutoConfigUrl" and stores it in variable REG1
RegRead, reg1, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\internet settings, AutoConfigURL
;This is saying that variable PROXY refers to string: http://tws-testproxy-shantodomain.org:8000
proxy=http://tws-testproxy-shantodomain.org:8000
IfInString, proxy, %reg1% ;so if the PROXY variable contains same text as REG1 variable (if proxy reg key equals http://tws-testproxy-shantodomain.org:8000) then continue the script that checks the registry by going back to label START:
goto, start
; If suddenly the registry proxy server changes and thus REG1 key is different to PROXY...then msgbox should come up saying "Its Changed" and the change is recorded in txt file regrecord.txt
Else
;FormatTime = built command to get the DateTime - store it into variable %TimeString%
FormatTime, TimeString
FileAppend, `n
(
At %TimeString%, the registry key %proxy% was changed to %reg1%
), c:\temp\regrecord.txt
MsgBox, 3, , Yes to continue checking. No to open Notepad. Cancel to close script
IfMsgBox, Yes
goto, start
IfMsgBox, No
goto, notepad
IfMsgBox, Cancel
exit
notepad:
run, c:\temp\regrecord.txt
goto, start