Page 1 of 1 1
Topic Options
#198098 - 2010-03-19 03:36 PM Drive Mapping Friendly Names
Aten Offline
Just in Town

Registered: 2010-03-19
Posts: 4
Loc: London
Hello,

Could someone please point me in the right direction if I am using a KIX script to map a network drive bases on Group membership how can I change the name to something else of the drive thus removing the servername etc

So if my script was:

if ingroup "Remote users"
net use x: "\\myserver\remote"

I do not want the drive to show as \\myserver\remote but something different such as Your Drive

Thanks in Advance

Top
#198099 - 2010-03-19 03:47 PM Re: Drive Mapping Friendly Names [Re: Aten]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Welcome to the board.

Your Ingroup statement is a bit wrong as is you use statement. Net Use is Batch scripting. Kix uses just the plain Use command. Ingroup is a function so it requires parentheses.
Have a look at the script below.
It checks for group membership, deletes the drive, maps the drive and sets a name for the drive. Sure you could do much more like checking if the drive exists and see it it points to the correct path. The script below is a basic drive mapping script. If you need any help please post your questions.

 Code:
If InGroup("Remote users")
	Use x: /delete /persistent
	Use x: "\\myserver\remote"
	Label('x:\','my fancy new name')
EndIf


;DO NOT MODIFY ANYTHING BELOW THIS LINE.
;BELOW IS A UDF AND IT COME SREADY FOR USE.
;
;FUNCTION	Label()
;
;AUTHOR		Lonkero
;
;ACTION		Read and Write Drive Label
;
;SYNTAX		Label("DRIVE","LABEL")
;
;PARAMETERS
;		DRIVE
;		 - drive to rename
;		LABEL
;		 - new name of the drive
;		   to read the label, leave out
;
;RETURNS
;		nothing on write.
;		on read the current label.
;		check @error for possible errors
;
;DEPENDENCIES
;		Minimum operating systems: Windows 2000/ME
;
;EXAMPLE
;		"Current Label for C: is:"
;		Label('c:')
;		? "Changing it..."
;		Label('c:\','my fancy new name')
;		if @error
;		 ? "ERROR OCCURED:" @serror
;		else
;		 ? "New Label for C: is:"
;		 Label('c:')
;		endif
;
;CODE
Function label($_d,optional $_s)
 $=CreateObject("shell.application")
 If VarType($_s)
  $.namespace(Left($_d,1)+":\").self.name=$_s
  Exit @error
 Else
  $label = $.namespace(Left($_d,1)+":\").self.name
  Exit @error
 EndIf
EndFunction
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#198102 - 2010-03-19 04:37 PM Re: Drive Mapping Friendly Names [Re: Mart]
Aten Offline
Just in Town

Registered: 2010-03-19
Posts: 4
Loc: London
Hi Mart,

DOH yes i meant use as opposed to net use thank you that is exactly what I was looking for

Top
#198141 - 2010-03-23 05:47 PM Re: Drive Mapping Friendly Names [Re: Mart]
Aten Offline
Just in Town

Registered: 2010-03-19
Posts: 4
Loc: London
Hi Mart,

It does not seem to work below is my login script please could you tell me of any errors you could spot and exactly etc I have removed the Label and modified domain names and paths it works without label but not with it I have placed this syntax Label('x:\','my fancy new name') after use x: any ideas?

 Code:
;*****************************************************
;*                                                               *
;*          LOGON DRIVE MAPPINGS             *
;* 	            MYCOMPANY                    *
;*****************************************************


;*****************************************************
;*  MYCOMPANY USER DRIVE MAPPINGS       *
;*****************************************************
Cls
  Color g+/n
  Box (2,6,9,65,Double)
  Color w+/n
  AT ( 4,8) "WELCOME TO THE MYCOMPANY NETWORK"
  AT ( 7,13) "Connecting Network Resources, Please Wait....."
;	DEPARTMENTS
;	***********

; Mappings for all users

IF Ingroup("Domain Users")
	
	use U: "\\MYDOMAIN.LOCAL\USERS\%username%$"
	MD "U:\Favorites"
	WRITEVALUE ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Favorites","U:\Favorites","REG_EXPAND_SZ")
ENDIF



IF Ingroup ("DRIVE 7")
	use A: "\\MYDOMAIN.LOCAL\DRIVE7"
ENDIF

If Ingroup ("DRIVE 6")
	use J: "\\MYDOMAIN.LOCAL\DRIVE6"
ENDIF

If Ingroup ("IT DRIVE")
	use I: "\\MYDOMAIN.LOCAL\IT$"
ENDIF

If Ingroup ("DRIVE 5")
	use L: "\\MYDOMAIN.LOCAL\MYCOMPANY"
ENDIF

If Ingroup ("DRIVE 4")
	use M: "\\MYDOMAIN.LOCAL\PLUS"
ENDIF

If Ingroup ("DRIVE 3")
	use N: "\\MYDOMAIN.LOCAL\DRIVE4"
ENDIF

If Ingroup ("DRIVE 2")
	use O: "\\MYDOMAIN.LOCAL\PLUS1"
ENDIF

If Ingroup ("DOMAIN USERS")
        use S: "\\MYDOMAIN.LOCAL\SCANNER"
ENDIF

If Ingroup ("DOMAIN USERS")
        use P: "\\MYDOMAIN.LOCAL\PUBLIC"
ENDIF

If Ingroup ("DRIVE 1")
        use T: "\\MYDOMAIN.LOCAL\PLUS2"
ENDIF

If Ingroup ("FTP")
	use V: "\\MYDOMAIN.LOCAL\FTP"
ENDIF

If Ingroup ("MYCOMPANY RESEARCH")
	use W: "\\MYDOMAIN.LOCAL\MYCOMPANY RESEARCH"

ENDIF

exit


Edited by Mart (2010-03-23 05:59 PM)
Edit Reason: Added code tags.

Top
#198144 - 2010-03-23 05:54 PM Re: Drive Mapping Friendly Names [Re: Aten]
Aten Offline
Just in Town

Registered: 2010-03-19
Posts: 4
Loc: London
Ok I am getting error "unknown label" so it looks like it does not know what label is do I need to add to my script the part DO NOT MODIFY ANYTHING BELOW THIS LINE. ;BELOW IS A UDF AND IT COME SREADY FOR USE. at the bottom of my script can I not just use a one line syntax? such as use x: something alone the lines of label x: "my drive"
Top
#198145 - 2010-03-23 05:58 PM Re: Drive Mapping Friendly Names [Re: Aten]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: Aten

....
do I need to add to my script the part DO NOT MODIFY ANYTHING BELOW THIS LINE. ;BELOW IS A UDF AND IT COME SREADY FOR USE. at the bottom of my script
....


Yes.
Label is a UDF (User Defined Function). It is not build in in Kixtart so you need to add that part to the bottom of your script. You can put it at the top but to keep things readable I always put it at the bottom or put it in a separate file and call it from the main script.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#198685 - 2010-05-20 07:30 PM Re: Drive Mapping Friendly Names [Re: Mart]
Ooter Offline
Fresh Scripter

Registered: 2010-05-20
Posts: 15
Loc: Sacramento, CA
I am using this "label" script. The issue I am having is drives are randomly not being labeled. My best bet is the drive is being labeled before the drive is fully mapped. Since the drive doesn't exist yet, the label doesn't rename the mapped drive. Is there a way to make the label loop or to not execute until the drive is mapped?
Top
#198687 - 2010-05-21 01:12 AM Re: Drive Mapping Friendly Names [Re: Ooter]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands

How about this?

 Code:

Use x: "\\server\share"
While Not Exist("x:\")
	Sleep 1
Loop
;Label script goes here 
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#198696 - 2010-05-21 10:25 AM Re: Drive Mapping Friendly Names [Re: Mart]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Ick - permanent loops bad.

 Code:
$iInterval=0.1  ; Check for presence every 10th of a second
$iMaxWait=10.0	; Don't wait any more than 10 seconds

Use x: "\\server\share"
While @ERROR=0 AND Not Exist("x:\") AND $iMaxWait>0
    Sleep $iInterval
    $iMaxWait=$iMaxWait-$iInterVal
Loop

If Exist("x:\")
	;Label script goes here
EndIf

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
1 registered (Allen) and 581 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

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

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