ucthakur-NOSPAM
Fri Mar 17 12:46:27 CST 2006
Pass the argument to VBS file by changing this line:
> cscript /nologo pwdset.vbs
to:
cscript /nologo pwdset.vbs %1
this will send the value of %1 as argument to VBS file. In VBS file, you
need to read the value of this argument and substitute it in your GetObject
call. your VBS willl then look like this:
set wsArgs = wscript.arguments 'Wscript Arguments collection
if wsArgs.count <> 1 then
wscript.echo "No user name specified."
wscript.quit 'end script.
end if
'wscript.echo "LDAP://cn=" & wsArgs(0) & ",ou=Users,dc=domain,dc=com"
set oUser = GetObject("LDAP://cn=" & wsArgs(0) & ",ou=Users,dc=domain,dc=com")
oUser.Put "pwdLastSet", CLng(-1)
oUser.Setinfo
2nd option - if you want it all in VBS.
-------------------------------------
dim fso
set fso = createObject("scripting.filesystemObject")
set ts = fso.openTextFile("c:\newacct\exp.txt")
while not ts.atEndOfStream
strUser = ts.readLine
strLDAP = "LDAP://cn=" & strUser & ",ou=Users,dc=domain,dc=com"
wscript.echo strLDAP 'to verify that data is read correctly from file
set oUser = GetObject(strLDAP)
oUser.Put "pwdLastSet", CLng(-1)
oUser.Setinfo
wend
ts.close
You can learn more about VBScripting at Microsoft Technet Script Center
http://www.microsoft.com/technet/scriptcenter/topics/beginner/firststeps.mspx
http://www.microsoft.com/technet/scriptcenter/resources/begin/default.mspx
http://www.microsoft.com/technet/scriptcenter/default.mspx
-----
Umesh
"Old programmers never die. They just terminate and stay resident."
"rwh@rodharrison.com" wrote:
> I need to pass a %1 variable from a batch/DOS script into my vbs
> script. Here's what I tried but it doesn't work.
>
> BATCH FILE*******************
> @echo on
> for /f "Tokens=1" %%i in (c:\newacct\exp.txt) do call :parse %%i
> goto end
> :parse
> cscript /nologo pwdset.vbs
> :end
>
> VBS SCRIPT***************************************
> set oUser = GetObject("LDAP://cn=%1,ou=Users,dc=domain,dc=com")
> oUser.Put "pwdLastSet", CLng(-1)
> oUser.Setinfo
> '
>
> ******************************************************************************************
> Basically I have a flat text file with 1 entry per line of the user
> ID's I need to reset the pwdlastset value to a -1. So I am parsing the
> entries from that file with DOS and trying to pass that value into the
> VBS script.
> Can I do this all in VBS? If so can someone write the script that would
> use the file ref'd in my above DOS script for a VBS script?
>
> Much thanks!!!!
>
>