Page 1 of 1 1
Topic Options
#40751 - 2003-05-28 12:09 AM To UDF or not to UDF..... A shutdown
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Hi People

Im in a slight dilemma at the mo with a problem that has been passed to me. I have been asked to reboot all of a departments Pcs every night due to a memory issue and im trying to work out what is the best way to go about it. I have seen a couple of UDF's on adding a scheduled task but they seem a little long winded for what is needed. I have also thought about having a bat file on the clients that executes every night but I am worried that if new Pc's get added to the dept that they will be missed of the routine restart.
All the clients are running the beloved NT and are using KIX32 3.47.0.0. Has anyone had suggestions or comments ?
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#40752 - 2003-05-28 12:14 AM Re: To UDF or not to UDF..... A shutdown
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
No udf as already intrinsic :

quote:
Shutdown( )

Action: Allows you to shut down or reboot a computer.

Syntax: SHUTDOWN ("computer", "message", wait, force, reboot)

Parameters: Computer
The name of the computer you want to shut down or reboot. An empty string("") indicates the local computer.

Message

String that specifies a message to display in the Shutdown dialog box.

Wait (optional)

Optional parameter specifying the time in seconds that the dialog box is displayed. While the dialog box is displayed, system shutdown can be stopped by using the Win32 AbortSystemShutdown function.

If wait is not zero, SHUTDOWN displays a dialog box on the specified computer. The dialog box, which displays the name of the user who called the function and the message specified by message, prompts the user to log off. The system beeps when the dialog box is created.

The dialog box remains on top of other windows and can be moved but not closed. A timer counts down the time remaining before a forced shutdown. If the user logs off, the system shuts down immediately. Otherwise, the computer is shut down when the timer expires.

If wait is zero, the computer shuts down without displaying the dialog box, and the shutdown cannot be stopped by AbortSystemShutdown.

Force

Specifies whether applications with unsaved changes are forcibly closed. If force is not zero, applications are closed. If force is zero, a dialog box is displayed prompting the user to close the applications.

Reboot (optional)

Optional parameter specifying whether the computer is to restart immediately after shutting down. If reboot is 1, the computer restarts. If reboot is 0, the computer does not start.

Remarks: SHUTDOWN does not work reliably on Windows 9x due to an issue in the underlying Windows API. As a workaround, try the following command sequence:
SHELL "%windir%\RUNDLL32.EXE user.exe,ExitWindowsExec"
SHELL "%windir%\RUNDLL32.EXE user.exe,ExitWindows"


Returns: 0 Shutdown successful
Error code Function failed


See Also: Logoff( )

Example: $RC = Shutdown("", "System is being rebooted to enable new settings.", 60, 0, 1)


--------------------------------------------------------------------------------

_________________________



Top
#40753 - 2003-05-28 12:16 AM Re: To UDF or not to UDF..... A shutdown
Jochen Administrator Offline
KiX Supporter
*****

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

Update the KiX version on Server and schedule a script running from there !
_________________________



Top
#40754 - 2003-05-28 12:22 AM Re: To UDF or not to UDF..... A shutdown
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Hi Jochen

Thanks for your reply. I have read about shutdown but I wanted to know peoples opions on how they would go about shutdowns and scheduled tasks etc, I saw a UDF that sea leopard had written about scheduling tasks and viewing tasks etc but this seemed a little long for what I wanted. I have decided to do something with kix calling a list of pcs in that dept (which I may also do something with it being updated each time a new Pc gets added and gets missed of the list) and does the reboot that way....
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#40755 - 2003-05-27 01:45 PM Re: To UDF or not to UDF..... A shutdown
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
if you really want to go with scheduling, you can use that udf or write your own but if you want to know the currently scheduled tasks on clients, it's going to be tricky.

thus the available UDFs are rather complex.

but, jochen came up with good way.
schedule your server to do the job.
_________________________
!

download KiXnet

Top
#40756 - 2003-05-27 02:25 PM Re: To UDF or not to UDF..... A shutdown
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Ive just finished setting up a basic script to shutdown the depts Pc's but for some reason the shutdown isnt returning an error code :

code:
Shutdown ("$computer","Tuff Its Shuting Down",60, 1, 1)
If @ERROR = 0
WriteLine(2, "Shutdown did execute on $computer"=Chr(13)+Chr(10))
Else
WriteLine(2, "# @serror, Shutdown did not execute on $computer"=Chr(13)+Chr(10))

Anyone ideas where im going wrong ?
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#40757 - 2003-05-27 02:29 PM Re: To UDF or not to UDF..... A shutdown
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Ive just finished setting up a basic script to shutdown the depts Pc's but for some reason the shutdown isnt returning an error code :

code:
Shutdown ("$computer","Tuff Its Shuting Down",60, 1, 1)
If @ERROR = 0
WriteLine(2, "Shutdown did execute on $computer"=Chr(13)+Chr(10))
Else
WriteLine(2, "# @serror, Shutdown did not execute on $computer"=Chr(13)+Chr(10))

Anyone ideas where im going wrong ?
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#40758 - 2003-05-27 02:32 PM Re: To UDF or not to UDF..... A shutdown
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Sorry guys just worked it out...

I hadnt put the + in after Writeline ----

DOH !!!!!
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#40759 - 2003-05-27 02:49 PM Re: To UDF or not to UDF..... A shutdown
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
code:
if Shutdown ("$computer","Tuff Its Shuting Down",60, 1, 1)
$nul=WriteLine(2, "# @serror, Shutdown did not execute on $computer"+Chr(13)+Chr(10))
Else
$nul=WriteLine(2, "Shutdown did execute on $computer"+Chr(13)+Chr(10))
endif

should work too.

[ 27. May 2003, 14:50: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#40760 - 2003-05-27 02:49 PM Re: To UDF or not to UDF..... A shutdown
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
You should be careful about having too many commands after your Shutdown() command. You'll generate errors as KiX is still running while the system is shutting down.
Top
#40761 - 2003-05-27 02:51 PM Re: To UDF or not to UDF..... A shutdown
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
chris, he has no problem if he takes our advice and shuts down the computers remotely.
_________________________
!

download KiXnet

Top
#40762 - 2003-05-27 02:53 PM Re: To UDF or not to UDF..... A shutdown
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Good point. [Wink] [Big Grin]
Top
#40763 - 2003-05-27 03:23 PM Re: To UDF or not to UDF..... A shutdown
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
I would be a complete fool if I didnt take your advice [Wink] But yes it is running off a server now and like I said before it's running like a dream !!!
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#40764 - 2003-05-27 08:51 PM Re: To UDF or not to UDF..... A shutdown
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
How about
code:
$comps=COMNetView()
for each $comp in $comps
if $comp<>@WKSTA
$rc=shutdown($comp,'',0,1,1)
endif
next
$rc=shutdown(@WKSTA,'',0,1,1)

and run this on a server under administrative rights, e.g. as a scheudled task.
_________________________
There are two types of vessels, submarines and targets.

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 661 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.092 seconds in which 0.053 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