Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Logon Script delete and remap drives

Posted on 2004-04-26
3
Medium Priority
?
684 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
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Just about everyone has an old PC laying around.  Ask anyone in the IT industry, whether they are a professional or play in it as a hobby.  From outdated Desktops to cheap "throwaway" laptops, they are all around and not as hard to "fix up" as you m…
I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
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.

926 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