Question about scripting

BZeto

Platinum Member
Apr 28, 2002
2,428
0
76
Say for example I have a script to set a specific user account expiration date in active directory. Only i don't wan't the expiration date to be the same each time I run the script and I don't want to manually edit the script to change the expiration date.

How difficult would it be to write some sort of tool with a blank field I can type the date into and then it automatically plugs that into my script and runs it?

Thanks
 

Jamsan

Senior member
Sep 21, 2003
795
0
76
Assuming it's vbscript, there should be a section of code that sets a variable to a specific date which is later used during the setting of the expiration date. Look for where that variable is set, and instead of hard coding the value, change it to the following:

variable = InputBox("Enter Expiration Date", "Prompt", , 200, 200)

The first parameter is the text in the message box, second is the title of the msg box, third is blank, 4th is the width and 5th is the height.
 

BZeto

Platinum Member
Apr 28, 2002
2,428
0
76
Hmm, well here is my exact code:

Set objUser = GetObject _
("LDAP://cn=testaccount,dc=domain,dc=com")

objUser.AccountExpirationDate = "02/11/2009"
objUser.SetInfo


So I could put your line of code in place of my date? I'm not sure I really understand the variable thing.
 

jlazzaro

Golden Member
May 6, 2004
1,743
0
0
variable is simply assigned whatever string you entered in the InputBox. not sure how picky the formatting is, but you probably want to do some syntax checking as well. this should include blank variable strings and misformatted dates...
 

Jamsan

Senior member
Sep 21, 2003
795
0
76
As jlazzaro said, the variable is just a temporary holding spot for a value which can later be used. It's not necessary in your script. Change the script to read the following:

Set objUser = GetObject _
("LDAP://cn=testaccount,dc=domain,dc=com")

objUser.AccountExpirationDate = InputBox("Enter Expiration Date", "Prompt", , 200, 200)
objUser.SetInfo


If someone other than you will be using the script, I would recommend the checks as well, but if only you will be using it, and you trust yourself enough to not screw up the date format, you'll be fine without it.