Page 3 of 3 <123
Topic Options
#173315 - 2007-01-27 05:38 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Kixtart can generate syntax errors in weird and wonderfull ways - missing quotes, parens mismatched block structures and other even harder to find things. All i'm saying is - fix the END IF thing, re-test and re-post and then we can move on to the next potential issue.

-Shawn

Top
#173316 - 2007-01-27 06:07 PM Re: Another login script: Error in Use Statement [Re: Shawn]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Ok, I have fixed the END IF occurances:

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

;**************************
;** Dim some global vars **
;**************************
Dim $frmForm
Dim $fraBanner, $fraForm 
;Dim $prgProgress 
Dim $Hour

;**************************
;** Set some global vars **
;**************************
$strVersion = "V.4.2.09"
$LSD = @LServer + "\netlogon"
$WaitTime = 1			;** Time to wait after each task
$Blanker = "                                  "	;** Blank texts  

;******************
;**  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 = 14
$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 = 8
$fraBanner.ForeColor = $frmForm.RGB(0,0,0)
$fraBanner.PrintXY (10,24,$strVersion +"   Powered by NetCare Engine (Shamil Nunhuck) ")
$fraBanner.FontSize = 9
$fraBanner.PrintXY (10,35,"@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(255,255,255)
$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.Top = 100
$lblJob.Width = 440 ;fraMain.Width - 20
$lblJob.Left = 10

$lblTask = $fraMain.Controls.Add("label")
$lblTask.FontSize = 10
$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 @fullname (@priv)"
Else 
	If $Hour < 17
		$Greeting = "Good Afternoon @fullname (@priv) "
	Else
		$Greeting = "Good Evening @fullname (@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(255,255,255)
$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
MapDrivesGroups()
MapDrivesCommon()
DoAudit()
LogUser()                                                       
DoAntiVirus()
Time()
Snd()

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

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

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

Function CheckDLL()
	;*************************************************
	;** Check that KIXFORMS.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								;** KixForms not registered
														;** Copy .DLL
		$SourceFile = @LServer + "\netlogon\kixforms.dll"
		$Value = ReadValue("HKLM\System\CurrentControlset\Control\Windows", "SystemDirectory") 
		$Destination = ExpandEnvironmentVars($Value) 
		Copy $SourceFile $Destination
														;** Register .DLL silently
		$CMDLine = "regsvr32 /s " + $Destination + "\kixforms.dll"
		$ObjShell = CreateObject("WScript.Shell")
		$ObjShell.run($CMDLine, 1, true)
														;** Kill shell object
		$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 MapDrivesGroups()
	$lblJob.Text = $Blanker
	$lblJob.Text = "Mapping Network Drives... "
	
	;Use * /DELETE



	Sleep $WaitTime
	DoProgress(5)

	
IF INGROUP("Staff")	
		
$DriveToMap = "\\rdc5400\students"
		$lblTask.Text = $DriveToMap
		USE W: $DriveToMap							;** Map W: to Students Share
		DoProgress(5)

		$DriveToMap = "\\sdc5400\shared"
		$lblTask.text = $DriveToMap
		USE O: $DriveToMap							;** Map O: to Old Work Area
		DoProgress(5)
EndIF

IF INGROUP("Domain Admins")
	
    	$DriveToMap = "\\rdc5400\NetAdmin"
		$lblTask.text = $DriveToMap
		USE N: $DriveToMap							;** Map P: to pcapps Share
		DoProgress(5)
	    
		$DriveToMap = "\\rdc5400\Menus"
		$lblTask.text = $DriveToMap
		USE M: $DriveToMap							;** Map R: to sharedres Share
	    DoProgress(5)
EndIF
		IF INGROUP("SIMSUsers")		
		
		$DriveToMap = @LServer + "\Simsarea"														
		$lblTask.text = $DriveToMap											
		USE S: $DriveToMap	
EndIF	

EndFunction


Function MapDrivesCommon()
;******* Common Mappings- Everyone get these***********************	
	$DriveToMap = @HomeShr 
	$lblTask.text = $DriveToMap
	USE U: @HomeShr						    ;** Map U: to HomeDir Share
    DoProgress(5)

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

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

	$DriveToMap = "\\sdc5400\pcapps"
	$lblTask.text = $DriveToMap			
	USE P: $DriveToMap						;** Map T: to PcApps Share
DoProgress(5)

	$DriveToMap = "\\sdc5400\cdroms"
	$lblTask.text = $DriveToMap
	USE V: $DriveToMap					    ;** Map V: to CDRoms Share
	DoProgress(5)
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(20)
	
	$lblTask.Text = $Blanker
	$lblTask.Text = "Software"
	Sleep $WaitTime
	DoProgress(20)
EndFunction
Function LogUser()
	$lblJob.text = $Blanker
	$lblJob.text = "Collecting Logon Info... "
	DoProgress(10)
	
	;** Dim some vars
	$LogFolder = @LServer + "\netlogon\logs\"			
	
	;** Path to log dir
	$FileName = @MONTH + "--"+ "log.htm"		

	;** 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.text = $Blanker
		$lblTask.text = "Time and Date"
		Sleep $WaitTime
		DoProgress(10)
		
		;** User Details
		$Silent = WriteLine (1, "User: " + @USERID + " Full Name: " + @FULLNAME + $CRLF);Write data to file
		$lblTask.text = $Blanker
		$lblTask.text = "User Name"
		Sleep $WaitTime
		DoProgress(15)
		
		;** IP 0
		$Silent = WriteLine (1, "IP: " + @IPAddress0 + $CRLF)  
		$lblTask.text = $Blanker
		$lblTask.text = "IP Address"
		Sleep $WaitTime
		DoProgress(15)
		
		$Silent = WriteLine (1, $CRLF) 
										
		$Silent = Close (1)                             ;Close file
	EndIf
	Sleep 0.5
EndFunction

Function DoAntiVirus()
	$lblJob.Text = $Blanker
	$lblJob.Text = "Updating Antivirus... "
	
	$lblTask.Text = $Blanker
	
	DoProgress(10)
EndFunction

Function Time()
	;======= Sync Time Local Time Server 
	$lblJob.Text = $Blanker
	$lblJob.Text = "Synchronizing time "
	$lblTask.Text = $Blanker
	$lblTask.Text = "Synchronizing with SWGfL NTP (Time) Server"
	DoProgress(25)
	If Exist (@scriptdir+"TimeSync.bat")
		Shell @scriptdir+"TimeSync.bat"
		
	EndIf
EndFunction

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

DoProgress(5)
EndFunction

Function ExitScript()
	Quit()
EndFunction

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


Top
#173317 - 2007-01-27 06:23 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
So I assume your getting the exact same error on the exact same line ?

-Shawn

Top
#173318 - 2007-01-27 06:31 PM Re: Another login script: Error in Use Statement [Re: Shawn]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
It is the exact same error but on a different line. However, the same code is on this line. This does not make any sense of why there is a USE error?
Top
#173319 - 2007-01-27 07:15 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
What happens if you comment-out this line (a few lines before):

USE U: @HomeShr

Top
#173320 - 2007-01-27 07:16 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I see in the script:
USE U: @HomeShr

You are mixing technologies. If you are defining @HomeShr in the users' profile, you should not try to do it in the script. Remove it from the profile and build out the path instead.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#173321 - 2007-01-27 07:36 PM Re: Another login script: Error in Use Statement [Re: Les]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Aha, it seems to work now. Thank you. It is very much appreciated.
Top
#173322 - 2007-01-27 07:42 PM Re: Another login script: Error in Use Statement [Re: 04nunhucks]
Glenn Barnas Administrator Online   content
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4291
Loc: New Jersey
Are you defining SHARE permissions? (or has someone else defined them?)

In an AD/Domain environment, the share should be Authenticated Users / Full Control, and actual permissions assigned from the NTFS level. This assumes you have no Wintendo clients or workgroups, which might rely on share perms.

Combining NTFS and Share permissions is a black art, that, practiced indiscriminately will lead to the most bizzare results.

BTW - on 2K3 systems, only Admins have FC perms, and Everyone has Read perms on shares. You MUST change the share perms if you expect any non-admins to actually be able to write to shares.

Just something else to check...

Also, many of your comments seem to come AFTER the code they describe - just seems odd..

Finally, declaring vars is not $X=4, but "DIM $X". A suggestion for code that will be supported by others, or will become complex and difficult to remember what you did in 6 months is to declare vars 1 per line, and add a comment to describe what it is for. Temp vars can be clumped together, sorta like this:
Code:
Dim $IFile      ; Input file name
Dim $OFile      ; Output file name
Dim $I,$J,$K    ; index pointers for loops/arrays
Dim $           ; var to catch and ignore result codes


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

Top
#173323 - 2007-01-27 08:02 PM Re: Another login script: Error in Use Statement [Re: Glenn Barnas]
04nunhucks Offline
Getting the hang of it

Registered: 2006-09-08
Posts: 66
Hi Glenn, thanks for telling me that. I did not actually know what the previous technician did but I can kinda guess. I will definately write in comments. It will make life a lot easier

I would like to say thank you to the KiXtart community for helping me to resolve the issue.

Top
Page 3 of 3 <123


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

Who's Online
0 registered and 59 anonymous users online.
Newest Members
diefnet, Arogya, gkustra, emnipetro, Hirze
17644 Registered Users

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