Page 1 of 1 1
Topic Options
#13331 - 2001-10-18 03:46 PM Logon script using KixPop to display results/Message of the day
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
Here goes chaps, I've asked some strange questions in the past and I've allways got an answer quick as a flash.

Well now it's my turn to contribute. I've been working on this script for a couple of weeks, and I've posted it for you.

It uses the KixPop app, (cheers Shawn) to display the results of the script and a message of the day. The messages are read from a messages.ini file which lives in the netlogon folder.

Any suggestions/comments would be really appreciated.

:)

The logon script - Pretty sloppy, but it works quickly.

code:

;*********************************;
; Curriculum Network Logon Script ;
;*********************************;

;************************************************************
;** Globals
;**
If SetConsole ("MINIMIZE") = 0
? "Console shrunk......"
Endif

$TRUE = 1
$FALSE = 0

;**********************************************************
; These are the settings for the KixPop 1.1 program

DIM $greeting

$drive1 = " "
$connect1 = " "
$drive2 = " "
$connect2 = " "
$drive3 = " "
$connect3 = " "
$drive4 = " "
$connect4 = " "
$drive5 = " "
$connect5 = " "
$drive6 = " "
$connect6 = " "
$drive7 = " "
$connect7 = " "

$favourites = "Your Internet Favourites"
$favConnect = "OK"

; Turn break on
Break Off

; Start of Script
:MAIN

; Set output to ASCII
Dim $PreviousASCIIState
$PreviousASCIIState = SetASCII ("ON")
Color W+/N

;Set the local time to the same as the server
SETTIME @LSERVER

; Clear the screen
Cls

; Display greeting to user

IF ((@time > "00:00:00") AND (@time < "12:00:00"))
$greeting = "Good Morning @FULLNAME"
ELSE
IF ((@time >= "12:00:00") AND (@time < "18:00:00"))
$greeting = "Good Afternoon @FULLNAME"
ELSE
$greeting = "Good Evening @FULLNAME"
ENDIF
ENDIF

; Progress meter init
$Progress = 0
$TotalProgress = 37 ; 36 is a 'full' bar
$Found = 0
$YearCount = 1992

; REM Setup the shared read only work area
$drive1 = "Files Drive"
use f: "\\gandalf\files"
$connect1 = "OK"

$drive2 = "Shared Access Drive"
use h: "\\gandalf\WorkShare$"
$connect2 = "OK"


; REM Setup the Lower 6th form work area
if ingroup("L6") = 1
$drive3 = "6th Form Drive"
use y: "\\gandalf\L6$"
$connect3 = "OK"
$drive4 = "6th Form Drive"
use u: "\\gandalf\ucas$"
$connect4 = "OK"
endif

; REM Setup the Upper 6th form work area
if ingroup("U6") = 1
$drive3 = "6th Form Drive"
use y: "\\gandalf\U6$"
$connect3 = "OK"
$drive4 = "6th Form Drive"
use u: "\\gandalf\ucas$"
$connect4 = "OK"
endif

; REM Setup the Electronics work area
if ingroup("electronics") = 1
$drive6 = "Electronics Drive"
use r: "\\gandalf\electronics$"
$connect6 = "OK"
endif

; REM Setup the History Internet work area
if ingroup("history") = 1
$drive5 = "History Drive"
use x: "\\gandalf\history$"
$connect5 = "OK"
endif

; REM Setup the staff work areas
if ingroup("staff") = 1
$drive3 = "Staff Home Drive"
use y: "\\gandalf\staff$"
$connect3 = "OK"
$drive4 = "Students Drives"
use t: "\\gandalf\users$"
$connect4 = "OK"
endif

; REM Setup the Drivers form work area
if ingroup("drivers") = 1
$drive7 = "Drivers Resource Area"
use g: "\\gandalf\drivers$"
$connect7 = "OK"
$drive3 = "Home Drive for @fullname"
use y: "\\gandalf\sbutterworth$"
$connect3 = "OK"
$drive5 = "Web's Drive"
use w: "\\gandalf\webs$"
$connect5 = "OK"
$drive4 = "UCAS Drive"
use u: "\\gandalf\ucas$"
$connect4 = "OK"
$drive6 = "Audit Drive"
use n: "\\gateway\audit$"
$connect6 = "OK"
endif

; REM Setup the Web Teams shared work area
if ingroup("Student Web Team") = 1
$drive7 = "Splat Online Drive"
use w: "\\gandalf\splat$"
$connect7 = "OK"
endif

; REM Setup the Key Skills shared work area
if ingroup("keyskills") = 1
$drive5 = "Key Skills Drive"
use k: "\\gandalf\keyskills$"
$connect5 = "OK"
endif

if ingroup("1997") = 1
$drive3 = "1997 Drive"
use y: "\\gandalf\1997$" ; REM Map drive
$connect3 = "OK"
endif

if ingroup("1998") = 1
$drive3 = "1998 Drive"
use y: "\\gandalf\1998$" ; REM Map drive
$connect3 = "OK"
endif

if ingroup("1999") = 1
$drive3 = "1999 Drive"
use y: "\\gandalf\1999$" ; REM Map drive
$connect3 = "OK"
endif

if ingroup("2000") = 1
$drive3 = "2000 Drive"
use y: "\\gandalf\2000$" ; REM Map drive
$connect3 = "OK"
endif

if ingroup("2001") = 1
$drive3 = "2001 Drive"
use y: "\\gandalf\2001$" ; REM Map drive
$connect3 = "OK"
endif

if ingroup("2002") = 1
$drive3 = "2002 Drive"
use y: "\\gandalf\2002$" ; REM Map drive
$connect3 = "OK"
endif

if ingroup("2003") = 1
$drive3 = "2003 Drive"
use y: "\\gandalf\2003$" ; REM Map drive
$connect3 = "OK"
endif

if ingroup("2004") = 1
$drive3 = "2004 Drive"
use y: "\\gandalf\2004$" ; REM Map drive
$connect3 = "OK"
endif

if ingroup("2005") = 1
$drive3 = "2005 Drive"
use y: "\\gandalf\2005$" ; REM Map drive
$connect3 = "OK"
endif

goSub OfficeKeys
gosub FavouritesLocation
gosub motd

$arguments = "$greeting;$drive1;$connect1;$drive2;$connect2;$drive3;$connect3;$drive4;$connect4;$drive5;$connect5;$drive6;$connect6;$drive7;$connect7;$favourites;$favConnect;$motd"

$style = "dialogWidth:400px;dialogHeight:455px;help:no;scroll:no"

shell '%comspec% /c kixwin "@curdir\logonbox.htm" "$arguments" "$style"'

; Reset the output mode
$X = SetASCII ($PreviousASCIIState)

Quit

;****************************************************
:motd
;****************************************************

;Message of the day section

IF EXIST ("@ldrive\message.ini")

$motd = ReadProfileString("@ldrive\message.ini", "general", "message")
If @ERROR = 0
$motd = $motd + Chr(13) + Chr(10)
Endif

SELECT
CASE InGroup("2001")
$motd = $motd + ReadProfileString("@ldrive\message.ini", "2001", "message")
If @ERROR = 0
Endif
CASE InGroup("2000")
$motd = $motd + ReadProfileString("@ldrive\message.ini", "2000", "message")
If @ERROR = 0
Endif
CASE InGroup("1999")
$motd = $motd + ReadProfileString("@ldrive\message.ini", "1999", "message")
If @ERROR = 0
Endif
CASE InGroup("1998")
$motd = $motd + ReadProfileString("@ldrive\message.ini", "1998", "message")
If @ERROR = 0
Endif
CASE InGroup("1997")
$motd = $motd + ReadProfileString("@ldrive\message.ini", "1997", "message")
If @ERROR = 0
Endif
CASE InGroup("u6")
$motd = $motd + ReadProfileString("@ldrive\message.ini", "u6", "message")
If @ERROR = 0
Endif
CASE InGroup("l6")
$motd = $motd + ReadProfileString("@ldrive\message.ini", "l6", "message")
If @ERROR = 0
Endif
CASE InGroup("staff")
$motd = $motd + ReadProfileString("@ldrive\message.ini", "staff", "message")
If @ERROR = 0
Endif
CASE InGroup("drivers")
$motd = $motd + ReadProfileString("@ldrive\message.ini","drivers","message")
If @ERROR = 0
Endif
CASE 1
$motd = ReadProfileString("@ldrive\message.ini", "general", "message")
If @ERROR = 0
Endif
ENDSELECT
endif

Return

;****************************************************
:OfficeKeys
;****************************************************

; This section inserts the users name into the MS Office Reg Keys

$counter=1
$Initials=""
$x = len (@userid)
while $counter =< $x
$Y=substr (ucase(@userid),$counter,1)
$ascii=asc ($y)
$hex=dectohex ($ascii)
$counter=$counter+1
;the spaces are to force at stringcopy.
$Initials=" "+$Initials+$hex+"00"
loop
$Initials=ltrim ($Initials) +"00" +"00"


$counter=1
$Name=""

$x = len (@fullname)

while $counter =< $x
$Y=substr (@fullname,$counter,1)
$ascii=asc ($y)
$hex=dectohex ($ascii)
$counter=$counter+1
$Name=" "+$Name+$hex+"00"
loop
$Name=ltrim ($Name) +"00" +"00"

;Check the keys for Office 97 Pro

$ikey="HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Common\UserInfo"
IF (ExistKey($ikey) = 0)
$rs = Writevalue("HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Common\UserInfo","UserInitials",$Initials,"reg_binary")
$rs = Writevalue("HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Common\UserInfo","UserName",$Name,"reg_binary")
ENDIF


; Set the Home Page for Internet Explorer
$rs = writevalue ("Software\Microsoft\Internet Explorer\Main", "Start Page", "http://www.kixtart.org", "REG_SZ")

; Set the header and the footer in Internet Explorer to read the users name
; This helps with printout collection.
$rs = writevalue ("Software\Microsoft\Internet Explorer\PageSetup", "header", "@FULLNAME&bPage &p of &P", "REG_SZ")
$rs = writevalue ("Software\Microsoft\Internet Explorer\PageSetup", "footer", "&u", "REG_SZ")

Return


;****************************************************
:FavouritesLocation
;****************************************************

$favorites_location="Y:\@userid\favorites"

;At ( $LineCount, 1) " Favorites Location"


$ikey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
IF (ExistKey($ikey) = 0)
IF (len(ReadValue($ikey,"Favorites")) <> 0)
IF (WriteValue($ikey, "Favorites", $favorites_location, "REG_SZ") <> 0)
;? "Warning "+@error+": "+@serror
ELSE
;? "Update: "+$ikey
ENDIF
ENDIF
ENDIF

$ikey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
IF (ExistKey($ikey) = 0)
IF (len(ReadValue($ikey,"Favorites")) <> 0)
IF (WriteValue($ikey, "Favorites", $favorites_location, "REG_SZ") <> 0)
;? "Warning "+@error+": "+@serror
ELSE
;? "Update: "+$ikey
ENDIF
ENDIF
ENDIF

$ikey="HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
IF (ExistKey($ikey) = 0)
IF (len(ReadValue($ikey,"Favorites")) <> 0)
IF (WriteValue($ikey, "Favorites", $favorites_location, "REG_SZ") <> 0)
;? "Warning "+@error+": "+@serror
ELSE
;? "Update: "+$ikey
ENDIF
ENDIF
ENDIF

$ikey="HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
IF (ExistKey($ikey) = 0)
IF (len(ReadValue($ikey,"Favorites")) <> 0)
IF (WriteValue($ikey, "Favorites", $favorites_location, "REG_SZ") <> 0)
;? "Warning "+@error+": "+@serror
ELSE
;? "Update: "+$ikey
ENDIF
ENDIF
ENDIF

IF (Exist($favorites_location) = 0)
md $favorites_location
ENDIF

Return



Messages.ini - This is where the messages are stored

code:

[general]
message="This is the message of the day windows, where interesting information will be presented to you. Have a nice day! "

[2001]
message="The 2001 message goes here"

[2000]
message="The 2000 message goes here"

[1999]
message="The 1999 message goes here"

[1998]
message="The 1998 message goes here"

[1997]
message="The 1997 message goes here"

[u6]
message="The U6th message goes here"

[l6]
message="Young Enterprise Company, Advertise here while the chance is yours."

[staff]
message="The staff message goes here"

[drivers]
message="Kixtart is Brill! "



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

Top
#13332 - 2001-10-18 03:47 PM Re: Logon script using KixPop to display results/Message of the day
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
logonbox.htm - This file is displayed to the user with the drive mappings and the message.

code:

<html>
<head>
<title>Logon</title>
</head>
<body bgcolor=menu scroll=no on load="body_on load()">
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr><td width=100% height=19>

<p align=center>
<font size="4" id=Greeting face="Verdana, Arial, Helvetica, sans-serif">
greeting</font>
</td></tr><tr>
<td width=100% height=38>
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">The
following drives have been connected:</font></div><hr>
</td></tr><tr>

<td width=100% height=38>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=80% height=19>  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Drive1></font></td>
<td width=20% height=19 align=right><font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Connected1></font>  </td>
</tr>
<tr>
<td width=80% height=19>  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Drive2></font></td>
<td width=20% height=19 align=right><font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Connected2></font>  </td>
</tr>
<tr>
<td width=80% height=19>  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Drive3></font></td>
<td width=20% height=19 align=right><font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Connected3></font>  </td>
</tr>
<tr>
<td width=80% height=18>  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Drive4></font></td>
<td width=20% height=18 align=right><font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Connected4></font>  </td>
</tr>
<tr>
<td width=80% height=19>  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Drive5></font></td>
<td width=20% height=18 align=right><font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Connected5></font>  </td>
</tr>
<tr>
<td width=80% height=19>  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Drive6></font></td>
<td width=20% height=18 align=right><font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Connected6></font>  </td>
</tr>
<tr>
<td width=80% height=19>  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Drive7></font></td>
<td width=20% height=18 align=right><font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Connected7></font>  </td>
</tr>
<tr>
<td width=80% height=19>  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=Favourites></font></td>
<td width=20% height=18 align=right><font face="Verdana, Arial, Helvetica, sans-serif" size="2" id=FavConnect></font>  </td>
</tr>
</table>
</td></tr></table>
<hr>
<center>
<font face="Verdana, Arial, Helvetica, sans-serif" size="3">MESSAGE OF THE DAY</font><br>
<TEXTAREA NAME="MOTD" ROWS=8 COLS=46 WRAP="VIRTUAL" id=motd>This is the area of the screen where messages are presented to the user at logon,

Have a nice day.</TEXTAREA>
</center>

<center><hr>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2"> </font>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="middle">
<td width="80%">
<div align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">  You
are OK to close this box</font></div>
</td>
<td width="20%">
<div align="right">
<input type=submit class=button onClick="cancel_click()" value="Close" name=cancel>
   </div>
</td>
</tr>
</table>
</center>


</body></html>

<script>
function body_on load()
{
var argv = new Array;
argv = window.dialogArguments.split(";");
document.all.Greeting.innerHTML = argv[0];
document.all.Drive1.innerHTML = argv[1];
document.all.Connected1.innerHTML = argv[2];
document.all.Drive2.innerHTML = argv[3];
document.all.Connected2.innerHTML = argv[4];
document.all.Drive3.innerHTML = argv[5];
document.all.Connected3.innerHTML = argv[6];
document.all.Drive4.innerHTML = argv[7];
document.all.Connected4.innerHTML = argv[8];
document.all.Drive5.innerHTML = argv[9];
document.all.Connected5.innerHTML = argv[10];
document.all.Drive6.innerHTML = argv[11];
document.all.Connected6.innerHTML = argv[12];
document.all.Drive7.innerHTML = argv[13];
document.all.Connected7.innerHTML = argv[14];
document.all.Favourites.innerHTML = argv[15];
document.all.FavConnect.innerHTML = argv[16];
document.all.motd.innerHTML = argv[17];






window.returnvalue = -1;
}

function cancel_click()
{
window.close();
}
</script>


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

Top
#13333 - 2001-10-18 05:41 PM Re: Logon script using KixPop to display results/Message of the day
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Ghost,

Very sharp - I just created a little stripped down version of your logon script so I could view (run) the results, with your permission:

code:

break on


$greeting = "Welcome to ACME Incorporated <br> Have a nice day"
$motd = "Don't be telling folks to have a nice day!"
$favconnect = "This is my favorite"
$favourites = "Y:\@userid\favorites"


$drive1 = "PERSONAL SHARE (M :)"
$connect1 = "OK"
$drive2 = "SECTION SHARE (N :)"
$connect2 = "OK"
$drive3 = "DISTRICT SHARE (O :)"
$connect3 = "OK"


$arguments = "$greeting;$drive1;$connect1;$drive2;$connect2;$drive3;$connect3;;;;;;;;;$favourites;$favConnect;$motd"
$style = "dialogWidth:400px;dialogHeight:490px;help:no;scroll:no"


shell '%comspec% /c kixwin "file://@curdir\test.htm" "$arguments" "$style"'


exit


Cudos aside, might suggest that the CLOSE button is a bit to far to the right ? Might look better centered with the close message right above (my 2 cents) ...

-Shawn

[ 18 October 2001: Message edited by: Shawn ]

Top
#13334 - 2001-10-19 01:17 PM Re: Logon script using KixPop to display results/Message of the day
Ghost Offline
Starting to like KiXtart

Registered: 2000-09-14
Posts: 171
It does look better, I put the button there to make the box smaller.

I just feels good to be giving back.

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

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

Generated in 0.052 seconds in which 0.024 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