Page 1 of 1 1
Topic Options
#113431 - 2004-02-05 04:02 PM Remote Reg Update
Ghost Offline
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
#113432 - 2004-02-05 04:13 PM Re: Remote Reg Update
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Code:
$ikey="\\$dest\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"



Read my FAQ on the registry. HKCU is smoke and mirrors... cannot be accessed remotely.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#113433 - 2004-02-05 04:15 PM Re: Remote Reg Update
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
you hace to write to the hku\<sid> of the remote user
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#113434 - 2004-02-05 04:17 PM Re: Remote Reg Update
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
If this is a training lab, you could set proxy per-machine instead of per-user and then write to HKLM.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#113435 - 2004-02-05 04:28 PM Re: Remote Reg Update
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
D'oh!

Back to the drawing board.

Cheers...

_________________________
Who are you? Who slips into my robot body and whispers to my ghost?

Top
#113436 - 2004-02-06 05:03 AM Re: Remote Reg Update
jpeachman Offline
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
#113437 - 2004-02-06 06:28 AM Re: Remote Reg Update
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, you don't have firewall?
simple setting in firewall that allows only outgoing port 80 on the proxy server forces users to stop using web directly.
_________________________
!

download KiXnet

Top
#113438 - 2004-02-06 09:48 AM Re: Remote Reg Update
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
I wanted to allow the teachers at the school to turn off the internet in a room, instead of turning the internet off for everyone. Some times when the teachers wants to talk with the group, the request for the internet to be turned off will stop the pupils messing about and will listen better.

This must be possible, I can set the HKCU on a remote machine to whatever I want it to be, but it doesn't take affect. I've got all the registry settings to do with IE and Proxys from Winguides ( Here).

There must be some way of doing this.

(goes off mumbling to self)

_________________________
Who are you? Who slips into my robot body and whispers to my ghost?

Top
#113439 - 2004-02-06 10:13 AM Re: Remote Reg Update
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
In my day if you didn't pay attention you got a blackboard eraser thrown at you...

Wouldn't it be easier to change the settings on your proxy/firewall so that the machines are denied?

Even easier, remote kill any active IE processes. Do that in a loop that runs every 60 seconds and the pupils will soon get bored with restarting IE.

As an added bonus, the teacher can get a list of all the machines that it is running on so that persistant offenders can be more accurately targetted with the eraser.

Top
#113440 - 2004-02-06 01:15 PM Re: Remote Reg Update
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
Mmmm, a script that will launch a board rubber?

Now there's an idea...



_________________________
Who are you? Who slips into my robot body and whispers to my ghost?

Top
#113441 - 2004-02-06 02:51 PM Re: Remote Reg Update
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

There must be some way of doing this



There is! you can either hit every SID in HKU or get the SID with one of the UDFs. Didn't you read my FAQ?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#113442 - 2004-02-06 03:14 PM Re: Remote Reg Update
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I wonder.
in my previous school they had a switch the teacher touched when he didn't want us to play around.
disconnecting the uplink cable is the easiest way and not every student can workaround that.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1172 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.073 seconds in which 0.036 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org