Torgeir
Mon Feb 09 19:26:46 CST 2004
Kevin wrote:
> Many example code pages in the scripting centre contain line like the following:
>
> Set objUser = GetObject ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
>
> Is there a way to pass the user name into the script at the time of running? You don't want to have to edit the code for each new user.
Hi
You can e.g. use the WScript.Arguments property to support command
line input for your script, here is an example:
Set objArgs = WScript.Arguments
If objArgs.Count <> 1 Then
WScript.Echo "Wrong number of arguments! You need to supply the user name."
WScript.Quit
End If
strUser = objArgs(0)
Set objUser = GetObject ("LDAP://cn=" & strUser _
& ",ou=management,dc=fabrikam,dc=com")
WSH 5.6 documentation (local help file) can be downloaded from here if you
haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter