Page 1 of 1 1
Topic Options
#199740 - 2010-09-03 09:29 AM Problem Login Script + If ingroup
tomcoleman Offline
Just in Town

Registered: 2010-09-03
Posts: 4
Loc: London
I have created the below script but when i run it it runs but doesnt map and drives? I get the black dos box open and 3 0's come up so i presume it running the script ok but does nothing??

 Code:
 
;Thomas Coleman 
;Map drives used by all users
;User Drives

USE * /delete 
Use h: /delete /persistent
Use h: "\\pamplona-dfsfs2\users\%USERNAME%"


; You can set the default printer using the following command
; NB. When using the set default printer command it uses the Name of the printer on the server not
; the unc share name - these are not necessarily the same
; SetDefaultPrinter ("\\pamplona-dfsfs2\printershare")

; To delete a printer use the following command
; This also uses the printer name not the UNC path (even though it looks like a UNC path)
; DelPrinterConnection ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")

;To map drives based on user
If @userid = lady		
		Use x: "\\pamplona-dfsfs2\awiredu"  
		?"ERROR " + @ERROR + " - " + @SERROR
EndIf

; Map drive for administrator with Installation files
If InGroup("Administrators")
	Use s: /delete /persistent
	Use s: "\\PAMPLONA-DFSFS2\IT$"
EndIf

; Map drives and printers for users by group membership
If InGroup("Fund of Funds")
	Use j: /delete /persistent
	Use j: "\\pamplona-dfsfs2\fund of funds"
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\HP LaserJet 4350 FOF")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\HP3800 FOF Window Bay")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\1st_Floor-RICOH_MPC6000")
	SetDefaultPrinter ("\\pamplona-dfsfs2\1st_Floor-RICOH_MPC6000")
EndIf

If InGroup("PCO ALL")
	Use s: /delete /persistent
	Use y: /delete /persistent
	use s: "\\pamplona-dfsfs2\PCO Marketing"
	use y: "\\pamplona-dfsfs2\PCO Fund"
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\HP Color LaserJet 3800 PCO")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\1st_Floor-RICOH_MPC6000")
	
EndIf

If InGroup("Private Equity")
	Use p: /delete /persistent
	Use p: "\\pamplona-dfsfs2\private equity"
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
	SetDefaultPrinter ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf

If InGroup("IVA")
	Use i: /delete /persistent
	Use i: "\\sqlpco\iva"
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf

If InGroup("oakwood")
	Use o: /delete /persistent
	Use o: "\\sqlpco\oakwood"
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf

If InGroup("finance")
	Use f: /delete /persistent
	Use f: "\\pamplona-dfsfs2\finance"
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf

If InGroup("infrastructure")
	Use q: /delete /persistent
	Use q: "\\pamplona-dfsfs2\infrastructure"
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf



If InGroup("Reception")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	ADDPRINTERCONNECTION ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
	SetDefaultPrinter ("\\pamplona-dfsfs2\4th_Floor_Reception-HP_CP3525")
EndIf

If InGroup("Hedge Fund")
	Use z: /delete /persistent
	Use z: "\\pamplona-dfsfs2\hedge fund"
EndIf

If InGroup("General")
	Use g: /delete /persistent
	Use g: "\\pamplona-dfsfs2\General"
EndIf

If InGroup("HR")
	Use r: /delete /persistent
	Use r: "\\pamplona-dfsfs2\hr"
EndIf







Top
#199743 - 2010-09-03 10:27 AM Re: Problem Login Script + If ingroup [Re: tomcoleman]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You're not checking the error states on any of your operations, so you are never going to know if there is a problem - the zeros are a clue that something is working, and it is probably your AddPrinterConnection() functions.

USE is a command however, not a function. As such it doesn't return anything, so you won't get any positive feedback when something goes wrong.

Here is your script re-written so that you'll get messages if there is a problem. Most of the work now takes place in user defined functions, so if you want to change anything you only need to do it in one place.

The $__MESSAGELEVEL global variable is used to change the amount of information displayed - set it to "9" to get every message (very verbose), 7 will get you detail messages, 0 will give you only error and other important message, -1 will suppress all messages.

I've not fully tested the script, but it should get you going:
 Code:
;Thomas Coleman 
;Map drives used by all users
;User Drives

$=SetOption("Explicit","ON")

Global $__MESSAGELEVEL

$__MESSAGELEVEL=9	; ** Change this value to set the level of messages to display, "-1" suppresses all messages

; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; FUNCTION DEFINITION SECTION STARTS

; Message UDF - display a message on the console if allowed by message level
Function Message($sMessage,optional $iLevel)
	If $__MESSAGELEVEL>=CInt($iLevel) $sMessage EndIf
	Exit 0
EndFunction

; Map a drive, report errors
Function MapDrive($sLetter, $sUNC)
	Message("Mapping "+$sLetter+" to "+$sUNC+@CRLF, 7)
	Use $sLetter /delete /persistent
	Use $sLetter $sUNC
	$MapDrive=@ERROR
	If @ERROR
		Message("ERROR: Failed to map "+$sLetter+" to "+$sUNC+@CRLF+"   Reason: ["+@ERROR+"] "+@SERROR+@CRLF)
	Else
		Message("   Drive mapped OK",9)
	EndIf
	Exit $MapDrive
EndFunction

; Map a printer, report errors
Function MapPrinter($sPrinter)
	Message("Connecting printer "+$sPrinter+@CRLF, 7)
	$MapPrinter=AddPrinterConnection($sPrinter)
	If @ERROR
		Message("ERROR: Failed to connect printer "+$sPrinter+@CRLF+"   Reason: ["+@ERROR+"] "+@SERROR+@CRLF)
	Else
		Message("   Printer connected OK",9)
	EndIf
	Exit $MapPrinter
EndFunction

; FUNCTION DEFINITION SECTION ENDS
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Dim $sGroup

USE * /delete 
$=MapDrive("h:","\\pamplona-dfsfs2\users\"+%USERNAME%)

; You can set the default printer using the following command
; NB. When using the set default printer command it uses the Name of the printer on the server not
; the unc share name - these are not necessarily the same
; SetDefaultPrinter ("\\pamplona-dfsfs2\printershare")

; To delete a printer use the following command
; This also uses the printer name not the UNC path (even though it looks like a UNC path)
; DelPrinterConnection ("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")

;To map drives based on user
If @userid = "lady"		
		$=MapDrive("x:","\\pamplona-dfsfs2\awiredu"  )
EndIf

; Map drive for administrator with Installation files
$sGroup="Administrators"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("s:","\\PAMPLONA-DFSFS2\IT$")
EndIf

; Map drives and printers for users by group membership
$sGroup="Fund of Funds"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("j:","\\pamplona-dfsfs2\fund of funds")
	MapPrinter("\\pamplona-dfsfs2\HP LaserJet 4350 FOF")
	MapPrinter("\\pamplona-dfsfs2\HP3800 FOF Window Bay")
	MapPrinter("\\pamplona-dfsfs2\1st_Floor-RICOH_MPC6000")
	$=SetDefaultPrinter("\\pamplona-dfsfs2\1st_Floor-RICOH_MPC6000")
EndIf

$sGroup="PCO ALL"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("s:","\\pamplona-dfsfs2\PCO Marketing")
	$=MapDrive("y:","\\pamplona-dfsfs2\PCO Fund")
	MapPrinter("\\pamplona-dfsfs2\HP Color LaserJet 3800 PCO")
	MapPrinter("\\pamplona-dfsfs2\1st_Floor-RICOH_MPC6000")
	
EndIf

$sGroup="Private Equity"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("p:","\\pamplona-dfsfs2\private equity")
	MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
	$=SetDefaultPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf

$sGroup="IVA"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("i:","\\sqlpco\iva")
	MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf

$sGroup="oakwood"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("o:","\\sqlpco\oakwood")
	MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf

$sGroup="finance"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("f:","\\pamplona-dfsfs2\finance")
	MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf

$sGroup="infrastructure"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("q:","\\pamplona-dfsfs2\infrastructure")
	MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
EndIf



$sGroup="Reception"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	MapPrinter("\\pamplona-dfsfs2\4th_floor-PE-HP_4300_B&W")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-PE -Colour_HP4005")
	MapPrinter("\\pamplona-dfsfs2\4th_Floor-RICOH_Copier")
	$=SetDefaultPrinter("\\pamplona-dfsfs2\4th_Floor_Reception-HP_CP3525")
EndIf

$sGroup="Hedge Fund"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("z:","\\pamplona-dfsfs2\hedge fund")
EndIf

$sGroup="General"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("g:","\\pamplona-dfsfs2\General")
EndIf

$sGroup="HR"
If InGroup($sGroup)
	Message("This user is a member of '"+$sGroup+"'"+@CRLF,7)
	$=MapDrive("r:","\\pamplona-dfsfs2\hr")
EndIf

Top
#199744 - 2010-09-03 10:54 AM Re: Problem Login Script + If ingroup [Re: Richard H.]
tomcoleman Offline
Just in Town

Registered: 2010-09-03
Posts: 4
Loc: London
i have run this script again only get 000 and it doesnt do anything?!

i have my login .bat set as
 Code:
  
@ECHO OFF
%0\..\Kix32.exe %logonserver%\netlogon\pamplona.kix
pause


which then comes up with DOS box and says


\\pamplona01\netlogon
CME.exe was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows Directory
000


Edited by tomcoleman (2010-09-03 11:01 AM)

Top
#199750 - 2010-09-03 01:10 PM Re: Problem Login Script + If ingroup [Re: tomcoleman]
tomcoleman Offline
Just in Town

Registered: 2010-09-03
Posts: 4
Loc: London
bump
Top
#199766 - 2010-09-03 05:18 PM Re: Problem Login Script + If ingroup [Re: tomcoleman]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
What version of KiXtart are you using?

Unless you have changed $__MESSAGELEVEL to 0 you should be getting a number of messages.

Check your replication is OK, and try running the script interactively from a DOS prompt.

Top
#199767 - 2010-09-04 11:56 AM Re: Problem Login Script + If ingroup [Re: Richard H.]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
decided to jump in too. with Richard's version that output just ain't possible.
hence, for some reason you are still running the old version of the script.
_________________________
!

download KiXnet

Top
#199780 - 2010-09-06 10:40 AM Re: Problem Login Script + If ingroup [Re: Lonkero]
tomcoleman Offline
Just in Town

Registered: 2010-09-03
Posts: 4
Loc: London
i'm on 4.61.0.0 ?
Top
#199781 - 2010-09-06 11:00 AM Re: Problem Login Script + If ingroup [Re: tomcoleman]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
That's fine, just wanted to make sure that you had UDF support.

The script as provided will output diagnostic information to the console window. If you are not seeing the disgnostic text you are not running the (new) script.

Try launching the script from an interactive prompt to see what I mean.

Top
#199858 - 2010-09-14 02:54 PM Re: Problem Login Script + If ingroup [Re: Richard H.]
Razer Offline
Fresh Scripter
*

Registered: 2010-09-03
Posts: 8
not easy solutions.
_________________________
Signature removed by admin

Top
#199864 - 2010-09-14 06:20 PM Re: Problem Login Script + If ingroup [Re: Razer]
dpres001 Offline
Just in Town

Registered: 2010-09-14
Posts: 2
Loc: USA
can you try changing your login.bat to this?

@ECHO OFF
%0\..\Kix32.exe %0\..\pamplona.kix
pause

I had a similar issue and this resolved it for me.

Top
#199865 - 2010-09-14 06:37 PM Re: Problem Login Script + If ingroup [Re: dpres001]
dpres001 Offline
Just in Town

Registered: 2010-09-14
Posts: 2
Loc: USA
That is....if your kix32.exe and pamplona.kix file are in the same directory?
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 196 anonymous users online.
Newest Members
SERoyalty, mytar, Gabriel, Alex_Evos, Dansen
17869 Registered Users

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