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

VBScript prompting for username and password 1

Status
Not open for further replies.

TD007

MIS
Jul 9, 2008
4
US
I am hoping someone here can assist me with this problem as I am fairly new to vbscripts.

I have a script that will run and load software and everything works great. My problem is some of the software in user profile specific and must be installed under the users credentials however that user will not have access to our software share. So the VBScript will need to be ran under a different user.

I have searched high and low and cannot find a working solution.

What I am looking for is for my script when ran will first prompt for a userid and password and then commence running the mapping and installing software.

Does anyone have a solution for this?
 
I don't think there is a way to do it within the script. Although, I could be wrong.

VBScripts are run by wscript.exe (or cscript.exe). What you'll need to do is run wscript.exe as the person with the appropriate credentials.

try this from a cmd prompt:
runas /user:domain\username "wscript.exe c:\path\myscript.vbs"

It that works, then you can create a new script that calls this command.

Code:
set objShell = WScript.CreateObject("WScript.Shell")

objShell.Run "runas /user:domain\username ""wscript.exe c:\path\myscript.vbs"""

-Geates
 
This would be great, but I need it to prompt me for a username and password, not just the password.
 
modify it slightly:

Code:
set objShell = WScript.CreateObject("WScript.Shell")

[red]strUserName = inputBox("What is your username (domain\username)")[/red]
objShell.Run "runas /user:" & strUserName & " ""wscript.exe c:\path\myscript.vbs"" "

It will prompt you for a username (domain\user) using vb and then ask for a password.

-Geates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top