Page 1 of 1 1
Topic Options
#62690 - 2002-02-01 09:51 PM KiXtart Systems Management Server (Part II, The Server)
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
I hope I'm not ruining anybody's weekend with this [Wink]

Jens
--------------------------------------------

This is the second part in a series of Kixtart scripts. The complete series will illustrate how to create a complete Kixtart Systems Management Server (KSMS) using only Kixtart and various freeware utilities and programs which are part of the Windows operating system. KSMS enables an administrator to perform administrative tasks in off-hours and without being present at the remote computer. It can be used to install programs, remove programs, clean up the harddisks, and modify regitry entries. It does not cook coffee though. It is compatible with both Windows NT/2000 and Windows 9x.

The first part described a modular login script for Windows 9X/NT/2K. The latest version on the modular login script can be found at http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=2&t=002682.

The second part covers the server part of the KSMS. The server part consists of one Kixtart script, two initialization files, and two function libraries. The MAINTENANCE_SERVER.KIX script calls various functions in those two UDF libraries. Nevertheless, all listed UDFs are used throughout KSMS.

The file COMPUTERS.DB is an .INI file that is created by the login script. The important entry for each computername (the name in the brackets) is the MAC address. All other entries are for informational reasons only to get a quick idea what type of computer it is. They are not necessary for KSMS. Basically, each time the login script runs it writes/updates the current MAC address associated with the specific computer. More precisely, if a user elects to integrate the computer into KSMS, it'll update the information, otherwise that computer is treated as a guest computer (e.g. laptop computer of a visiting research in my case)

The file MAINTENANCE_LIST.INI is used mainly to communicate between the login script and the maintenance client script. The maintenance server script is using the MAINTENANCE_LIST.INI file to read the type of scheduling service for a specific computer and to write logging information into the file. Thus, it is possible to track down problems with the initialization of the computer maintenance on a computer.

In order for the maintenance server script to schedule maintenance it requires either the Task Scheduler or the Scheduler service. If the Scheduler service is used, then the service must be run under an administrative account since the SYSTEM account cannot establish network connections.

The maintenance server script is scheduled to run every night (2am seems to be a good time since virtually nobody is working at this time of day). It first initializes itself, loads its UDF libraries and sets the logging options. Each screen printout is also written into a log file to trace errors and monitor the script. One does not need to be logged into the computer that is running the maintenance server script as long as it is run through the Task Scheduler and is using a global administrative account. I created special KIX_SRV and KIX_CLI accounts for the server and client part of KSMS.

The server then reads a list of computers from MAINTENANCE_LIST.INI and the associated scheduler type. It checks whether it can access the admin share on each remote computer. If it cannot access it then the computer either has no admin share (therefore the client script will not be run) or the computer is not reachable. If the computer is not reachable the server script reads the MAC address and uses MAGIC.EXE to send a MagicPacket to the remote computer. This will trigger a Wake-On-LAN request for that computer if the NIC supports it. Then the script waits a little bit and checks wheter the computer is waking up by trying to access the admin share (with a 5 minute timeout). If the computer woke up successfully (admin share accessible) the script continues otherwise the script starts again with the next computer in its list.

If the remote computer is accessible through the admin share, the CLIENT_MAINTENANCE.BAT file is copied to the remote computer. This file contains a call to the CLIENT_MAINTENANCE.KIX script which does the maintenance on the remote computer. The Kixtart script sits on a server, thus is not accessible to a normal user. Also, if a user manipulates the CLIENT_MAINTENANCE.BAT then it will be overwritten with the version on the server the next time the client maintenance is initialized. This should effectively prevent tampering.

Finally, it schedules the execution of CLIENT_MAINTENANCE.BAT on the remote computer using either the Task Scheduler or the Scheduler service. The Task Scueduler is scheduled with JT.EXE from the Microsoft Windows 2000 Resource Kit Supplement 3 which is a CLI for the Task Scheduler. See also http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=1&t=003208 and http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000060

This example of KSMS has been used for two months to manage a computer network consisting of over 80 Windows 9x, NT, and 2000 computers. As part of the systems management all computers have been upgraded to Internet Explorer 5.5 Service Pack 2, an antivirus package has been distributed and various server-based applications have been installed (Microsoft Project, Microsoft Publisher, Microsoft Visio, SPSS). Additionally, system policies have been applied through the manipulation of registry entries and programs on the remote computres have been upgraded if necessare (e.g. Adobe Acrobat from 5.0.0 to 5.0.5). It is also used to essentially push specific applications to the remote computers.

The next part in this series will contain the client part of KSMS, namely CLIENT_MAINTENANCE.KIX.

You can download a ZIP-file containing the script and initialization files here: http://people.bu.edu/jenmeyer/kixtart/maintenance_server.zip

code:
<pre>
; FUNCTIONS.UDF
;
; KixTart library functions
;
; List of included functions (36 total):
;
; OSID() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000019]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000019[/URL]
; ShellCmd() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000057]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000057[/URL]
; FullFile() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000028]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000028[/URL]
; MapDrive() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000108]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000108[/URL]
; MapPrinter() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000109]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000109[/URL]
; UpdateRegistry() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000110]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000110[/URL]
; IsIncluded() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000105]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000105[/URL]
; IsInGroup() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000097]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000097[/URL]
; IsInArray() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000098]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000098[/URL]
; ATrim() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000031]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000031[/URL]
; Warning() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000099]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000099[/URL]
; DisplayText() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000036]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000036[/URL]
; Err() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000107]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000107[/URL]
; SendAlert() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000100]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000100[/URL]
; IsArray() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000088]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000088[/URL]
; Fatal() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000101]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000101[/URL]
; CheckDatabase() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000111]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000111[/URL]
; ProcessRegINI() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000112]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000112[/URL]
; RunningTime() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000038]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000038[/URL]
; SetINIValue() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000113]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000113[/URL]
; DateMath() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000102]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000102[/URL]
; SerialDate() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000089]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000089[/URL]
; CleanTempFiles() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000103]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000103[/URL]
; IsInIPRange() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000052]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000052[/URL]
; BinaryIP() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000029]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000029[/URL]
; IsInSubnet() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000053]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000053[/URL]
; IPMask() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000054]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000054[/URL]
; RunOnce() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000055]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000055[/URL]
; IsVPNConnection() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000056]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000056[/URL]
; NightlyReboot() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000106]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000106[/URL]
; RequestInstall() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000092]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000092[/URL]
; Mod() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000093]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000093[/URL]
; TimeDiff() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000040]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000040[/URL]
; SerialTime() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000039]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000039[/URL]
; Msec2Sec() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000051]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000051[/URL]
; DiskSpace() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000094]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000094[/URL]
</pre>

code:
<pre>
; MAINTENANCE.UDF
;
; Kixtart functions for the maintenance script (21 total)
;
; List of included functions:
;
; CheckNICs() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000148]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000148[/URL]
; ServiceMode() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000138]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000138[/URL]
; ActiveService() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000139]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000139[/URL]
; UpdateFileOnReboot() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000142]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000142[/URL]
; RebootWarning() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000140]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000140[/URL]
; CheckLinks() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000143]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000143[/URL]
; UpdateFile() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000149]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000149[/URL]
; GetFileExt() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000144]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000144[/URL]
; CompareVersions() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000145]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000145[/URL]
; ArrayEnumKey() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000064]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000064[/URL]
; ArrayEnumValue() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000065]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000065[/URL]
; EnumIPInfoAll() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000146]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000146[/URL]
; DirList() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000090]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000090[/URL]
; GetFilePath() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000091]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000091[/URL]
; Join() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000095]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000095[/URL]
; CheckUpdateOnReboot() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000147]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000147[/URL]
; IsStringInFile() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000141]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000141[/URL]
; DisableAutoLogon() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000151]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000151[/URL]
; EnableAutoLogon() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000150]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000150[/URL]
; CheckNAVExpiration() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000159]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000159[/URL]
; BSort() [URL=http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000070]http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000070[/URL]
</pre>

code:
<pre>
; COMPUTERS.DB

[DESIGNLAB]
Hostname=name1.host.com
MAC Address=0123456789AB
OS Kernel=WinNT
Operating System=Windows NT 4.0 Workstation Service Pack 6 (Workstation)
IP Address 0=0.0.0.0
Network Adapter 0=3Com EtherLink 10/100 PCI For Complete PC Management NIC (3C905C-TX)

[SCRATCH]
Hostname=name1.host.com
MAC Address=0123456789AB
OS Kernel=WinNT
Operating System=Windows NT 4.0 Workstation Service Pack 6 (Workstation)
IP Address 0=0.0.0.0
Network Adapter 0=3Com Fast EtherLink XL 10/100Mb TX Ethernet NIC (3C905B-TX)
</pre>

code:
<pre>
; MAINTENANCE_LIST.INI

[DESIGNLAB]
Scheduler=Task Scheduler
Initiated=successful at 2002/02/01 02:35:44
Initialization=successful at 2002/02/01 02:35:50
Finished=successful at 2002/02/01 02:36:39
InstallVisio=1

[SCRATCH]
Scheduler=Task Scheduler
Initiated=successful at 2002/02/01 02:37:51
Initialization=successful at 2002/02/01 02:37:57
Finished=successful at 2002/02/01 02:38:51
InstallMSIExec=1
</pre>

code:
<pre>
; MAINTENANCE_SERVER.KIX
;
; Maintenance server script for all computers on the NMRC-NT LAN
;
; The server script is run under the kix_server user account on the local computer
;
; Author: Jens Meyer
; Date : 10-Jan-2002
;
; Revision : 3.0
; Revised at : 10-Jan-2002
; Platforms : Windows 9x, Windows NT 4.0, Windows 2000

; show the maintenance script window
$retcode=SETCONSOLE('SHOW')
$retcode=SETCONSOLE('FOREGROUND')
$retcode=SETOPTION('HideCursor','ON')
$retcode=SETOPTION('WrapAtEOL','ON')
$retcode=SETTITLE('Kixtart Maintenance Server - Scheduling maintenance clients...')
BREAK ON

if @INWIN=1 and @PRIV<>'ADMIN'
? 'Kixtart maintenance script requires administrative privileges'
$retcode=SETOPTION('HideCursor','OFF')
exit 1314
endif

gosub MAIN

$retcode=displaytext('Finished with maintenance server script')
$retcode=redirectoutput('')
$retcode=SETOPTION('HideCursor','OFF')
exit 0

:MAIN
; read list of computers
; check if computer is online, otherwise make note/warning
; check that the scheduler is running, otherwise make scheduler running
; schedule

; initialize global variables for the script
gosub INITIALIZE

; display general maintenance script information
gosub GENERALINFO

; read list of computers and process tasks
gosub COMPUTERS

return

;-------------------------------------
; subroutine to initialize global variables
;-------------------------------------
:INITIALIZE
global $SCRIPTNAME, $SCRIPTVERSION, $SCRIPTDIRECTORY, $SCRIPTFUNCTIONS
global $SCRIPTINI, $DBINI
global $ALERTSERVER, $LOGDIRECTORY, $ERRORLOG, $LOGGINGFILE
global $OUTPUTLINE, $OUTPUT, $SCROLLING, $VERBOSE, $LOGGING
global $HKLM, $HKDU, $HKCR

dim $retcode, $inivalue
cls

; set script information
$SCRIPTNAME='maintenance_server'
$SCRIPTVERSION='3.0'
$SCRIPTDIRECTORY='\\SENSEI\kixtart_maintenance$'
$SCRIPTFUNCTIONS=@LSERVER+'\NETLOGON\functions.udf'
$MAINTENANCEFUNCTIONS=$SCRIPTDIRECTORY+'\maintenance.udf'

; define display line the the output target (screen, file)
$OUTPUTLINE=0
$OUTPUT=''
$SCROLLING=1

; define registry key constants
$HKLM='HKEY_LOCAL_MACHINE'
$HKDU='HKEY_USERS\.Default'
$HKCR='HKEY_CLASSES_ROOT'

; set global variables to default values
$ALERTSERVER='REDPOINT'

; set initialization files
$SCRIPTINI=$SCRIPTDIRECTORY+'\ini\maintenance_list.ini'
$DBINI=$SCRIPTDIRECTORY+'\db\computers.db'

; set log files
$LOGDIRECTORY='\\SENSEI\kixtart_maintenance$'
$LOGGINGFILE='\\SENSEI\kixtart_maintenance$\log\maintenance_server.log'
$ERRORLOG=$LOGDIRECTORY+'\log\errors.log'
$VERBOSE=1
$LOGGING=1

; initialize the Kixtart functions library
if exist($SCRIPTFUNCTIONS)
call $SCRIPTFUNCTIONS
else
? 'Cannot find Kixtart functions library '+$SCRIPTFUNCTIONS
$retcode=SETOPTION('HideCursor','OFF')
exit 2
endif

; initialize the Kixtart maintenance functions library
if exist($MAINTENANCEFUNCTIONS)
call $MAINTENANCEFUNCTIONS
else
? 'Cannot find Kixtart functions library '+$MAINTENANCEFUNCTIONS
$retcode=SETOPTION('HideCursor','OFF')
exit 2
endif

if $LOGGING
; initialize the log files
$retcode=redirectoutput($LOGGINGFILE,1)
$retcode=redirectoutput($OUTPUT)
if not exist($LOGGINGFILE)
; disable logging if we cannot create the log file
$LOGGING=0
endif
endif

return

;-------------------------------------
; subroutine to display general maintenance script information
;-------------------------------------
:GENERALINFO
; display the LAN script version
$retcode=displaytext('NMRC Maintenance Script V'+$SCRIPTVERSION+' running under KixTart V'+@KIX)
; display the user information
$retcode=displaytext(' User ID : '+@USERID)
$retcode=displaytext(' Full Name : '+@FULLNAME)
$retcode=displaytext(' Privilege : '+@PRIV)
$retcode=displaytext(' Domain : '+@DOMAIN)
$retcode=displaytext(' Logon Server : '+@LSERVER)
; display additional script information
$retcode=displaytext('Maintenance INI : '+$SCRIPTINI)
$retcode=displaytext(' Functions KIX : '+$SCRIPTFUNCTIONS)
$retcode=displaytext('Maintenance KIX : '+$MAINTENANCEFUNCTIONS)
return

;-------------------------------------
; subroutine to initialize global variables
; $SCRIPTINI location of maintenance initialization file
; $SCRIPTDIRECTORY location of the maintenance scripts
;-------------------------------------
:COMPUTERS
Dim $computernames, $computer, $remoteroot, $macaddress, $waitseconds, $counter, $maxwait

if exist($SCRIPTINI)
$computernames=readprofilestring($SCRIPTINI,'','')
$computernames=split($computernames,chr(10))

for each $computer in $computernames
if $computer<>''
$remoteroot='\\'+$computer+'\admin$'
$schedulertype=readprofilestring($SCRIPTINI,$computer,'Scheduler')
if $schedulertype<>''
$retcode=displaytext(' ')
$retcode=displaytext('========== BEGIN '+UCASE($computer)+' ==========')

; execute a wake-on-LAN if computer is shut down
if not exist($remoteroot)
$macaddress=readprofilestring($DBINI,$computer,'MAC Address')
if $macaddress<>''
$retcode=displaytext('Sending a wake-on-LAN command to '+$computer)
$shellcommand=fullfile($SCRIPTDIRECTORY,'tools\magic.exe')+' 128.197.181.1 24 '+$macaddress
$retcode=shellcmd($shellcommand)
; wait a maximum of five minutes for computer to wake up and check every x seconds
$waitseconds=10
$counter=0
$maxwait=100
do
'.'
$counter=$counter+$waitseconds
sleep $waitseconds
until $counter=$maxwait or exist($remoteroot)
if $counter<$maxwait
$retcode=displaytext('Computer '+$computer+' woke up after '+$counter+' seconds')
else
$retcode=displaytext('Computer '+$computer+' did not wake up')
endif
else
$retcode=displaytext('Cannot find MAC address for computer '+$computer)
endif
else
; wait 120 seconds before starting task in order to not overload maintenance server
sleep 120
endif

if exist($remoteroot)

; copy the maintenance client batch file to the local computer
$retcode=displaytext('Copying maintenance client batch file to '+$remoteroot)
copy fullfile($SCRIPTDIRECTORY,'maintenance_client.bat') $remoteroot /h

select
case $schedulertype='Task Scheduler'
$retcode=displaytext('Scheduling maintenance client on '+$computer)
gosub TASKSCHEDULER
$retcode=writeprofilestring($SCRIPTINI,$computer,'Initiated','successful at '+@DATE+' '+@TIME)
case $schedulertype='Schedule'
$retcode=displaytext('Scheduling maintenance client on '+$computer)
GOSUB SCHEDULE
$retcode=writeprofilestring($SCRIPTINI,$computer,'Initiated','successful at '+@DATE+' '+@TIME)
case 1
$retcode=displaytext('Cannot schedule maintenance client on '+$computer+' due to incompatible scheduler service')
$retcode=writeprofilestring($SCRIPTINI,$computer,'Initiated','failed at '+@DATE+' '+@TIME+' due to incompatible scheduler service')
$retcode=warning('Computer '+$computer+' has incorrect scheduler service!')
endselect
else
$retcode=writeprofilestring($SCRIPTINI,$computer,'Initiated','failed at '+@DATE+' '+@TIME+' due to computer being offline')
$retcode=warning('Computer '+$computer+' is offline!')
endif
$retcode=displaytext('========== END '+UCASE($computer)+' ==========')
endif
endif
next
else
$retcode=err('Cannot find maintenance initialization file '+$SCRIPTINI)
endif
return

;-------------------------------------
; subroutine to schedule the client maintenance script on computers running the schedule service
;-------------------------------------
:SCHEDULE
Dim $schedulercmd

$retcode=displaytext('Scheduling maintenance client batch file on '+$computer+' using scheduler service')

$schedulercmd = fullfile($SCRIPTDIRECTORY,'tools\soon.exe')
$schedulercmd = $schedulercmd + ' \\'+$computer+' 60'
$schedulercmd = $schedulercmd + ' "%COMSPEC% /e:1024 /c'
$schedulercmd = $schedulercmd + ' maintenance_client.bat"'
$retcode=shellcmd($schedulercmd)
return

;-------------------------------------
; subroutine to schedule the client maintenance script on computers running the task scheduler service
;-------------------------------------
:TASKSCHEDULER
Dim $schedulercmd, $retcode
$retcode=displaytext('Scheduling maintenance client batch file on '+$computer+' using task scheduler service')

; delete a potentially existing task
$schedulercmd = fullfile($SCRIPTDIRECTORY,'tools\jt.exe')
$schedulercmd = $schedulercmd + ' /SM \\'+$computer+' /SD maintenance_client.job'
$retcode=shellcmd($schedulercmd)

; create a new task, save it, and force a run
$schedulercmd = fullfile($SCRIPTDIRECTORY,'tools\jt.exe')
$schedulercmd = $schedulercmd + ' /CTJ StartDate=TODAY'
$schedulercmd = $schedulercmd + ' StartTime=NOW'
$schedulercmd = $schedulercmd + ' HasEndDate=0'
$schedulercmd = $schedulercmd + ' KillAtDuration=0'
$schedulercmd = $schedulercmd + ' Disabled=0'
$schedulercmd = $schedulercmd + ' Type=ONCE'
$schedulercmd = $schedulercmd + ' /SC NMRC-NT\kix_cli kixtartclient'
$schedulercmd = $schedulercmd + ' /SJ ApplicationName="maintenance_client.bat"'
$schedulercmd = $schedulercmd + ' Parameters=""'
$schedulercmd = $schedulercmd + ' WorkingDirectory="%SYSTEMROOT%"'
$schedulercmd = $schedulercmd + ' Comment="Kixtart Maintenance Client Script"'
$schedulercmd = $schedulercmd + ' Creator="Kixtart Maintenance Server"'
$schedulercmd = $schedulercmd + ' Priority=Normal'
$schedulercmd = $schedulercmd + ' MaxRunTime=3600000'
$schedulercmd = $schedulercmd + ' DontStartIfOnBatteries=0'
$schedulercmd = $schedulercmd + ' KillIfGoingOnBatteries=0'
$schedulercmd = $schedulercmd + ' RunOnlyIfLoggedOn=0'
$schedulercmd = $schedulercmd + ' SystemRequired=0'
$schedulercmd = $schedulercmd + ' DeleteWhenDone=1'
$schedulercmd = $schedulercmd + ' Suspend=0'
$schedulercmd = $schedulercmd + ' StartOnlyIfIdle=0'
$schedulercmd = $schedulercmd + ' KillOnIdleEnd=0'
$schedulercmd = $schedulercmd + ' RestartOnIdleResume=0'
$schedulercmd = $schedulercmd + ' Hidden=0'
$schedulercmd = $schedulercmd + ' TaskFlags=0'
$schedulercmd = $schedulercmd + ' /SM \\'+$computer
$schedulercmd = $schedulercmd + ' /SAJ maintenance_client.job'
$schedulercmd = $schedulercmd + ' /SAC maintenance_client.job'
$schedulercmd = $schedulercmd + ' /RJ'

$retcode=shellcmd($schedulercmd)

return
</pre>



[ 29 July 2002, 18:39: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#62691 - 2002-02-01 11:23 PM Re: KiXtart Systems Management Server (Part II, The Server)
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France

Seems interesting, but you won't ruin my WE, as something else will do the job
_________________________
? getobject(Kixtart.org.Signature)

Top
#62692 - 2002-02-04 01:12 PM Re: KiXtart Systems Management Server (Part II, The Server)
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
Looks good from here. Just downloaded the zip file to take a closer look!
_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#62693 - 2002-07-24 12:22 AM Re: KiXtart Systems Management Server (Part II, The Server)
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Jens,

what's the URL for the client-scripts-download???

(wanting to get rid of MickeySoft SMS and deploying KiXtart SMS... [Big Grin] )
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#62694 - 2002-07-24 06:35 PM Re: KiXtart Systems Management Server (Part II, The Server)
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Still working on some documentation for it. I'm also in the process of converting it all to KiXtart 4.11 and adding more functionality, especially WMI stuff, and working on the Inventory Database system, and the Print Auditing HTML output.

Hope to post the client script by the end of the week.
_________________________
There are two types of vessels, submarines and targets.

Top
#62695 - 2002-07-24 11:21 PM Re: KiXtart Systems Management Server (Part II, The Server)
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
I'm looking forward to it...
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#62696 - 2002-10-15 12:09 AM Re: KiXtart Systems Management Server (Part II, The Server)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uuh...

jens, can we have package of this.
it's pretty exchaustive to read the text and still not know how to actually go with this.
_________________________
!

download KiXnet

Top
#62697 - 2002-10-14 04:28 PM Re: KiXtart Systems Management Server (Part II, The Server)
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Lonkero: In case you missed the thread, please take a look at KiXtart Systems Management Server (Part III, The Client) [a.k.a The Complete Package]. Please note the last word in the title [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#62698 - 2002-10-14 04:42 PM Re: KiXtart Systems Management Server (Part II, The Server)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh, didn't miss that thread but missed that word!
thanks.
_________________________
!

download KiXnet

Top
#62699 - 2002-10-14 05:17 PM Re: KiXtart Systems Management Server (Part II, The Server)
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Oh, any ideas for improvements?
_________________________
There are two types of vessels, submarines and targets.

Top
#62700 - 2002-10-14 05:29 PM Re: KiXtart Systems Management Server (Part II, The Server)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ee...
forms 2.1 interface with some fancy stuff...
_________________________
!

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 (mole) and 598 anonymous users online.
Newest Members
Raoul, Timothy, Jojo67, MaikSimon, kvn317
17875 Registered Users

Generated in 0.064 seconds in which 0.025 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