Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running dsquery in a vbscript using variables

Status
Not open for further replies.

tazmaniandevil

Technical User
Nov 19, 2002
14
0
0
GB
Hi

I am new to vbscript, and want my script to ask for a machine hostname, do a dsquery using this input, then display the result on screen.
From a command prompt I am using
"dsquery computer -name %hostname%" (replacing %hostname% with the machine hostname)
This returns the info I want.
My vbscript looks like this so far:
Code:
Dim hName, runline

hName = Inputbox("Enter Machine Host Name","Enter Name")
Set WShell = CreateObject("WScript.Shell")
runline = ("dsquery computer -name " & hName)
WShell.Run  runline
This flashes the info I want on screen for a split second. How do I output this to screen?

Thanks in advance
 
Try this:

runline = "[red]cmd /k[/red] dsquery computer -name " & hName"

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top