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

Username and Password 1

Status
Not open for further replies.

irkey

MIS
Sep 23, 2002
14
0
0
CA
Does anyone know how to get the username and password in VBScript? I want to be able to map a network drive and pass the logon credentials to it.

set net = Wscript.CreateObject("Wscript.Network")
net.MapNetworkDrive "Z:", "\\server\share", , "sUserName", "sPassWord"

I know I can probably use "InputBox" to get the username into the sUserName variable, but this wouldn't work for the password as it will display it in plain text. Is there a way to mask the password???? Or is there a better way to get access to a network resource?
 
Since I am new to VBScript, I have no idea what you're talking about. I went to the sites you mentioned, but I cannot find anything on functions...??? Anyone else??? Help!
 
The point was that there is no function to return the password for a user because that would compromise the very security that you are trying to establish. It has nothing to do with your being new to VBScript. It has to do with using your brain to realize that any system that uses passwords for security and then just hands them out to any script that asks for them is not a secure system. Any script in any Html page that you were viewing could ask for the password of the person currently signed on, that being you.

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
I think maybe just telling him that, in kind manner would have been better than belittling him, we all make mistakes and have a momentary lapses of reasonable thought.

In short don't be such a jerk!

Irkey, you can do it just don't provide the password, if its with the same domain the workstation will provide the password automagically when you attempt the drive mapping, I think!

Hope this helps.
 
P.S. It will provide the server with the password not your script.
 
If you still need to enter a masked password, download and register the free SCBLIB COM component from
This provides console, keyboard and mouse support.

There is a sample script in the SCBLIB.ZIP, gk.vbs, that provides the ability to enter masked password text.

The following snippet shows what you could add to the script to prompt for a user id and masked password:
'prompt for user id
sUserName = InputLine (12,12,30,sUserName, bInsert, False, objSCBLib)
'edit password with masked input
sPassWord = InputLine (12, objSCBLib.CursorYPos + 1 , _
20,sPassWord , bInsert, True, objSCBLib)

set net = Wscript.CreateObject("Wscript.Network")
net.MapNetworkDrive "Z:", "\\server\share", , sUserName, sPassWord

Hope this helps.

Regards

Stein Borge
Author of: Managing Enterprise Systems with the Windows Script Host
Over 800 pages of practicle solutions oriented material, providing
detailed coverage of WSH 5.6, ADSI, WMI, ADO, CDO, FSO and more
sb@nyetspam.enterprisewsh.com <- remove nyetspam when E-mailing
 
steinb,

I have tried your method and I get an error message say &quot;Type mismatch: 'InputLine'&quot;, Code 800A000D. I have registered the scblib.dll and put the file in the Windows system directory.
 

Sorry, the code provided won't run on it's own, it's a suggested modification to the gk.vbs script that contains the InputLine function. Does the gk.vbs sample included in the ZIP file run?

Stein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top