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

need to run a command from a vb script

Status
Not open for further replies.

1971240z

Technical User
Jul 24, 2002
20
US
I need to run a net use command from a vb script. The script will ask for a users login name as input. Then the user name will be put in to a net use command that will prompt for the users password. This is what I have written.

Option Explicit
Dim name, username
Wscript.StdOut.WriteLine "Enter your name: "
username = Wscript.StdIn.ReadLine

Wscript.StdOut.Run "net use \\55chevy /user:domain\"& username &""

The problem is I do not know how to execute the net use command. Can anyone help?

Regards,

 
Option Explicit
Dim WshShell, WshNetwork, strUserName

Set WshShell = WScript.CreateObject("WScript.Shell")

strUserName = InputBox("Enter your name:" & vbCRLF & "Please enter your username.", "Login")

WshShell.Run "%comspec% net use \\55chevy /user:domain\" & strUserName & ""

Hope that helps.
 
Oops, change the WshShell.Run line to:

WshShell.Run "%comspec% /c net use \\55chevy /user:domain\" & strUserName & "", 0, True

Sorry about that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top