Solved

Remapping Drives Using Logon Scripting

Posted on 2001-06-12
5
463 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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…
Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 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