Page 1 of 3 123>
Topic Options
#173266 - 2007-01-26 06:51 PM Another login script: Error in Use Statement
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Hello, when trying to run the following script, the users recieve an error:

ERROR : error in USE statement!
Script: .../netlogon.kix
Line : 234

Code:
;************************************************************
;**              NetLogon Script 4                         **
;**              Powered by KiXforms                       **
;**                                                        **
;**    Script compiled with help from the following        **
;**    members in the KiXtart Forum:                       **
;**    Benny69, Exodus3320, Gargoyle, Shawn                **
;**                                                        **
;**    Original Script by: dpalmer, snunhuck, nau          **
;************************************************************
;**************************
;** Dim some global vars **
;**************************
Dim $frmForm
Dim $fraBanner, $fraForm 
;Dim $prgProgress 
Dim $Hour

;**************************
;** Set some global vars **
;**************************
$strVersion = "v4.2.09"
$LSD = @scriptdir 
$WaitTime = 1			
$Blanker = "                                  "	

;******************
;**  START HERE  **
;******************                      

CheckDLL()

;Create NetCare Object
$System = CreateObject("Kixtart.System")
;Verify NetCare Object was created
If Not $System
	$nul= MessageBox("NetCare Not Initiated."+@CRLF+
	                 "Please Verify netcare.dll is installed."+@CRLF+
	                 "This Script Will Now Close.","Error...",16)
   Quit()
EndIf

;***************
;** Main form **
;***************
$frmForm = $System.Form()
$frmForm.Text = "NetCare $strVersion - D5PS2Z0J Logon System "
$frmForm.SysMenu = 0
$frmForm.Height = 350
$frmForm.Width = 500
$frmForm.FontName = "ariel"
$frmForm.FontSize = 10

;*************
;**  Banner **
;*************	
$fraBanner = $frmForm.Controls.Add("PictureBox")
$fraBanner.Image = @Scriptdir + "\finalbanner.jpg"
$fraBanner.BackColor = $frmForm.RGB(255,255,255)
$fraBanner.Width = $frmForm.Width - 4
$fraBanner.Height = 106
$fraBanner.Left = -2
$fraBanner.Top = -2

;************************
;** Draw On the banner **
;************************
$fraBanner.FontSize = 20
$fraBanner.FontName = "ariel"
$fraBanner.FontBold = 1
$fraBanner.FontItalic = 1
$fraBanner.ForeColor = $frmForm.RGB(0, 100, 200)
$fraBanner.PrintXY (10,0,"Netlogon on @WKSTA")
$fraBanner.FontItalic = 0
$fraBanner.FontSize = 12
$fraBanner.ForeColor = $frmForm.RGB(0,0,0)
$fraBanner.PrintXY (10,35,$strVersion +"   Powered by NetCare Engine (Shamil Nunhuck) ")
$fraBanner.FontSize = 12
$fraBanner.PrintXY (10,55,"@DAY @MDAYNO @MONTH @YEAR")
$fraBanner.FontBold = 0
$fraBanner.FontSize = 10

;******************
;** Progress Bar **
;******************
$prgProgress = $frmForm.Controls.Add("ProgressBar")
$prgProgress.Width = $frmForm.Width - 10
$prgProgress.Left = 2
$prgProgress.Height = 20
$prgProgress.Top = 290;$frmForm.Height - $prgProgress.Height - 5
$prgProgress.Style = 1

;****************
;** Main Frame **
;****************
$fraMain = $frmForm.Controls.Add("PictureBox")
$fraMain.BackColor = $frmForm.RGB(245,245,245)
$fraMain.Width = $frmForm.Width 
$fraMain.Height = 182 ;$frmForm.Height - $fraBanner.Height - 35
$fraMain.Left = -2
$fraMain.Top = $fraBanner.Height - 5

$lblJob = $fraMain.Controls.Add("label")
$lblJob.FontSize = 10
$lblJob.FontName = "ariel"
$lblJob.Top = 100
$lblJob.Width = 440 ;fraMain.Width - 20
$lblJob.Left = 10

$lblTask = $fraMain.Controls.Add("label")
$lblTask.FontSize = 10
$lblTask.FontName = "ariel"
$lblTask.Top = 130
$lblTask.Width = 440 ;fraMain.Width - 20
$lblTask.Left = 50

;***********************
;** Draw on the frame **
;**     Greeting      **
;***********************
$Hour = Val(Trim(Left(@Time,2)))
If $Hour < 12
	$Greeting = "Good Morning @userid (@priv)"
Else 
	If $Hour < 17
		$Greeting = "Good Afternoon @userid (@priv) "
	Else
		$Greeting = "Good Evening @userid (@priv) "
	EndIf
EndIf
$Date = "@DAY @MDAYNO @MONTH @YEAR "
$fraMain.FontSize = 13
$fraMain.FontName = "ariel"
$fraMain.FontBold = 1
$fraMain.ForeColor = $frmForm.RGB(0,100,200)
$fraMain.PrintXY (10,10,$Date)
$fraMain.PrintXY (10,40,$Greeting)

$fraMainLabel = $fraMain.Controls.Add("Label")
$fraMainLabel.BackColor = $frmForm.RGB(245,245,245)
$fraMainLabel.FontSize = 13
$fraMainLabel.FontBold = 1
$fraMainLabel.ForeColor = $frmForm.RGB(0,100,100)
$fraMainLabel.Left = 10
$fraMainLabel.Text = "Please wait while you logon script executes..."
$fraMainLabel.Top = 70
$fraMainLabel.Width = $frmForm.Width

$frmForm.Center
$frmForm.Show 

Prep()
sleep 1
MapDrives()
DoAudit()
DoAntiVirus()
Time()
LogUser()
Snd()

Sleep 0.5
$fraMainLabel.Text = "Logon has been successful."
Sleep 3
ExitScript()

While $frmForm.Visible
	$=Execute($frmForm.DoEvents())
Exit 0

;*******************
;** End Main Form **
;*******************

Function CheckDLL()
	;*************************************************
	;** Check that netcare.DLL is registered and   **
	;**         copy and register if not            **
	;*************************************************
	
	;$ReturnCode = KeyExist("HKEY_CLASSES_ROOT\KixTart.Form\CLSID")
	$ReturnCode = KeyExist("HKEY_CLASSES_ROOT\Kixtart.System\CLSID")
	
	If  $ReturnCode = 0								
														
		$SourceFile = @scriptdir + "\netcare.dll"
		$Value = ReadValue("HKLM\System\CurrentControlset\Control\Windows", "SystemDirectory") 
		$Destination = ExpandEnvironmentVars($Value) 
		Copy $SourceFile $Destination
														
		$CMDLine = "regsvr32 /s " + $Destination + "\netcare.dll"
		$ObjShell = CreateObject("WScript.Shell")
		$ObjShell.run($CMDLine, 1, true)
														
		$ObjShell = ""
	EndIf
	;** Wait for registration to take effect
	
EndFunction

Function DoProgress($Step)
	$prgProgress.Value = $prgProgress.Value + $Step
EndFunction

Function Prep()
	$lblJob.Text = $Blanker
	$lblJob.Text = "Preparing for logon"
	DoProgress(5)
	Sleep 0.5
EndFunction 

Function MapDrives()
	$lblJob.Text = $Blanker
	$lblJob.Text = "Mapping Network Drives... "
	
	Use * /DELETE

;** Common mappings: Everyone gets these **

	Sleep $WaitTime
	DoProgress(5)

	$DriveToMap = @HomeShr
	$lblTask.Text = $Blanker
    $lblTask.Text = "Home Directory"
	Use U: $DriveToMap		
	DoProgress(2)	
	
	
	$DriveToMap = "\\sdc5400\mfl"
	$lblTask.Text = "MFL"
	Use L: $DriveToMap		
	DoProgress(2)
	
	
	$DriveToMap = "\\sdc5400\sharedres"
	$lblTask.Text = "Shared Resources"
	Use R: $DriveToMap		
	DoProgress(2)
	
	
	$DriveToMap = "\\sdc5400\pcapps"
	$lblTask.Text = "PC Apps"
	Use P: $DriveToMap		
	DoProgress(2)
	
	
	$DriveToMap = "\\sdc5400\cdroms"
	$lblTask.Text = "CD Roms"
	Use V: $DriveToMap		
	DoProgress(2)
	
	
	IF INGROUP("SIMSUsers") 
	$DriveToMap = @LServer + "\Simsarea"
	$lblTask.Text = "SIMS Area"
	Use W: $DriveToMap		
	DoProgress(2)

ENDIF	
	IF INGROUP("Staff")
	$DriveToMap = "\\rdc5400\students"
	$lblTask.Text = "Students"
	Use S: $DriveToMap		
	DoProgress(2)

	
	$DriveToMap = "\\sdc5400\shared"
	$lblTask.Text = "Shared"
	Use O: $DriveToMap		
	DoProgress(2)

	ENDIF
	IF INGROUP("Domain Admins")
	$DriveToMap = "\\rdc5400\NetAdmin"
	$lblTask.Text = "NetAdmin"
	Use N: $DriveToMap		
	DoProgress(2)

	
	$DriveToMap = "\\rdc5400\Menus"
	$lblTask.Text = "Menus"
	Use M: $DriveToMap		
	DoProgress(2)

ENDIF
	EndFunction
Function DoAudit()
	$fraMain.fontsize = 10
	$lblJob.Text = $Blanker
	$lblJob.Text = "Running Workstation Audit... "
	
	;AUDIT STUFF IN HERE
	;
	;Audit what????
	;
	; Hardware: (Check for changes?)
	; Installed Software (Check for changes?)
                                                          
	$lblTask.Text = $Blanker
	$lblTask.Text = "Hardware"
	Sleep $WaitTime
	DoProgress(5)
	
	$lblTask.Text = $Blanker
	$lblTask.Text = "Software"
	Sleep $WaitTime
	DoProgress(5)
EndFunction
Function LogUser()
	$lblJob.caption = $Blanker
	$lblJob.caption = "Collecting Logon Info... "
	
	
	;** Dim some vars
	$LogFolder = @scriptdir + "\logs\"			
	
	;** Path to log dir
	$FileName = @month  + "--"+ "log.txt"		

	;** Get Log File Name
	$MyFile = $LogFolder + $FileName				

	;** Set full path to file
	$CRLF= Chr(13) + Chr(10)  					

	;** Set Carriage Return + Line feed
	$MyDateTime = @DATE + " : " + @TIME			

	;** Date and time string
	DoProgress(10)
	                                                                               
	If Open(1,$MyFile,5) = 0 					
		;** Open file for write. Create if doesn't exist
		;** Date And time
		$Silent = WriteLine (1, $MyDateTime + $CRLF)   
		$lblTask.Caption = $Blanker
		$lblTask.Caption = "Time and Date"
		Sleep $WaitTime
		DoProgress(10)
		
		;** User Details
		$Silent = WriteLine (1, "User: " + @USERID + " Full Name: " + @FULLNAME + $CRLF);Write data to file
		$lblTask.Caption = $Blanker
		$lblTask.Caption = "User Name"
		Sleep $WaitTime
		DoProgress(10)
		
		;** IP 0
		$Silent = WriteLine (1, "IP: " + @IPAddress0 + $CRLF)  
		$lblTask.Caption = $Blanker
		$lblTask.Caption = "IP Address"
		Sleep $WaitTime
		DoProgress(15)
		
		$Silent = WriteLine (1, $CRLF) 
										
		$Silent = Close (1)                             
	EndIf
	Sleep 0.5
EndFunction

Function DoAntiVirus()
	$lblJob.Text = $Blanker
	$lblJob.Text = "Updating Antivirus... "
	$lblTask.Text = " CANNOT UPDATE ANTIVIRUS"
	$lblTask.Text = $Blanker
	DoProgress(10)
sleep 0.5
	EndFunction

Function Time()
	;======= Sync Time Local Time Server 
	$lblJob.Text = $Blanker
	$lblJob.Text = "Synchronizing time with SWGfL NTP (Time) Server "
	$lblTask.Text = $Blanker
	$lblTask.Text = " CANNOT PERFORM SYNC"
	DoProgress(15)
;	If Exist (@scriptdir+"\netlogon\TimeSync.bat")
;		Shell @scriptdir+"\netlogon\TimeSync.bat"
	
;	EndIf
sleep 1
EndFunction

Function Snd()
	$lblTask.Text = $Blanker
    $lblTask.Text = "Welcome to " + @WKSTA
	DoProgress(10)
    $fraMainLabel.Text = "Logon has been successful."	
	DoProgress(10)
    $lblJob.Text = $Blanker
	$lblJob.Text = ""
	Play @scriptdir + "logon.wav"


EndFunction

Function ExitScript()
	Quit()
EndFunction

;*****************
;** End of File **
;*****************


Top
#173267 - 2007-01-26 07:11 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
exodus3320 Offline
Lurker

Registered: 2007-01-26
Posts: 1
I would just like to point out that I contributed largely to the writing of that code, and specifically to the User Interface elements. For some reason, the person who posted this hasn't mentioned me in the credits/title box in the source code.

Don't make me use upper case!!!

Top
#173268 - 2007-01-26 07:27 PM Re: Another login script: Error in Use Statement [Re: exodus3320]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I assume its failing around here:

$lblTask.Text = "MFL"
Use L: $DriveToMap

on the use ? What happens if you comment out the line before it - the $lblTask line - does it make any difference ? If you comment-out the USE line - does the error go completely away ?

Top
#173269 - 2007-01-26 07:30 PM Re: Another login script: Error in Use Statement [Re: exodus3320]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Sorry about that, that was a prototype that the other technician did, as mine was absolutely rubbish. He seemed to have deleted the top half which did have all the credits. I hadn't noticed that until you told me. Thnaks for telling me. I have amended it. Thanks again for reminding me to restore the info at the top.

edit: 18:51 " I have editied it but the credits are just not showing in the code"


Edited by 04nunhucks (2007-01-26 07:51 PM)

Top
#173271 - 2007-01-26 07:48 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Hello Shawn, I have followed your instructions to no avail. Commenting out $lblTask makes no difference. Commenting out the USE statement just makes it punce on the next USE statement (Use R: $DriveToMap) and gives the same error.
Top
#173273 - 2007-01-26 07:56 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Quote:

Warning: Undeclared variable.
Variable Name: $strVersion
In function: Main
Referenced on line: 25

Warning: Undeclared variable.
Variable Name: $LSD
In function: Main
Referenced on line: 26

Warning: Undeclared variable.
Variable Name: $WaitTime
In function: Main
Referenced on line: 27

Warning: Undeclared variable.
Variable Name: $Blanker
In function: Main
Referenced on line: 28

Warning: Undeclared variable.
Variable Name: $System
In function: Main
Referenced on line: 37

Warning: Undeclared variable.
Variable Name: $nul
In function: Main
Referenced on line: 40

Warning: Possible mismatched parenthesis.
In function: Main
Referenced on line: 40
PF=1
40: $nul= MessageBox("NetCare Not Initiated."+@CRLF+

Warning: Possible mismatched parenthesis.
In function: Main
Referenced on line: 42
PF=-1
42: "This Script Will Now Close.","Error...",16)

Warning: Variable referenced inside string.
Variable Name: $strVersion
In function: Main
Referenced on line: 50
50: $frmForm.Text = "NetCare $strVersion - D5PS2Z0J Logon System "

Warning: Undeclared variable.
Variable Name: $prgProgress
In function: Main
Referenced on line: 89

Warning: Undeclared variable.
Variable Name: $fraMain
In function: Main
Referenced on line: 99

Warning: Undeclared variable.
Variable Name: $lblJob
In function: Main
Referenced on line: 106

Warning: Undeclared variable.
Variable Name: $lblTask
In function: Main
Referenced on line: 113

Warning: Undeclared variable.
Variable Name: $Greeting
In function: Main
Referenced on line: 126

Warning: Undeclared variable.
Variable Name: $Date
In function: Main
Referenced on line: 134

Warning: Undeclared variable.
Variable Name: $fraMainLabel
In function: Main
Referenced on line: 142

Warning: Undeclared variable.
Variable Name: $
In function: Main
Referenced on line: 170

Warning: Undeclared variable.
Variable Name: $ReturnCode
In function: CheckDLL
Referenced on line: 184

Warning: Undeclared variable.
Variable Name: $SourceFile
In function: CheckDLL
Referenced on line: 188

Warning: Undeclared variable.
Variable Name: $Value
In function: CheckDLL
Referenced on line: 189

Warning: Undeclared variable.
Variable Name: $Destination
In function: CheckDLL
Referenced on line: 190

Warning: Undeclared variable.
Variable Name: $CMDLine
In function: CheckDLL
Referenced on line: 193

Warning: Undeclared variable.
Variable Name: $ObjShell
In function: CheckDLL
Referenced on line: 194

Warning: Undeclared variable.
Variable Name: $prgProgress
In function: DoProgress
Referenced on line: 204

Warning: Undeclared variable.
Variable Name: $lblJob
In function: Prep
Referenced on line: 208

Warning: Undeclared variable.
Variable Name: $Blanker
In function: Prep
Referenced on line: 208

Warning: Undeclared variable.
Variable Name: $lblJob
In function: MapDrives
Referenced on line: 215

Warning: Undeclared variable.
Variable Name: $Blanker
In function: MapDrives
Referenced on line: 215

Warning: Undeclared variable.
Variable Name: $WaitTime
In function: MapDrives
Referenced on line: 222

Warning: Undeclared variable.
Variable Name: $DriveToMap
In function: MapDrives
Referenced on line: 225

Warning: Undeclared variable.
Variable Name: $lblTask
In function: MapDrives
Referenced on line: 226

Warning: Undeclared variable.
Variable Name: $fraMain
In function: DoAudit
Referenced on line: 291

Warning: Undeclared variable.
Variable Name: $lblJob
In function: DoAudit
Referenced on line: 292

Warning: Undeclared variable.
Variable Name: $Blanker
In function: DoAudit
Referenced on line: 292

Warning: Undeclared variable.
Variable Name: $lblTask
In function: DoAudit
Referenced on line: 302

Warning: Undeclared variable.
Variable Name: $WaitTime
In function: DoAudit
Referenced on line: 304

Warning: Undeclared variable.
Variable Name: $lblJob
In function: LogUser
Referenced on line: 313

Warning: Undeclared variable.
Variable Name: $Blanker
In function: LogUser
Referenced on line: 313

Warning: Undeclared variable.
Variable Name: $LogFolder
In function: LogUser
Referenced on line: 318

Warning: Undeclared variable.
Variable Name: $FileName
In function: LogUser
Referenced on line: 321

Warning: Undeclared variable.
Variable Name: $MyFile
In function: LogUser
Referenced on line: 324

Warning: Undeclared variable.
Variable Name: $CRLF
In function: LogUser
Referenced on line: 327

Warning: Undeclared variable.
Variable Name: $MyDateTime
In function: LogUser
Referenced on line: 330

Warning: Undeclared variable.
Variable Name: $Silent
In function: LogUser
Referenced on line: 338

Warning: Undeclared variable.
Variable Name: $lblTask
In function: LogUser
Referenced on line: 339

Warning: Undeclared variable.
Variable Name: $WaitTime
In function: LogUser
Referenced on line: 341

Warning: Undeclared variable.
Variable Name: $lblJob
In function: DoAntiVirus
Referenced on line: 366

Warning: Undeclared variable.
Variable Name: $Blanker
In function: DoAntiVirus
Referenced on line: 366

Warning: Undeclared variable.
Variable Name: $lblTask
In function: DoAntiVirus
Referenced on line: 368

Warning: Undeclared variable.
Variable Name: $lblJob
In function: Time
Referenced on line: 376

Warning: Undeclared variable.
Variable Name: $Blanker
In function: Time
Referenced on line: 376

Warning: Undeclared variable.
Variable Name: $lblTask
In function: Time
Referenced on line: 378

Warning: Undeclared variable.
Variable Name: $lblTask
In function: Snd
Referenced on line: 389

Warning: Undeclared variable.
Variable Name: $Blanker
In function: Snd
Referenced on line: 389

Warning: Undeclared variable.
Variable Name: $fraMainLabel
In function: Snd
Referenced on line: 392

Warning: Undeclared variable.
Variable Name: $lblJob
In function: Snd
Referenced on line: 394
56 warnings generated, 408 lines processed.

Top
#173274 - 2007-01-26 08:02 PM Re: Another login script: Error in Use Statement [Re: NTDOC]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Hi,

I would like to say that if I replace all of the Drive mappings with
Code:
	$DriveToMap = "\\shamil-2dptm3ss\netlogon"
	$lblTask.Text = $Blanker
    $lblTask.Text = "netlogon"
	Use N: $DriveToMap		
	DoProgress(10)	
	
	Sleep 0.5
	$DriveToMap = "\\shamil-2dptm3ss\cache"
	$lblTask.Text = "SmartCache"
	Use S: $DriveToMap		
	DoProgress(10)
	Sleep 0.5


The code works perfectly fine. (I use this at home). But adding the drive mappings make it fail.

Also, I am sure all the variables are declared at the begninning of the script, NTDOC.

Top
#173275 - 2007-01-26 08:16 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Originally Posted By: 04nunhucks
Also, I am sure all the variables are declared at the begninning of the script, NTDOC.


Well declaring the variables is probably not your issue, but they are not declared otherwise these errors would not show.

You also use vars in strings and macros in strings all of which removing and cleaning up might help in the long run to make the code better.

.

Top
#173276 - 2007-01-26 08:27 PM Re: Another login script: Error in Use Statement [Re: NTDOC]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Ok, thanks NTDOC, which one of these would be a macro and a var? Just an example will do; just to refresh my memory.
Top
#173277 - 2007-01-26 09:03 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Line 47 has a variable in a string
$frmForm.Text = "NetCare $strVersion - D5PS2Z0J Logon System "

Line 73 has a macro in a string
$fraBanner.PrintXY (10,0,"Netlogon on @WKSTA")


etc...

.

Top
#173280 - 2007-01-26 10:09 PM Re: Another login script: Error in Use Statement [Re: NTDOC]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
ah, right thanks, I will amend it asap
Top
#173281 - 2007-01-26 10:20 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Hello, by clearing up, I interpret that you meand changing it all to either macro or string? Or have I misunderstood NOTDOC?
Top
#173282 - 2007-01-26 10:31 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA

Doc meant cleaning up your code so that you do not have Vars or Macro in your strings...

from:
$frmForm.Text = "NetCare $strVersion - D5PS2Z0J Logon System "
to:
$frmForm.Text = "NetCare " + $strVersion + " - D5PS2Z0J Logon System "

and from:
$fraBanner.PrintXY (10,0,"Netlogon on @WKSTA")
to:
$fraBanner.PrintXY (10,0,"Netlogon on " + @WKSTA)

Top
#173283 - 2007-01-26 11:09 PM Re: Another login script: Error in Use Statement [Re: Allen]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
If you instate the following options at the beginning of your script you will see what they mean real quick

Code:

$RC = Setoption(NoVarsInStrings,ON)
$RC = Setoption(NoMacrosInStrings,ON)
$RC = Setoption(Explicit,ON)



Another really good one is

Code:
If not @logonmode
 Break ON
EndIf


With the first section your script will start screaming (beeping everytime you execute it) until you fix it to comply with all the SetOptions.

Can be frustrating at times, but it does make one a much better coder.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#173284 - 2007-01-26 11:19 PM Re: Another login script: Error in Use Statement [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
The errors that Doc displayed were the result of passing your script through the Sanity() udf, which checks for mismatched quotes & parens, undeclared vars or duplicate var definitions. Sanity is also part of the KGen tools.

Sanity also generates a report of variable usage, so you can easily add var declarations in each UDF.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#173290 - 2007-01-27 11:42 AM Re: Another login script: Error in Use Statement [Re: Glenn Barnas]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Wow, thanks guys, I am really learning a lot from this. I will post the new script in my next post; just having breakfast!
Top
#173291 - 2007-01-27 12:13 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Hi, here is the amended code:

Code:
;************************************************************
;************************************************************
;**                                                                                                               **
;**           NetCare4 - D5PS2Z0J Login System                                     **
;**                     Netlogon.NET                                                                  **
;**                                                                                                               **
;**                                                                                                               **
;**           Credits from KiXtart Bulletin Board Forum:                           **
;**           Benny69, gargoyle, exodus3320, Shawn, NTDOC,               **                                                           
;************************************************************
;************************************************************ 

;**************************
;** Dim some global vars **
;**************************
Dim $frmForm
Dim $fraBanner, $fraForm 
;Dim $prgProgress 
Dim $Hour
;**************************
;** Set some global vars **
;**************************
$strVersion = "v4.2.09"
$LSD = @scriptdir 
$WaitTime = 1			
$Blanker = "                                  "	

;******************
;**  START HERE  **
;******************                      

CheckDLL()

;Create NetCare Object
$System = CreateObject("Kixtart.System")
;Verify NetCare Object was created
If Not $System
	$nul= MessageBox("NetCare Not Initiated."+@CRLF+
	                 "Please Verify netcare.dll is installed."+@CRLF+
	                 "This Script Will Now Close.","Error...",16)
   Quit()
EndIf

;***************
;** Main form **
;***************
$frmForm = $System.Form()
$frmForm.Text = "NetCare"+ $strVersion - "D5PS2Z0J Logon System "
$frmForm.SysMenu = 0
$frmForm.Height = 350
$frmForm.Width = 500
$frmForm.FontName = "ariel"
$frmForm.FontSize = 10

;*************
;**  Banner **
;*************	
$fraBanner = $frmForm.Controls.Add("PictureBox")
$fraBanner.Image = @Scriptdir + "\finalbanner.jpg"
$fraBanner.BackColor = $frmForm.RGB(255,255,255)
$fraBanner.Width = $frmForm.Width - 4
$fraBanner.Height = 106
$fraBanner.Left = -2
$fraBanner.Top = -2

;************************
;** Draw On the banner **
;************************
$fraBanner.FontSize = 20
$fraBanner.FontName = "ariel"
$fraBanner.FontBold = 1
$fraBanner.FontItalic = 1
$fraBanner.ForeColor = $frmForm.RGB(0, 100, 200)
$fraBanner.PrintXY (10,0,"Netlogon on @WKSTA")
$fraBanner.FontItalic = 0
$fraBanner.FontSize = 12
$fraBanner.ForeColor = $frmForm.RGB(0,0,0)
$fraBanner.PrintXY (10,35,$strVersion +"   Powered by NetCare Engine (Shamil Nunhuck) ")
$fraBanner.FontSize = 12
$fraBanner.PrintXY (10,55,"@DAY @MDAYNO @MONTH @YEAR")
$fraBanner.FontBold = 0
$fraBanner.FontSize = 10

;******************
;** Progress Bar **
;******************
$prgProgress = $frmForm.Controls.Add("ProgressBar")
$prgProgress.Width = $frmForm.Width - 10
$prgProgress.Left = 2
$prgProgress.Height = 20
$prgProgress.Top = 290;$frmForm.Height - $prgProgress.Height - 5
$prgProgress.Style = 1

;****************
;** Main Frame **
;****************
$fraMain = $frmForm.Controls.Add("PictureBox")
$fraMain.BackColor = $frmForm.RGB(245,245,245)
$fraMain.Width = $frmForm.Width 
$fraMain.Height = 182 ;$frmForm.Height - $fraBanner.Height - 35
$fraMain.Left = -2
$fraMain.Top = $fraBanner.Height - 5

$lblJob = $fraMain.Controls.Add("label")
$lblJob.FontSize = 10
$lblJob.FontName = "ariel"
$lblJob.Top = 100
$lblJob.Width = 440 ;fraMain.Width - 20
$lblJob.Left = 10

$lblTask = $fraMain.Controls.Add("label")
$lblTask.FontSize = 10
$lblTask.FontName = "ariel"
$lblTask.Top = 130
$lblTask.Width = 440 ;fraMain.Width - 20
$lblTask.Left = 50

;***********************
;** Draw on the frame **
;**     Greeting      **
;***********************
$Hour = Val(Trim(Left(@Time,2)))
If $Hour < 12
	$Greeting = "Good Morning"+ @userid+ "("+@priv")"
Else 
	If $Hour < 17
		$Greeting = "Good Afternoon"+ @userid+ "("+@priv")"
	Else
		$Greeting = "Good Evening" + @userid+ "("+@priv")"
	EndIf
EndIf
$Date = "@DAY +@MDAYNO +@MONTH +@YEAR "
$fraMain.FontSize = 13
$fraMain.FontName = "ariel"
$fraMain.FontBold = 1
$fraMain.ForeColor = $frmForm.RGB(0,100,200)
$fraMain.PrintXY (10,10,$Date)
$fraMain.PrintXY (10,40,$Greeting)

$fraMainLabel = $fraMain.Controls.Add("Label")
$fraMainLabel.BackColor = $frmForm.RGB(245,245,245)
$fraMainLabel.FontSize = 13
$fraMainLabel.FontBold = 1
$fraMainLabel.ForeColor = $frmForm.RGB(0,100,100)
$fraMainLabel.Left = 10
$fraMainLabel.Text = "Please wait while you logon script executes..."
$fraMainLabel.Top = 70
$fraMainLabel.Width = $frmForm.Width

$frmForm.Center
$frmForm.Show 

Prep()
sleep 1
MapDrives()
DoAudit()
DoAntiVirus()
Time()
LogUser()
Snd()

Sleep 0.5
$fraMainLabel.Text = "Logon has been successful."
Sleep 3
ExitScript()

While $frmForm.Visible
	$=Execute($frmForm.DoEvents())
Exit 0

;*******************
;** End Main Form **
;*******************

Function CheckDLL()
	;*************************************************
	;** Check that netcare.DLL is registered and   **
	;**         copy and register if not            **
	;*************************************************
	
	;$ReturnCode = KeyExist("HKEY_CLASSES_ROOT\KixTart.Form\CLSID")
	$ReturnCode = KeyExist("HKEY_CLASSES_ROOT\Kixtart.System\CLSID")
	
	If  $ReturnCode = 0								
														
		$SourceFile = @scriptdir + "\netcare.dll"
		$Value = ReadValue("HKLM\System\CurrentControlset\Control\Windows", "SystemDirectory") 
		$Destination = ExpandEnvironmentVars($Value) 
		Copy $SourceFile $Destination
														
		$CMDLine = "regsvr32 /s " + $Destination + "\netcare.dll"
		$ObjShell = CreateObject("WScript.Shell")
		$ObjShell.run($CMDLine, 1, true)
														
		$ObjShell = ""
	EndIf
	;** Wait for registration to take effect
	
EndFunction

Function DoProgress($Step)
	$prgProgress.Value = $prgProgress.Value + $Step
EndFunction

Function Prep()
	$lblJob.Text = $Blanker
	$lblJob.Text = "Preparing for logon"
	DoProgress(5)
	Sleep 0.5
EndFunction 

Function MapDrives()
	$lblJob.Text = $Blanker
	$lblJob.Text = "Mapping Network Drives... "
	
	Use * /DELETE

;** Common mappings: Everyone gets these **

	Sleep $WaitTime
	DoProgress(5)
    $DriveToMap = @HomeShr 
	$lblTask.Caption = $Blanker
	$lblTask.Caption = $DriveToMap
	USE U: @HomeShr						;** Map U: to HomeDir Share
	DoProgress(5)

	$DriveToMap = "\\sdc5400\mfl"
	$lblTask.Caption = $Blanker
	$lblTask.Caption = $DriveToMap
	USE L: $DriveToMap						;** Map L: to SharedRes Share
	DoProgress(5)

	$DriveToMap = "\\sdc5400\sharedres"
	$lblTask.Caption = $Blanker
	$lblTask.Caption = $DriveToMap
	USE R: $DriveToMap						;** Map R: to SharedRes Share
	DoProgress(5)

	$DriveToMap = "\\sdc5400\pcapps"
	$lblTask.Caption = $Blanker
	$lblTask.Caption = $DriveToMap			
	USE P: $DriveToMap							;** Map T: to PcApps Share
DoProgress(5)
	$DriveToMap = "\\sdc5400\cdroms"
	$lblTask.Caption = $Blanker
	$lblTask.Caption = $DriveToMap
	USE V: $DriveToMap							;** Map V: to CDRoms Share
DoProgress(5)
	IF INGROUP("SIMSUsers")         ;** User belongs to SIMSUsers Group
						
		$DriveToMap = @LServer + "\Simsarea"
		$lblTask.Caption = $Blanker
		$lblTask.Caption = $DriveToMap
		USE S: $DriveToMap						;** Map S: to SIMSArea
DoProgress(5)
;		$DriveToMap = "\\SQLxxxx\Simsarea"
;		$lblTask.Caption = $Blanker
;		$lblTask.Caption = $DriveToMap
;		USE S: $DriveToMap							;** Map W: to Students Share
;		Sleep $WaitTime
;		$prgProgress.value = $prgProgress.value + 5

	ENDIF								
	
	IF INGROUP("Staff")	;** User belongs to Staff group						
	
		$DriveToMap = "\\rdc5400\students"
		$lblTask.Caption = $Blanker
		$lblTask.Caption = $DriveToMap
		USE W: $DriveToMap							;** Map W: to Students Share
DoProgress(5)
		$DriveToMap = "\\sdc5400\shared"
		$lblTask.Caption = $Blanker
		$lblTask.Caption = $DriveToMap
		USE O: $DriveToMap							;** Map O: to Old Work Area
DoProgress(5)

ENDIF
	
	IF INGROUP("Domain Admins")
	
		$DriveToMap = "\\rdc5400\NetAdmin"
		$lblTask.Caption = $Blanker
		$lblTask.Caption = $DriveToMap
		USE N: $DriveToMap							;** Map P: to pcapps Share
DoProgress(5)	
		$DriveToMap = "\\rdc5400\Menus"
		$lblTask.Caption = $Blanker
		$lblTask.Caption = $DriveToMap
		USE M: $DriveToMap							;** Map R: to sharedres Share
DoProgress(5)	
	ENDIF	
	


	EndFunction
Function DoAudit()
	$fraMain.fontsize = 10
	$lblJob.Text = $Blanker
	$lblJob.Text = "Running Workstation Audit... "
	
	;AUDIT STUFF IN HERE
	;
	;Audit what????
	;
	; Hardware: (Check for changes?)
	; Installed Software (Check for changes?)
                                                          
	$lblTask.Text = $Blanker
	$lblTask.Text = "Hardware"
	Sleep $WaitTime
	DoProgress(5)
	
	$lblTask.Text = $Blanker
	$lblTask.Text = "Software"
	Sleep $WaitTime
	DoProgress(5)
EndFunction
Function LogUser()
	$lblJob.caption = $Blanker
	$lblJob.caption = "Collecting Logon Info... "
	
	
	;** Dim some vars
	$LogFolder = @scriptdir + "\logs\"			
	
	;** Path to log dir
	$FileName = @month  + "--"+ "log.txt"		

	;** Get Log File Name
	$MyFile = $LogFolder + $FileName				

	;** Set full path to file
	$CRLF= Chr(13) + Chr(10)  					

	;** Set Carriage Return + Line feed
	$MyDateTime = @DATE + " : " + @TIME			

	;** Date and time string
	DoProgress(10)
	                                                                               
	If Open(1,$MyFile,5) = 0 					
		;** Open file for write. Create if doesn't exist
		;** Date And time
		$Silent = WriteLine (1, $MyDateTime + $CRLF)   
		$lblTask.Caption = $Blanker
		$lblTask.Caption = "Time and Date"
		Sleep $WaitTime
		DoProgress(10)
		
		;** User Details
		$Silent = WriteLine (1, "User: " + @USERID + " Full Name: " + @FULLNAME + $CRLF);Write data to file
		$lblTask.Caption = $Blanker
		$lblTask.Caption = "User Name"
		Sleep $WaitTime
		DoProgress(10)
		
		;** IP 0
		$Silent = WriteLine (1, "IP: " + @IPAddress0 + $CRLF)  
		$lblTask.Caption = $Blanker
		$lblTask.Caption = "IP Address"
		Sleep $WaitTime
		DoProgress(15)
		
		$Silent = WriteLine (1, $CRLF) 
										
		$Silent = Close (1)                             
	EndIf
	Sleep 0.5
EndFunction

Function DoAntiVirus()
	$lblJob.Text = $Blanker
	$lblJob.Text = "Updating Antivirus... "
	$lblTask.Text = " CANNOT UPDATE ANTIVIRUS"
	$lblTask.Text = $Blanker
	DoProgress(10)
sleep 0.5
	EndFunction

Function Time()
	;======= Sync Time Local Time Server 
	$lblJob.Text = $Blanker
	$lblJob.Text = "Synchronizing time with SWGfL NTP (Time) Server "
	$lblTask.Text = $Blanker
	$lblTask.Text = " CANNOT PERFORM SYNC"
	DoProgress(15)
;	If Exist (@scriptdir+"\netlogon\TimeSync.bat")
;		Shell @scriptdir+"\netlogon\TimeSync.bat"
	
;	EndIf
sleep 1
EndFunction

Function Snd()
	$lblTask.Text = $Blanker
    $lblTask.Text = "Welcome to " + @WKSTA
	DoProgress(10)
    $fraMainLabel.Text = "Logon has been successful."	
	DoProgress(10)
    $lblJob.Text = $Blanker
	$lblJob.Text = ""
	Play @scriptdir + "logon.wav"


EndFunction

Function ExitScript()
	Quit()
EndFunction

;*****************
;** End of File **
;*****************



Still with the USE error. I was just wondering, why does it fail at the second drive mapping: L: ($DriveToMap = "\\sdc5400\mfl")


Edited by 04nunhucks (2007-01-27 12:15 PM)

Top
#173292 - 2007-01-27 01:42 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
place this:
? "USE L: " + $DriveToMap ? sleep 1
just before this line:
USE L: $DriveToMap

what it shows?
_________________________
!

download KiXnet

Top
#173293 - 2007-01-27 01:46 PM Re: Another login script: Error in Use Statement [Re: Lonkero]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Hi, Jooel, It shows the same error: error in USE statement on line 233
I added your piece of script to that line.

Also, a command line box appears and the only character in it is ")". The title bar of the box is wkix32.exe.

Top
#173294 - 2007-01-27 02:27 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Hi 04

The '.Caption' property is out dated and has been replaced with '.Text', You need to replace all of the '.Caption' properties with '.Text' in the entire script. (I count 30 occurrences)

Things to check on:
  • Access rights to the drive in question (can you map it manualy as the user you are running the script under)
  • KiXtart ver and KiXforms ver on the machine in question
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
Page 1 of 3 123>


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

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.079 seconds in which 0.026 seconds were spent on a total of 14 queries. Zlib compression enabled.

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