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

map a windows network drive in perl

Status
Not open for further replies.

hcclnoodles

IS-IT--Management
Joined
Jun 3, 2004
Messages
123
Location
GB
Hi there, The issue I have is that I have a w2k box that will be connecting to our windows network , but will not be connected to the domain, therefore, when we map a network drive, it asks for a "DOMAIN/UserName" and then "Password" to let us in.

Because we want to automate this process I tried writing a .bat script, but there is no way I can put the username/password within the script, and as such everytime it tries to map the drive , a login dialog pops up

I have been told that I can use perl to resolve this issue, does anybody know how ?

Any help would be greatly appreciated
Gary
 
cant you use the auto login feature?
 
sorry, the auto login feature i believe you are referring to is the function that allows you to login to your computer automatically when you boot it up, but i am specifically talking about mapping a drive from within windows.....unless of course you are refering to something completely different?

 
There is, of course, a security problem with what you want to do - your password needs to be in the script in plain text. If that's acceptable to you, I don't think this requires Perl. You should just be able to put a line in your batch file with the net use command.

Typing a command similar to

Code:
net use z: /user:SomeDomain\Username \\Server\Share password
should map z: to \\Server\Share. The syntax might not be exactly correct, try looking at 'net use -?' in your cmd prompt if there are problems.
 
To use it in a script, but as rharsh points out, very v. dodgy, from a security standpoint, wrap the command in backticks

If you're already logged in as the sysadmin to run it, i think
this should work.

$result=`net use z: \\server\share`;

HTh
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top