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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net View Script

Status
Not open for further replies.

mpiontek

Technical User
Nov 17, 2004
9
US
Hi,
I may be getting vbs and VB a little comfused here, but I am trying to create a little script that will run the command Net View | Find "InsertVariableHere" I've gotten pretty close, but cannot get any output. Here is my code:

' VBScript File
Dim strName
strName = InputBox("Who's Station?","Find Station","Enter Name Here")
Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("Net View | find" & strName)
strStation = objScriptExec.StdOut.ReadAll
WScript.Echo strStation

If I take out the "| Find & strName" peice, it gives me a nice list of stations on my network. If you copy and paste this code to a .vbs file, you will probably see what I'm trying to do. should be simple, but I'm not really a programmer.

Any help is appreciated. Thanks.
Mark.
 
Is this what you're after?

Change:
Code:
Set objScriptExec = objShell.Exec("Net View | find" & strName)
To:
Code:
Set objScriptExec = objShell.Exec("Net View \\" & strName)


NET VIEW
[\\computername [/CACHE] | /DOMAIN[:domainname]]
NET VIEW /NETWORK:NW [\\computername]
 
To use find in that context, you have to [1] obviously leave a blank space between find and the string; and [2] you have to further enclose the string in the quotes. Hence try this.
>[tt]Set objScriptExec = objShell.Exec("Net View | find" & strName)[/tt]
[tt]Set objScriptExec = objShell.Exec("Net View | find[highlight] [/highlight]" & [red]chr(34) &[/red] strName [red]& chr(34)[/red])[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top