Mombu the Microsoft Forum

Mombu the Microsoft Forum > Microsoft > Windows 2003 Server (TECHNET) > set custom variables
REGISTER NOW! Mark Forums Read




Reply
 
Thread Tools Display Modes
1 3rd May 22:25
peter
External User
 
Posts: 1
Default set custom variables



I want to add some custome variables on a user base to my script.
I used to do this in batch with the following command:

if %username%==user1 set %station% "wrk01"
if %username%==user2 set %station% "wrk02"

greetings,

P.
  Reply With Quote
SPONSORED LINKS BY GOOGLE

 


2 3rd May 22:26
tom lavedas
External User
 
Posts: 1
Default set custom variables



if %username%==user1 set station=wrk01
if %username%==user2 set station=wrk02

But this is not a WSH related question. Better newsgroups for batch
related questions are alt.msdos.batch.nt or
microsoft.public.win2000.cmdprompt.admin

Tom Lavedas
==========
http://members.cox.net/tglbatch/wsh/
  Reply With Quote
3 3rd May 22:28
al dunbar
External User
 
Posts: 1
Default set custom variables


That was my first impression. Read his post again - that is how he has
already done it in batch (even though the code wasn't 100% correct), so I
suspect he is looking to do something similar using WSH.

Peter: give us a little more detail about your script, like what is its
primary purpose and how are is it being run.


/Al
  Reply With Quote
SPONSORED LINKS BY GOOGLE

 


4 15th July 21:22
tom lavedas
External User
 
Posts: 1
Default set custom variables


Opps. You're right, of course. I would then suggest he lookup the
Wscript.Shell object's Environment property.
  Reply With Quote
5 15th July 21:22
tdm
External User
 
Posts: 1
Default set custom variables


One possible way :

Dim objSH
Dim objENV

Set objSH = CreateObject("WScript.Shell")
Set objENV = objSH.Environment("SYSTEM")

Select Case LCase(objSH.ExpandEnvironmentStrings("%UserName%") )
Case "user1"
objENV("station") = "wrk01"
Case "user2"
objENV("station") = "wrk02"
End Select

Not sure if this is what you really want but it may help you along.

TDM
  Reply With Quote
6 15th July 21:22
peter
External User
 
Posts: 1
Default set custom variables


I'm setting up a login script.
The variable is used for starting up an dos program with this variable.

The following code doesn't do the trick:

Const WEEG_GROUP = "cn=Weeg"
Const PC_TIME_GROUP = "cn=PC-Time"
Const ULTIMO_GROUP = "cn=Ultimo"
Const ADMIN = "cn=administrators"

Set wshNetwork = CreateObject("WScript.Network")

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" &ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, WEEG_GROUP) Then

wshNetwork.MapNetworkDrive "f:","\\FS01-PROD-BLN\PRD\"

ElseIf InStr(strGroups, PC_TIME_GROUP) Then

wshNetwork.MapNetworkDrive "y:","\\172.16.16.244\atps"

ElseIf InStr(strGroups, ULTIMO_GROUP) Then

wshNetwork.MapNetworkDrive "x:","\\172.16.16.244\ultimo"

ElseIf InStr(strGroups, ADMIN) Then

wshNetwork.MapNetworkDrive "z:","\\fs02-kant-bln\c$"

End IF

Dim objSH
Dim objENV

Set objSH = CreateObject("WScript.Shell")
Set objENV = objSH.Environment("USER")


Select Case LCase(objSH.ExpandEnvironmentStrings("%UserName%") )
Case "administrator"
objENV("STATION") = "wrk01"
Case "user2"
objENV("STATION") = "wrk02"
End Select
  Reply With Quote
Reply


Thread Tools
Display Modes







Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
Also visit Ogoun the Usenet Archive
666