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

Need script to map home drive based on user input location

Hello,

done a search and haven't found anything exactly like what I'd like to do.

We have a single domain with users in multiple locations. Each main location has its own file server and users map their home drive based on their location. We've had issues with home drives not mapping in remote locations that do not have a local server. We believe it may be timing out, that issue is being looked into.

Rather than have our IT staff manually map the drives, I'd like to do a small script we could place on their desktop that allows users to put their primary location, which would then map their home drive to the correct server.  Something like this.

Please select your primary location:
0 = HQ
1= Region 1
2= Region 2
3 = Region 3
4 = Region 4

Based on their answer I assume it would then run a command

HQ
Net Use K:\\hqserver\vol\%username%

Reg 1
Net Use K:\\r1server\vol\%username%

Reg 2
Net Use K:\\r2server\vol\%username%

Reg 3
Net Use K:\\r3server\vol\%username%

Reg 4
Net Use K:\\r4server\vol\%username%

I've tried writing a few, but scripting is definitely not a strong suit. I'm sure it would take a talented scripter about 2 minutes.

TIA
0
DTSC-OEIM
Asked:
DTSC-OEIM
1 Solution
 
NVITCommented:
Try this

@echo off
echo.
echo 0 = HQ
echo 1 = Region 1
echo 2 = Region 2
echo 3 = Region 3
echo 4 = Region 4
echo.

SET /P location=Please select your primary location: 

if %location% equ 0 Net Use K: \\hqserver\vol\%username%& goto :eof

if %location% equ 1 Net Use K: \\r1server\vol\%username%& goto :eof

if %location% equ 2 Net Use K: \\r2server\vol\%username%& goto :eof

if %location% equ 3 Net Use K: \\r3server\vol\%username%& goto :eof

if %location% equ 4 Net Use K: \\r4server\vol\%username%& goto :eof

Open in new window

0
 
DTSC-OEIMNetwork AdministratorAuthor Commented:
Thanks for the quick reply, I'll test it out.
0
 
David Johnson, CD, MVPOwnerCommented:
in group policy you also have SITES use this to create a gpo for each site that has the folder location
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
Mal OsborneAlpha GeekCommented:
Either:

1. Set up DFS, and let Windows do all that tricky stuff for you.
2. Set up GPOs tied to site, and have them either map via preferences, or fire a logon script.
0
 
Mal OsborneAlpha GeekCommented:
Here is some info on how DFS Replication works.

Basically, you set up several shares on multiple servers that are automatically synced in the background. So, maybe
\\headofficesver\shared
\\branch1svr\shared
\\branch2svr\shared

If a file is changed in any of these shares, the changes are replicated to the rest. Client machines use site information to connect to the "closest" server.

https://msdn.microsoft.com/en-us/library/bb540025(v=vs.85).aspx
0
 
DTSC-OEIMNetwork AdministratorAuthor Commented:
Tweaked it for my environment and so far testing with a few staff has worked like a charm. Thanks.
0

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now