• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1123
  • Last Modified:

Mapped Network drives

Hi

I have a problem with mapped network drives in Windows 2000. When I check the box "reconnect at next logon", windows refuses to remember the password that was used to connect to the mapped drive. I know that with the use of "net use" I can create a logonscript, but DOS scripts are not an option.
How can I make WIndows remember the network drive passwords?

Thanks

Wandalf
0
Wandalf
Asked:
Wandalf
  • 10
  • 6
  • 6
  • +3
1 Solution
 
danichCommented:
The Remember Password checkbox depends on the user having a logon (local or domain) in the first place. The passwords are then stored in a .PWL file which is unlocked by the logon. If you are not logging into the machine at startup there is no secure place to store the password(s), thus they are not remembered.
0
 
antonsigurCommented:
I'm not sure you can.
You could go the other way, set the network drive security, in a way, that the remote computer can map the drive.

This is a nice cmd script, connects and disconnects the drive v:

@echo off
if not exist v: goto install
goto uninstall
:install
net use v: \\server\share$ /user:server\username password
goto end
:uninstall
net use v: /delete
:end

You could include a key in registry, this would run for all users, you could setup a CURRENT_USER key there too

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"drive1"="net use v: \\server\share$ /user:server\username password"

But again, I use net use, and you don't wan't to use that tool....
0
 
WandalfAuthor Commented:
Net use is indeed not an option, because I have a Windows Terminal Services environment here, and whenever DOS is accessed (through a script or DOS program) exception errors are created in a in-house written piece of software.
So any script that runs in DOS is out of the question. Maybe I can use VBScript or JScript to make the connection?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
antonsigurCommented:
yes okey., this is a vbs code You just replace it with your username and passsowrd, sharename and on you go.

You just run it!

Set objNetwork = Wscript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "y:", "\\server\share", false, "server\user", "password"
0
 
antonsigurCommented:
Yes, and if you call the script "map.vbs" you can doubleclick it, or run it with "cscript map.vbs"
or "wscript map.vbs" You could put in in a registry like this:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"drive1"="wscript C:\map.vbs"
0
 
oBdACommented:
Hi Wandalf,

maybe you just used the wrong terminology, but the standard NT shell (cmd.exe) is NOT a DOS Box (command.com), though both can be started in NT and look similar.
cmd.exe is a regular 32bit program, it's needed for basic functionality, and it shouldn't interfere with other software. If it's nevertheless really cmd.exe that's interfering with your in-house software, there's something seriously wrong with your software.
If you start a batch file and it runs in the 16bit environment (NTVDM), you might want to check your ComSpec variable; that should point to %SystemRoot%\system32\cmd.exe.
0
 
antonsigurCommented:
Yes, Wandalf, cmd is a not a dos... "net" function is not a dos function.. ..
But did my comments help you? Do you need more help?
0
 
PremierncCommented:
This sounds horrible, but if you do not use scripts to map the drives or control the access to them, and you are using terminal services, it will always ask you for the password to create connections. Try implementing the guest account certain shares, be careful. If you do it right you shouldn't have to many issues with security.
0
 
WandalfAuthor Commented:
Hi

to oBdA : you're right, I did use the wrong terminology, but it is in fact the standard NT shell (cmd.exe).
My ComSpec variable points to %SystemRoot%\system32\cmd.exe, but still when I start a batch file (.bat), and I monitor the task manager, both the cmd.exe and ntvdm.exe process are activated.
About the in-house software, I know something is wrong with it, but I didn't implement it, my job is to provide the systems, so I'm stuck  with it.

to antonsigur : I'm still working on the scripts you proposed, but they might be the answer. The only problem is, when I run the script, all the mapped drives are opened in Explorer each time the script runs.

to Premiernc : I will try to allow the guest account on certain shares.
0
 
yoann_proutCommented:
You can try these 2 little VBScript, copy/paste code in 2 .vbs files :

'Login
Option Explicit

Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")

'Map drives
'object.MapNetworkDrive strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword]
'[bUpdateProfile] : Use TRUE instead of FALSE if you want a persistent mapping, info will be store in your profile

WSHNetwork.MapNetworkDrive "F:", "\\Server\system_volume", False, StrUserName, StrPassword
WSHNetwork.MapNetworkDrive "G:", "\\Server\volume_1", False
WSHNetwork.MapNetworkDrive "H:", "\\Server\volume_2", False
WSHNetwork.MapNetworkDrive "X:", "\\Server\volume_2\users\My_Name", False

_________________________________________________________________________________________________

'Logout
Option Explicit

Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")

'"Unmap" drives
'object.RemoveNetworkDrive strName, [bForce], [bUpdateProfile]
'[bForce] : Remove mapping even if distant ressources are in use
'[bUpdateProfile] : Use TRUE if you want the mapping to be removed from your profile


WSHNetwork.RemoveNetworkDrive "F:", True, True
WSHNetwork.RemoveNetworkDrive "G:", True, True
WSHNetwork.RemoveNetworkDrive "H:", True, True
WSHNetwork.RemoveNetworkDrive "X:", True, True

WScript.DisconnectObject WSHNetwork
0
 
yoann_proutCommented:
You can try these 2 little VBScript, copy/paste code in 2 .vbs files :

'Login
Option Explicit

Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")

'Map drives
'object.MapNetworkDrive strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword]
'[bUpdateProfile] : Use TRUE instead of FALSE if you want a persistent mapping, info will be store in your profile

WSHNetwork.MapNetworkDrive "F:", "\\Server\system_volume", False, StrUserName, StrPassword
WSHNetwork.MapNetworkDrive "G:", "\\Server\volume_1", False
WSHNetwork.MapNetworkDrive "H:", "\\Server\volume_2", False
WSHNetwork.MapNetworkDrive "X:", "\\Server\volume_2\users\My_Name", False

_________________________________________________________________________________________________

'Logout
Option Explicit

Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")

'"Unmap" drives
'object.RemoveNetworkDrive strName, [bForce], [bUpdateProfile]
'[bForce] : Remove mapping even if distant ressources are in use
'[bUpdateProfile] : Use TRUE if you want the mapping to be removed from your profile


WSHNetwork.RemoveNetworkDrive "F:", True, True
WSHNetwork.RemoveNetworkDrive "G:", True, True
WSHNetwork.RemoveNetworkDrive "H:", True, True
WSHNetwork.RemoveNetworkDrive "X:", True, True

WScript.DisconnectObject WSHNetwork
0
 
antonsigurCommented:
yoann_prout: I gave him this Wscript earlier....

Set objNetwork = Wscript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "y:", "\\server\share", false, "server\user", "password"

Wandalf: When I run this vbs script, it doesn't open a explorer window, it just maps the drive.... Does it open a window? Ore does the "net use" open window?
0
 
WandalfAuthor Commented:
antonsigur, each time I activate the script, all mapped drives are opened in seperate explorer windows. I Don't know what causes that behaviour.
"Net use" doesn't open explorerwindows
0
 
antonsigurCommented:
How do you activate the script?
0
 
yoann_proutCommented:
Yes antonsigur, excuse me.
(I saw it after sending my comment... I have started writing it this morning but was called outside my desk, then I have submitted it after you, but at this moment, I was not able to see yours... blabla)

Anyway... I explain things you don't, then just take my comment as a complement.

Wandalf : Do you finally use "net use" via cmd line or MapNetworkDrive with VBScript ?
0
 
yoann_proutCommented:
Yes antonsigur, excuse me.
(I saw it after sending my comment... I have started writing it this morning but was called outside my desk, then I have submitted it after you, but at this moment, I was not able to see yours... blabla)

Anyway... I explain things you don't, then just take my comment as a complement.

Wandalf : Do you finally use "net use" via cmd line or MapNetworkDrive with VBScript ?
0
 
yoann_proutCommented:
Yes antonsigur, excuse me.
(I saw it after sending my comment... I have started writing it this morning but was called outside my desk, then I have submitted it after you, but at this moment, I was not able to see yours... blabla)

Anyway... I explain things you don't, then just take my comment as a complement.

Wandalf : Do you finally use "net use" via cmd line or MapNetworkDrive with VBScript ?
0
 
antonsigurCommented:
Yes yes... no harm done...
0
 
yoann_proutCommented:
Oooooooooooola

I PROMISE I only click ONE time on "submit"... There's some Internet connection problem today here and I think it's the reason why my comments are duplicated...

Sorry.
0
 
WandalfAuthor Commented:
yoann_prout : I don't want to use "net use"
The whole idea of this question here is to eliminate the use of "net use", because for some unknown yet bizarre reason it causes exception errors in a piece of software we use.
No harm done with the multiple replies

antonsigur : I've activated the script in 3 different ways : first just by doubleclicking, second by placing it in the startup folder of a specific user an third by going to start->run "wscript c:\mapdrive.vbs".
But the explorerwindows just keep on popping up.
0
 
antonsigurCommented:
strange as hell...
I'm looking for solution... hmmm
0
 
antonsigurCommented:
I've tried this on five computers...

One XP
One W2kpro
Two w2k servers

Once on the console
And once on a diffrent server, runnig as terminal application server...

No popping up windows..

-------
Finding solution:
Are there any network drives, connected or "disconnected" in "my computer" ? If there are, disconnect them.

Try using "cscript c:\mapdrive.vbs" - does it pop up?

What version of wscript are you using, I'm running 5.6.0.6626

Try run in batch mode, "wscript //B C:\mapdrive.vbs"

Finally, did you try running it from the registry?

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"drive1"="%SystemRoot%\system32\wscript c:\mapdrive.vbs"
0
 
oBdACommented:
Hi Wandalf,

seems like there's something not right with your server, independent of your in-house software. Starting a .bat that only contains internal shell commands or 32bit program calls should not open the NTVDM. Avoiding a script file because of that is treating the symptoms, not the cause of the problem.
You could try several things:

* Open Windows Explorer and navigate to %systemroot%\system32; check out the properties of cmd.exe and command.com. cmd.exe should have only the regular four tabs and display an icon; only command.com should have the additional 16bit tabs and have the default "empty window" icon.

* start cmd.exe from the run menu (that should not open the NTVDM) and type 'assoc | find /i ".bat"'; it should respond with '.bat=batfile'; now type 'ftype batfile', that should respond with 'batfile="%1" %*';trying the same with '.cmd' should return 'cmdfile' and 'cmdfile="%1" %*.

* Start regedit and go to HKCR; check out if '.bat' and '.cmd' have the same entry in "PersistentHandler"

* Create a batch file with a "net use" statement (or just a 'pause' command), save it as <SomeFileName>.CMD (not .bat), and start that. The NTVDM process should not start.

* Try if the links in http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/windows2000serv/support/FAQW2KCP.asp can be of any help.
0
 
WandalfAuthor Commented:
antonsigur: the problem of the explorer windows is solved.
I was using the original wscript engine that came with windows (5.1). After I installed the 5.6 release, no pup-ups.
Now 1 single question remains : is the method of running it from the registry considered the "cleanest way" : least chances of tampering?

oBdA : I'll try your suggestions tomorrow, running low on time now.
0
 
antonsigurCommented:
No, this is just a alternate...

If you put it in the startup folder, then everyone sees it... It is somewhat "hidden" if you put it in the registry (hidden from the users)

You just do what you like best, I would probably putit in the registry if it where the same for all users, (under LOCAL_MACHINE) but if the mappings differs from user to user, or if it is only for one user, then I would just put it in the startup folder.
0
 
WandalfAuthor Commented:
Sorry to all for the delay

It seems that the error generated in the software doesn't originate from the use of "net use". It is the result of memory problems, about which I will post a different question, as the errors still remain.

The points will be rewarded to antonsigur, as he was the first to provide the script which didn't really solve this problem, but it was usefull for other environments.
Thank you for that antonsigur.

Sincerely
Wandalf
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 10
  • 6
  • 6
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now