Sign in to follow this  
Followers 0
jefhal

Pass argument to vbscript

7 posts in this topic

My AutoIT script runs as a shell script within an Active Directory custom console. It picks up the system name, the mac ids, the express service code(Dell), and the service tag(Dell) and puts them into the Active Directory Computer description field.

Right now it runs semi-automatically through AutoIT. That is, after generating the description, it pastes it into the "description" field by sending the contents of the clipboard. I'd like to make this happen through ADSI though. That means I have to pass the description to the vbs script. If the vbs script looks like this:

On Error Resume Next
Wscript.StdOut.Write "Please enter the name of the computer you want to connect to: "
strComputer = WScript.StdIn.ReadLine
If strComputer = "" Then
    Wscript.Quit
End If
Set objComputer = GetObject("WinNT://" & strComputer & "")
objComputer.Filter = Array("User")
For Each objUser in objComputer
    Wscript.Echo objUser.Name
Next
' End

How would I pass the AutoIT variable $description into the vbs script? The vbs script is expecting a command line that looks like this:

c:>MyVBScript.vbs $description

Should I use StdINWrite? I can't figure this out based on the helpfile example. Thank you!


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites



try running "whatever program actually executes .vbs extension""C:\MyVBScript.vbs""desc..."

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

are you just enumerating the users with the vbs script? you could easily do that with autoit

I may completely be off though.

EDIT:

Oh, I dont know much about passing variables. I will play around with it and see if i can help though.

Edited by Wus

Share this post


Link to post
Share on other sites

are you just enumerating the users with the vbs script? you could easily do that with autoit

I may completely be off though.

<{POST_SNAPBACK}>

I'm using this script to create computer descriptions, although that was not clear from the code snippet I showed (that was to show how to bring data into vbs using stdin).

For example, we have an "OU" called "Main Office" that contains 4 computers (comp100, comp101, comp102...). I select one of the computer names and press the Active Directory custom task button to run my AutoIT script. The script gets the computer name (comp100) from the built-in Active Directory variables, and then gets the Dell service tag, the Dell express service code, the mac id for the wired nic, and the mac id for the wireless nic. It then concatenates the strings into a "description" which I put into the AutoIT variable: $description. It looks like: ~ 5928v31 ~ 1892486732 ~ 00-0a-bc-de-f9-d2 ~ 00-2c-59-ab-bc-de ~

I now want to send the contents of $description into a command line that runs a vbs to modify the Active Directory description field for that computer. Whew! Everything is done except the part where I feed $description into the vbs script. In the script will be something like: "objUser.Description = $description", etc.


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Hi,

I don't know the answer to your question; can't you just use an "ini" file write and read that; [ if on same computer; or even registry read/write?]

At least as a workaround if you prefer the other?

Randall

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

How would I pass the AutoIT variable $description into the vb script:

set args=wscript.arguments
description = args(0)
Wscript.Echo description

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

AU3:

$description = "whatever"; 
$scriptpath = "C:\MyVBScript.vbs"
$scriptparam = $description
RunWait($scriptpath & " " & $scriptparam)
Dear IceKirby1, /dev/null and all-

Thanks again for reminding me of the subtleties of code writing. The answer was right under my nose and you pointed it out to me. I was trying to make it more complicated than necessary...


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0