Page 1 of 1 1
Topic Options
#37035 - 2003-02-27 09:34 AM Fast check if the workstation (PC) is turned on
Luziekix Offline
Getting the hang of it

Registered: 2003-02-27
Posts: 68
Hi!

With the following Script-Line I would like to disable the Internet-Connections on school-PC from the Teacher-PC:

$Err=WriteValue("\\BBS-GER701\HKEY_USERS\S-1-5-21-57989841-1202660629-1060284298-2727\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyEnable","0","REG_DWORD")

.... for each Student-PC with different PC-name and different USER-SID. This works OK an fast, if all PCs are turned on. But if some of the PCs are turned off it takes about 30 Seconds for my scripts to go on to the next PC to make the setting.

Can someone help me out and have an idea on how to FAST check if the stundent-PC is turned on, so I could only try to do this settings then.

Regards,

Luziekix

Top
#37036 - 2003-02-27 09:37 AM Re: Fast check if the workstation (PC) is turned on
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Luzie,

you might want to add a ping() in the loop [Big Grin]

Jochen
_________________________



Top
#37037 - 2003-02-27 09:38 AM Re: Fast check if the workstation (PC) is turned on
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh yeah,

Welcome to the board !
_________________________



Top
#37038 - 2003-02-27 09:45 AM Re: Fast check if the workstation (PC) is turned on
onlinrgames Offline
Fresh Scripter

Registered: 2002-07-23
Posts: 27
Hi Luziekix,

Here's what we do to check the machine status before applying any KiXtart scripts.

- Do a PING test of the machine and log the result to a text file.
- If the machine returns "Request timed out" message, consider the machine as OFF and move onto the next one.

A sample code would be :

code:
Break On
Shell "cmd.exe /c ping m/c_name -n 1 > result.txt"
If Open(3,"result.txt",2) = 0
$Readline_val = ReadLine(3)
While @error = 0
If $Readline_val = "Request timed out."
? "Machine not On. Skip to next m/c"
Del ("Result.txt")
EndIf
$Readline_val = ReadLine(3)
Loop
$ = Close(3)
Del ("Result.txt")
EndIf

Regards

Onlinegames

Top
#37039 - 2003-02-27 10:17 AM Re: Fast check if the workstation (PC) is turned on
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
condensed line from ping() If you don't like to use a user defined function :



break on

$a = "nb2jpzz1","Foo" ;replace with an array of valid machine names  [Wink]

for each $m in $a
    shell '%Comspec% /C ping $m -n 2 | find /C "TTL=" > nul'
    if not @error
        $m + " is online" ?              ; replace with your action
    else
        $m + " appears to be offline" ?
    endif
next


get $



As 'TTL=' is the only valid search pattern for online machines ...

hth
Jochen
_________________________



Top
#37040 - 2003-02-27 11:02 AM Re: Fast check if the workstation (PC) is turned on
Luziekix Offline
Getting the hang of it

Registered: 2003-02-27
Posts: 68
Well thank you all for your fast help !!!

I now use this:
(Sample in german, if someone need it in english, please request it from me!)

Break On
$PCON=1
Shell "cmd.exe /c ping BBS-GER701 -n 1 > C:\TEMP\result.txt"
If Open(3,"C:\TEMP\result.txt",2) = 0
$Readline_val = ReadLine(3)
While @error = 0
If $Readline_val = "Zeitberschreitung der Anforderung."
$PCON=0
Del ("C:\TEMP\Result.txt")
EndIf
$Readline_val = ReadLine(3)
Loop
$ = Close(3)
Del ("C:\TEMP\Result.txt")
If $PCON=0
AT (1,0) "BBS-GER701: PC ist ausgeschaltet oder nicht am Netz!"
ELSE
$Err=WriteValue("\\BBS-GER701\HKEY_USERS\S-1-5-21-57989841-1202660629-1060284298-2727\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyEnable","1","REG_DWORD")
If $Err=0
AT (1,0) "BBS-GER701: Internet EIN-geschaltet. IE dort schliessen / neu öffnen!"
ELSE
AT (1,0) "BBS-GER701: FEHLER: User nicht eingeloggt ?!"
ENDIF
Endif
EndIf

Regards;

Luzie

Top
#37041 - 2003-02-27 11:05 AM Re: Fast check if the workstation (PC) is turned on
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mm...
this checks if it's power is on...

what about checking if it is on or in dos mode/crashed?
_________________________
!

download KiXnet

Top
#37042 - 2003-02-27 11:27 AM Re: Fast check if the workstation (PC) is turned on
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Would then try and map to ipc$ ... if fails the remote isn't that reachable to edit registry [Smile]

Luzie, wenn du magst können wir das auch offline diskutieren ... mail genügt [Wink]

Jochen
_________________________



Top
#37043 - 2003-02-27 03:32 PM Re: Fast check if the workstation (PC) is turned on
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
However, trying to connect to IPC$ will also incur the 30-second-timeout-penalty. However, it would be the clean approach. Pseudo code:
code:
IF NOT PING
; try sending a Wake-On-LAN command
; PING again until computer resonds or timeout is reached
IF NOT timeout-is-reached
IF CONNECT-TO-IPC
; do whatever you need to do
ENDIF
ENDIF
ENDIF

This approach has been implemented in the server script of the KiXtart Systems Management Server.
_________________________
There are two types of vessels, submarines and targets.

Top
#37044 - 2003-02-27 03:36 PM Re: Fast check if the workstation (PC) is turned on
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yap,

all of my admin scripts to act on Remote Servers work this way ... except maybe the Wake-On-Lan command which isn't an option since it is deactivated (The Servers are supposed to Run 24/7/364.25)

[ 27. February 2003, 15:38: Message edited by: jpols ]
_________________________



Top
#37045 - 2003-02-27 03:50 PM Re: Fast check if the workstation (PC) is turned on
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Wait a second ...

If I look at your code I have to assume that it is only a single PC you control ...

[Confused] [Confused] [Confused]
_________________________



Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.072 seconds in which 0.034 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