Solved

Remapping Drives Using Logon Scripting

Posted on 2001-06-12
5
460 Views
Last Modified: 2010-04-13
I am working on a logon scripting problem for the first time. My problem is basically how do I remap drives to there correct locations in script? I am in a mixed evironment with win2k server and win2k pro/ win98/ mac workstations.
0
Comment
Question by:Khanpk197
  • 2
  • 2
5 Comments
 

Accepted Solution

by:
jhawklyn earned 100 total points
ID: 6182622
NET USE  - probably the command you'll need.  (Except the Mac....)
- some steps
1. Check that the drive isn't already mapped correctly.
2. map if it isn't available
3. check that the drive as mapped is mapped to a known location if it isn't unmap it. - remap.

Assumption: Username/password on current machine matches username and password on destination machine.

Below sample bat file would map a 'J' Drive to a specific location:
==== Begin MapSample.BAT =======
@echo off
REM PREMISE Drive to be mapped has known location ie: J:\EVAL
REM This sample bat file demo's mapping to Drive 'J'
if exist j:\eval\nul goto Done
REM check for mapping to 'wrong' location,  unmap to then do drive  remap.
if exist j:\nul net use j:  /delete
REM Map the drive
net use j: \\machine\volume
REM Check for success
if exist j:\eval\nul goto Done
:Error
Echo ERROR: Drive NOT mapped to j:\eval as expected.
Goto End
:Done
Echo Drive J is mapped
:End
==== End MapSample.Bat
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 6182850
Sounds good so far.

Also. win9x/ME can not map drive Z: ,  NT can.

It is going to be difficult to map more than one or 2 drives if you want to be consistent.

I would start at drive M or N or higher.

 I hope this helps !
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 6182878
From Tim , regarding finding the first free drive letter:

From: tim_holman                               Date: Wednesday, November 22 2000 - 04:01AM EST

                     In a batch script, try this:

                      net use * \\nt4_pdc\public > test.txt
                     for /f "tokens=2,3*" %%i in ('findstr "Drive" test.txt') do set drive=%%i

                     This will set the variable 'Drive' to whatever drive * has found.

                     From: timdog                                    Date: Wednesday, November 22 2000 - 08:59AM EST

Jeez, I thought you had it!  Almost there. I receive an error message saying that /F"tokens=2,3*" was unexpected at this time.
    From: tim_holman                                             Date: Wednesday, November 22 2000 - 10:14AM EST

                     net use * \\nt4_pdc\public > test.txt
                     for /f "tokens=2" %%i in ('findstr "Drive" test.txt') do set drive=%%i

                     You don't need the 3*, but it shouldn't matter.

                     Have you enough drives left to map ?

                     This works fine for me - NT 4, SP6a...
-----------------
I hope this helps !
0
 
LVL 3

Expert Comment

by:hendrik999
ID: 6182996
Please use a real login script program called KixTart.
It is freeware and programmed by Ruud van Velsen of Microsoft Benelux.
I'm working for a long while with this program and it is the best option if you want to use login scripts.
For more information please look at
http://netnet.net/~swilson/kix/

With KixTart you can (re)map drives via the following command:

  use f: /del /persistent
  use f: "\\servername\sharename"
0
 
LVL 3

Expert Comment

by:hendrik999
ID: 6183025
A better KixTart site is actually
http://kixtart.org/helpdesk/
0

Featured Post

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

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…
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

861 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now