#113431 - 2004-02-05 04:02 PM
Remote Reg Update
|
Ghost
Starting to like KiXtart
Registered: 2000-09-14
Posts: 171
|
Hi Chaps...
I've been trying to put together a script that will turn off the internet on computers in a class room. I've got the registry keys for the current user etc... but it doesn't want to work.
Would one of you kind chaps have a look at my code, as I am now scratching my head.
Here we go...
:)
[code] Function disableinternet($dest) shell '%comspec% /c ping -n 1 $dest | find "Reply" >nul' if @error = 0 ? "Host $dest is alive"
$ikey="\\$dest\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" IF (ExistKey($ikey) = 0)
$proxy = ReadValue($ikey, "ProxyServer") ? $proxy
IF (len(ReadValue($ikey,"ProxyServer")) <> 0) IF (WriteValue($ikey, "ProxyServer", "10.0.0.1:5555", "REG_SZ") <> 0) ? "Warning "+@error+": "+@serror ELSE ? "Update: Proxy Server set to 10.0.0.1:5555" ENDIF ELSE ? "Warning "+@error+": "+@serror ENDIF ENDIF IF (ExistKey($ikey) = 0) IF (len(ReadValue($ikey,"ProxyEnable")) <> 0) IF (WriteValue($ikey, "ProxyEnable", "1", "REG_BINARY") <> 0) ? "Warning "+@error+": "+@serror ELSE ? "Update: Proxy is Enabled" ENDIF ELSE ? "Warning "+@error+": "+@serror ENDIF ENDIF
else ? "Host $dest is dead or just wants to be alone right now!" endif EndFunction
[/code]
_________________________
Who are you? Who slips into my robot body and whispers to my ghost?
|
|
Top
|
|
|
|
#113433 - 2004-02-05 04:15 PM
Re: Remote Reg Update
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
you hace to write to the hku\<sid> of the remote user
|
|
Top
|
|
|
|
#113436 - 2004-02-06 05:03 AM
Re: Remote Reg Update
|
jpeachman
Fresh Scripter
Registered: 2002-11-18
Posts: 39
|
What's the context for doing this? If you're trying to control internet access on a per-user basis, you can write to HKCU during the login process as a part of your login script (but there are extra hoops you'll have to jump through if your clients are running Win9x). If you want to be able to remotely turn off access while users are already logged in, you may be disappointed, as I believe once a browser is launched, the proxy settings are read once and not re-checked for the duration of the browser session. And, of course, if you want to be able to do it while nobody is logged in, there isn't an HKCU hive anyway!
You can also control proxy settings through Group Policies, but again, don't expect a change to affect users who are already browsing at the time the change is made. Les is correct that you can remotely write the HKLM proxy settings if you set proxy per-machine instead of per-user, but it still won't affect users already browsing when you want to "throw the switch."
I don't know of a reliable way to do this for users who are logged in, so if it could work for you, doing it through a login script or GPO might be your best bet.
Joe
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1172 anonymous users online.
|
|
|