Question Locked

Windows Script, Using a variable in a command

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am new to scripting, can some let me know how to do this. I have a variable called username, but how do I make the create user line see username as a variable and not plain text

All this script does is create a user called username.

'Get username
Firstname = InputBox("Enter Firstname")
MsgBox ("You entered: " & Firstname)

LastName = InputBox("Enter LastName")
MsgBox ("You entered: " & LastName)

UserName = FirstName & "." & LastName
Msgbox ("Username is; " & UserName)

'Create user
Set objOU = GetObject("LDAP://ou=Corporate,dc=domain,dc=com")
Set objUser = objOU.Create("User", "cn=UserName")
objUser.Put "sAMAccountName", "UserName"
objUser.SetInfo

2 replies

by lowlands

Anything between quotes is seen as "plain text".

so in your case you'll need something like:


Set objUser = objOU.Create("User", "cn=" & UserName)
objUser.Put "sAMAccountName", UserName

Now you'll have to make sure all the quotes match up. This tends to get a little tricky.
Play with the strings and use Chr(34). It's the ASCII representation of a quote

This discussion is closed to new replies.