#179414 - 2007-08-17 08:07 AM
Hyphen problem - Help
|
ping82
Lurker
Registered: 2007-08-17
Posts: 3
|
Hello,
I have some problem with the hyphen. I am trying to use the macro @wuserid If the windows user id is without hypen it works perfectly fine. If the userid contains hyphen, it does not work, giving error LABEL [<label>] not found!
a similar example below does not work as well ---- goto mytest-av '<-Have tried added in "mytest-av" goto end
:mytest-av 'added quotation mark, still not work "testing"
:end -----
I tried to add the double quotation to the userid label(eg. :"abc-d") but it does not work. Please help. Below is my script algorithm.
--------- goto @wuserid .. .. ..
:abc .. goto end
:abc-d .. .. goto end
:end
|
|
Top
|
|
|
|
#179419 - 2007-08-17 09:01 AM
Re: Hyphen problem - Help
[Re: Arend_]
|
ping82
Lurker
Registered: 2007-08-17
Posts: 3
|
Hi,
I will need to change some registry entry based on each windows username.
Is there an alternate way to do this? Is there a function to remove the hyphen? i.e - user abc-d become abcd, user df-erfg becomes dferfg
Thanks.
Edited by ping82 (2007-08-17 09:03 AM)
|
|
Top
|
|
|
|
#179420 - 2007-08-17 09:18 AM
Re: Hyphen problem - Help
[Re: ping82]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
"a-a" --> "aa"
BREAK ON
Join(Split("a-a","-"),"") ?
Get $
|
|
Top
|
|
|
|
#179422 - 2007-08-17 09:27 AM
Re: Hyphen problem - Help
[Re: ping82]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Is there a function to remove the hyphen
Yes, but I'd still advise that you don't use GoTo.
Better to use something like Select:
Select
Case @WUSERID="userA"
; Update Registry here
Case @WUSERID="anotheruser"
; Update regsitry here
Case @WUSERID="bill" OR @WUSERID="ben" OR @WUSERID="weed-little"
; Update registry here
EndSelect
Better still if there are common settings among the users is to use a parameter (INI) file. Read a profile from the parameter file and only set the registry if it is true.
To do this, create an INI file on your netlogon share that looks like this:
[userA] Office=1 RemoteUser=0 DevTeam=0 [Bill] Office=1 RemoteUser=0 DevTeam=1
Now in your script you can do this:
$sUserProfile=@LSERVER+"\netlogon\PARAMETER.INI"
If ReadProfileString($sUserProfile,@WUSERID,"Office")
; Do Office reg settings
EndIf
If ReadProfileString($sUserProfile,@WUSERID,"RemoteUser")
; Special login coding for remote users
EndIf
If ReadProfileString($sUserProfile,@WUSERID,"DevTeam")
; Install development tools for DevTeam members
EndIf
Still better again, use AD groups rather than the INI file.
If InGroup("Office Users")
; Do Office reg settings
EndIf
If InGroup("Remote Users")
; Special login coding for remote users
EndIf
If InGroup("Engineering Dev Team", "Accounting Dev Team", "Sales Dev Team")
; Install development tools for DevTeam members
EndIf
Finally, if you must use dodgy GoTo the simplest way to remove the hyphen is to use the Join(Split()) replace trick:
GoTo Join(Split(@WUSERID,"-"),"")
|
|
Top
|
|
|
|
#179424 - 2007-08-17 09:59 AM
Re: Hyphen problem - Help
[Re: Witto]
|
ping82
Lurker
Registered: 2007-08-17
Posts: 3
|
Hi All,
Thanks. That solves the problem.
Since it is for individual users, I will just use the Select statement.
:-)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2333 anonymous users online.
|
|
|