Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Logon Script delete and remap drives

Posted on 2004-04-26
3
Medium Priority
?
676 Views
Last Modified: 2008-02-01
Hi all.... I run a simple logon script like below:
---------------------------------------------------------------------
@echo off
net time \\servername /set /yes

if "%OS%"=="Windows_NT" goto winnt

rem ------------Windows 9X Script----------------
net use p: \\servername\programs
net use r: \\servername\school

xcopy \\servername\programs\blueri~1.bmp C:\ /y
xcopy \\servername\netlogon\putinenv.exe %windir% /y
xcopy \\servername\netlogon\winset.exe %windir% /y
xcopy \\servername\netlogon\kx16.dll %windir%\system /y
xcopy \\servername\netlogon\kx32.dll %windir%\system /y
%windir%\putinenv.exe L
%windir%\winset.exe username=%username%$
%windir%\winset.exe langroup=%langroup%
@echo on
@echo %username%$
@echo off
net use h: \\servername\%username%$
START /W \\servername\netlogon\kix32 \\servername\NETLOGON\logon.scr
exit

rem ------------Windows 2k/xp Script----------------
:winnt
net use /persistent:no
net use * /delete /y

net use p: \\servername\programs
net use r: \\servername\school
net use h: \\servername\%username%$

\\servername\netlogon\ifmember.exe "Magazine Users"
if not errorlevel 1 exit
net use k: \\servername\magazine$
---------------------------------------------------------------------

Now the first problem I have is that in the Windows 2k/xp logon I dont have any mapped drives. If I rem the "net use * /delete" they are there. Its like the logon script just 'exits' after deleting any existing mapped drives.

Also even tho it works, I had to 'echo' the username in the win9x script for it to accept the varible in the mapping of h: drive. I dont know why? - Its been like this for a few years now but just never figured out why I had to do this.

Cheers - other suggestions welcome :)
0
Comment
Question by:Zebis_nz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Expert Comment

by:infotrader
ID: 10923582
replace "if "%OS%"=="Windows_NT" goto winnt" with
"if %ostype%==NT goto winnt"

- Info
0
 
LVL 1

Accepted Solution

by:
idez_rsp earned 1000 total points
ID: 10925779
I think your problem is that when the Logon Script executes it's actually doing so as a mapped drive.  (Z:) And you are removing ALL the drive Mappings.  So it can't continue execution when it would get to the next instruction.

Try Manually deleting any drives you need to map prior to mapping them.

Good Luck!

R.
0
 
LVL 1

Author Comment

by:Zebis_nz
ID: 10927153
I *used* to run a slightly different script along the lines of:

if exist x: net use x: /delete /y
else etc...

But I thought there was a way to just *delete* all the currently mapped drives (thats if there any persistent ones).. then remap them...

Am I wrong in thinking that? Because then I think I ran into problems deleteing the home drive? Ill need to test it again.

Cheers,

Matt
0

Featured Post

Find the IP of a Linux Server in Command Line

Knowing your server’s IP address(s) can be a useful bit of information to have for various reasons. This tutorial will teach you how to check the IPs of any modern Linux server. To follow along will simply need access to the server via SSH or TTY.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Often we come across situations wherein our batch files would be needing to reboot Windows for a variety of reasons. A few of them would be like: (1) Setup files have been updated whose changes can take effect only after a reboot …
Windows 10 is here and for most admins this means frustration and challenges getting that first working Windows 10 image. As in my previous sysprep articles, I've put together a simple help guide to get you through this process. The aim is to achiev…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

730 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