windows login script

Posted on 2005-03-02
Medium Priority
Last Modified: 2010-04-14
hello all,

     I would like to ask for a sample window script that shall add a network drive while passing the  username and password, to connect to another computer.  
Question by:manthanein
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 22

Accepted Solution

Christopher McKay earned 1600 total points
ID: 13445406
First thing I'd like to ask, is why you want the batch file to pass the username and password. This leaves this information unprotected and available to be read by others.
Is there any other way to accomplish what you're looking for?


LVL 22

Expert Comment

by:Christopher McKay
ID: 13445441
To pass the information to the net use command, try this:

Net use p: \\<computername>\<sharename> "password" /user:<domain>\<username>

This should work in XP, but once again, the password is stored in the batch file and is readily available to be viewed by all.


LVL 15

Assisted Solution

sr75 earned 400 total points
ID: 13446756
A vb script would look like this:

Set Net = WScript.CreateObject("WScript.Network")
Net.MapNetworkDrive "Z:", "\\Server\Share", "false", "Username", "Password"

You should then download the Windows Script Encoder from here:


This will give you a bit more security with your passwords, but it is crackable if the person really want it.

After you install it you run this from the command line:

screnc scripttobeencoded.vbs scriptencoded.vbe

You will need to place the path before each script and possible to the screnc command.

The scriptencoded.vbe is the encoded script.  It cannot be read with just a text editor.

Author Comment

ID: 13449072
Bartender_1, to answer your question it's because it's just a generic account, and everybody knows the password and the account to be used to map the network drive. I was only trying to prevent  mistyping of the password that would later on make the account to be used locked out. the source computer is included in our domain where I can't set any account  to be unlockable, so the only solution is to create a bat file to connect to the said directory and passing the username and passsword as argument..  

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question