[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 703
  • Last Modified:

Batch file for drive mappings

Okay here is our problem today.  We are running a win2000 server in our school district that serves a application that logs student information.  In order for this program to work properly we map that specific drive where every teacher has a login and password.  The problem is on certain xp machines the drive mapping fails (it shows it as mapped but you have to password in again everytime) on the reboot.  There is no timeout or anything its only when you reboot.  I have read a couple of other similar problems on here that were solved by writing batch files but I havent done that in years, could someone walk me through that to build that batch file?  Sorry, I am sure this is elementary to most of you but I cannot remember how to do it. Thanks.
0
plainsschools
Asked:
plainsschools
  • 6
  • 4
  • 4
  • +3
1 Solution
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Are you running a domain on the server?  I think you should be trying to solve this through troubleshooting the domain, not sidestepping the problem with a security risk.  If you insist on doing this with a batch file, it would basically be this:


NET USE X: \\server\share password /user:DomainOrComputerName\Username

The obvious problem with this is you end up having the user password in a clear text file - kid gets this password and now they can use the account - do you really want this?
0
 
plainsschoolsAuthor Commented:
no there is no domain, we work on workgroups - I am aware of the security risks but we cannot firgure another way around it. Thanks
0
 
The_IT_GarageCommented:
Are the machines logging into a domain or local account?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
plainsschoolsAuthor Commented:
They are logging into a local account.  We are not implementing domains.
0
 
alextoftCommented:
Perhaps consider encrypting the jobfile using CPAU from http://www.joeware.net/win/free/tools/cpau.htm

It's free, simple, very effective, and I use it all the time to execute jobs as Administrator from a restricted user's workstation without them seeing the command or being able to decode it.
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Use a domain - it's SO MUCH EASIER!  Why not use a domain?  (I'm sorry, this just amazes me that you would run a school on workgroups like that with weak security like that).
0
 
plainsschoolsAuthor Commented:
OK, I understand all of your concerns but the simple problem is why is one of these machines doing it and another right next to it set up the exact way is not... the drive mappings are what we are concerned with at this point.  Domains/Workgroups will be addressed at a later time.  The network has been pieced together by several different people over the years - I just recently began working here so we are making due with what is available for now.  
0
 
The_IT_GarageCommented:
What leew suggested will work but....why can't the teachers have domain accounts? Seems like you're missing a golden opportunity for leveraging a server's capabilities resources. How many worksations do you have?
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
You have a 2000 server - that's all you need - run DCPROMO on it and make it a domain controller, then join the workstations.
Microsoft licensing for schools is VERY inexpensive (compared to the retail costs of things) - new server license is (was, last time I checked) less than $200.  Obviously, there are budget concerns, but if you do a proper analysis, I think you'll find the money SAVED by a domain is significant - because then it becomes easy to patch systems, install software, control user access, and you don't spend man-hours trying to troubleshoot problems like these.
0
 
JoeCommented:
Do you have your mapped drives to reconnect on logon?
0
 
The_IT_GarageCommented:
" but the simple problem is why is one of these machines doing it and another right next to it set up the exact way is not."
It sounds like some PC's are sending cached credentials and other are not

If you absolutely cannot then for the short term use leew's suggestion to send the credentials - that was the direct answer to your initial question.

Having said that.... instead of spending time on the band-aid put the affected machines into the domain which will be a proper fix - the amount of time will be about the same.  Then roll the others into the domain as you get time. It takes about 2 minutes to put the machine into the domain and crete a user account and solve the issue permanently.

Understood you walked into a mess, this is the perfect opportunity to show your talent & initiative and fix it for them, it's win/win!
0
 
plainsschoolsAuthor Commented:
JoeZ430:  The drives are showing up when you boot up and there is no red x but it is obviously not connected, when you double click on it, it prompts for user name and password to reconnect.  Kind of strange.
0
 
JoeCommented:
Disconnect the drive, then re-map one of them Set the correct user name and password and make sure reconnect at logon is checked. You may have change a password or something and it is not able to logon with the supplied credentials.

Joe
0
 
The_IT_GarageCommented:
Back to the initial Q - did it USED to work on the affected machines and now it doesn't, or has it always been OK on some PC's and not others? What are the security settings (access permissions) on the sever share (both share and file level)?
0
 
plainsschoolsAuthor Commented:
Okay, i remapped a couple of times - same result.  And no it never worked properly on this machine, it has dropped the map every reboot since mapping.
0
 
SunBowCommented:
>  we map that specific drive where every teacher has a login and password.  The problem is on certain xp machines the drive mapping fails

This usually means you need to include "persistent", where in windows explorer you get a checkbox, and with the net command you add "/persistent:yes".

C:\>net help use
The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

/SAVECRED        Specifies that the username and password are to be saved.
                 This switch is ignored unless the command prompts for username
                 and password.  This option is not available on Windows XP
                 Home Edition and will be ignored.
/PERSISTENT      Controls the use of persistent network connections.
                 The default is the setting used last.
YES              Saves connections as they are made, and restores
                 them at next logon.
NO               Does not save the connection being made or subsequent
                 connections; existing connections will be restored at
                 next logon. Use the /DELETE switch to remove
                 persistent connections.
...etc.

You might want /savecred as well, I've never needed it

>  you have to password in again everytime

This often happens when synchronization is lost. Best IMO is to have same Login ID and same password used for both the origin and destination, workstation and server. With an occasional problem for synch'ing changes, since this is for students, (limited duration), it might be good idea to not require them to (not let them?) change passwords
0
 
SunBowCommented:
> and there is no red x

yeah, shame on them. They did that p

JoeZ430 > Disconnect the drive,  

Right. I forgot to include that part. To redo it, it works out better if you disconnect, don't just reconnect. Sometimes it remembers too much, which can mean it works better with old or administrative passwords
0
 
SunBowCommented:
Done
0
 
plainsschoolsAuthor Commented:
Thanks a lot guys I wish I had not given out the points yet...sunbow, you answered the question perfectly.  Thanks again.
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
I will unnaccept the selected answer, but consider this in reselecting the answer:

This is still HORRIBLY insecure.  Your trying to remember the teacher's passwords - preventing them from changing their passwords is not safe - especially when you have students - unless these students are adults I would be inclined to guess at least 1 in 10 students will have a "curiousity" and want to access the system as the teacher - does the teacher store tests/homework information on the computer?  If so, this is exactly the kind of information the kids would want to get at.  And you are essentially giving it to them if you put the password to the resource in any kind of script.  Further, you can't force complex passwords without a domain (as far as I've seen) so a teacher that is not computer savvy can use an easy password for the kids to guess.

Your original question was regarding batch files - I gave the command you would use.  To take it one step further,

If Exist x:\ NET USE X: /DELETE
NET USE X: \\server\share password /user:DomainOrComputerName\Username

This will remove the mapping before mapping it again to ensure no error messages appear.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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