Solved

Mapping drives in logon.bat

Posted on 2004-09-15
37
24,186 Views
Last Modified: 2012-06-27
Im having issues with getting dirves to map when a user logs into the doman.

My logon.bat looks like this:
REM logon.bat
@echo off
call welcome.bat
call mapdrives.bat

My welcome.bat looks like this:
echo.
ECHO Welcome to the Network, %USERNAME%.
echo.
ECHO You are at computer %COMPUTERNAME% running Windows XP Pro os.
echo.
ECHO Please wait, authenticating %USERNAME% with the %USERDOMAIN% domain.
echo.

AND the mapdrivers.bat looks like this:
REM mapdrives.bat

@echo off

REM Exit if user has logged on to the server
IF %COMPUTERNAME%.==Server2003. GOTO END

REM Delete pre-existing drive mappings
NET USE H: /DELET >nul

REM MAP H: To Users
NET USE H: \\Server2003\Temp

I made that Temp folder in the ROOT dire and set it up so "Everyone" had full access.

The bat files are all stored in the windows\sysvol\domain\scripts folder

When I go to my test client PC and log into the domain. I see NO welcome message and no hard drive is mapped.

Any Idea on where I went worng?
0
Comment
Question by:mrchaos101
  • 14
  • 11
  • 5
  • +4
37 Comments
 
LVL 3

Expert Comment

by:Thaaron
ID: 12070348
First, are the user accounts setup to use that login script in Active Directory Users and Computers?  (Assuming 2000/2003 domain)

If so, then try simplifying the logon.bat to see if it is running at all.  Something like this.

echo test
pause

If you dont' see this when you login, then something else is going on.  Do you have more than one Domain Controller?  If so, has the login script replicated between them properly?
0
 

Expert Comment

by:Neil_2004
ID: 12070450
its possible to open up the ou and enter the path for the logon script to make sure its definately going to the right place
0
 

Expert Comment

by:Neil_2004
ID: 12070457
thaaron,
if this was on the "pdc" would it matter if the were more domain controllers?
0
 
LVL 3

Expert Comment

by:Thaaron
ID: 12070491
When you point to the login script are you using a path or simply putting "login" in the field?

Yes, even if it is the PDC it still matters.
0
 
LVL 23

Expert Comment

by:Tim Holman
ID: 12072452
You want to store the scripts in the NETLOGON share, not the SCRIPTS share.  Also make sure they replicated across all domain controllers.
0
 

Expert Comment

by:Neil_2004
ID: 12072549
you can use the sec edit command to force the replication instead of waiting for it to replicate as it can take upto 30 mins
0
 
LVL 1

Expert Comment

by:RichardKline
ID: 12073222
These are not new ideas -- just further explanation of those above.  Please make sure that, if successful, the original suggesters get the awareded points.

Check that the scripts are where you want them to be:
1.  Open My Network Places
2.  Open Entire Network
3.  Open Microsoft Windows Network
4.  Open Domain
5.  Open Server
6.  Open NETLOGON
Your bat files shoule be there.

-------------------------------------
Login scripts are not executed unless specifcied within a policy or within each user's account properties.   Try this:
1.  Edit the Active Directory User Properties for your test user.  
2.  Select Profile
3. Add the login script location and name to the the Login Script text box using the format \\SERVER\netlogon\logon.bat
--------------------------------------
It's possible that your LOGON.BAT file is executing but that it is unable to locate the other called files.  As mentioed above, try
1.  removing  @Echo Off
2. Inserting something like Echo Test
3. Finish the script by adding PAUSE to the end


0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12075535
It just isn't opening logon.bat
The bat files are all stored in the windows\sysvol\domain\scripts folder
I looked in the \\SERVER\netlogon\ folder as well and the same files are there... so I guess 2k3 is smart and put them there on its own?

I went to my test clint and added \\SERVER\netlogon\logon.bat  under the tpa that said profile there is a text box that sas log in script  I put it there... replacing SERVER with the name of my server.

STILL NO GO
I did the ECHO TEST and PAUS at the begining of the logon.bat and NOTHING. No text comes up at all.

Any ideas?

0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12075562
"you can use the sec edit command to force the replication instead of waiting for it to replicate as it can take upto 30 mins"

eh?  you lost me. Keep in mind I am a noob lol
The way RichardKline explaind and walked though is kinda what Im hoping for. Im fresh out of scool and dont have much exp at this yet.
0
 
LVL 3

Expert Comment

by:Thaaron
ID: 12075601
Try just putting logon.bat in the line instead of \\SERVER\netlogon\logon.bat  
0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12075843
Put logon.bat in that same text field instead of the full path.

No go.
0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12075856
The user I am loggin in has a "restriced" access.  It was what I chose when I set him up throught he wizzard.  Im trying to mimic a real user on this net work.
0
 
LVL 23

Expert Comment

by:Tim Holman
ID: 12075899
Do your users have RX access to the \\server\netlogon share ?

ie - you should just be able to log on as a client, then Start > Run > \\SERVER\netlogon\logon.bat


0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12075959
I looked at the security tab of the netlogon folder

by default it says Authenticated Users have RX rights....

I asume that because the client is loggin intot the domain that said client is authentcated right?
Should I add Domain users there as well or the user him self?
0
 
LVL 3

Expert Comment

by:Thaaron
ID: 12075985
As tim holman suggested, after loggin in as the user try running \\SERVER\netlogon\logon.bat  manually to see if it works.
0
 
LVL 1

Expert Comment

by:RichardKline
ID: 12076094
Yes, Authenticated users should work just fine.  

Concur on Tim's suggestion:  try running \\SERVER\netlogon\logon.bat  manually to see if it works

0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12076236
OK I didn't get a chance to try it....

I rebooted as I am having a problem with svchost.exe.  Every time I LOG OFF and swithc to a local user on the comptuer the damned file takes up 100% of my CPU and I need to power it off then back on to get it under controll.

I will do another thread on that issue...

BUT after the reboot it mapped the drive :)

Not sure what or why... BUT I am still having issues

The Dos window doesnt show up so It isn't showing the ECHOED text.  I realy want it to show on the screen so I can use my welcome.bat to welcome the user as they are logging in...



0
 
LVL 3

Expert Comment

by:Thaaron
ID: 12076302
Be sure to put in a Pause after the echo'ed text otherwise it just all flashes by...
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 1

Author Comment

by:mrchaos101
ID: 12076417
Ok but the box is minimized at the bottom of hte screen...

is there a batch timmer?  say to count donw 10 seconds then continue?
0
 
LVL 3

Expert Comment

by:Thaaron
ID: 12076558
To do that you'd need to use a third part app.

There is a free app called sleep.exe that will do it.

If you google "Download sleep.exe" you should find several places to download the file.

Of course you should only download at your own risk and always scan for viruses before using it!
0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12077328
Thaaron,

I Downloaded the tools form Microsoftcom  http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

It has the sleep.exe  said it is a batch waiter?

How would I use it?
0
 
LVL 3

Expert Comment

by:Thaaron
ID: 12077368
Put the sleep.exe file in your netlogon folder.

Put a line in your login script after the echo commands that says sleep with the number of seconds after it.

For instance if you want it to wait for 15 seconds it would look like this:

echo.
ECHO Welcome to the Network, %USERNAME%.
echo.
ECHO You are at computer %COMPUTERNAME% running Windows XP Pro os.
echo.
ECHO Please wait, authenticating %USERNAME% with the %USERDOMAIN% domain.
echo.
sleep 15
0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12077604
OK we are getting close

Sleep is pausing it for the time I put.. but the box still shows up minimized int he task bar

When I log in I dont get the BLACK BOX in the middel of the screen saying WELCOME BLA BLA BLA.. If I click the event int eh task bar it shows up on the screen of course.. but by default I want it to show up on the screen when they log in.

0
 
LVL 3

Expert Comment

by:Thaaron
ID: 12077699
0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12077914
Ok I made a bat file called display.bat
that is the first call that is made in the logon.bat

 ;*************************************************************************************
 ; Check the following key for W2k Machines to make the window not run minimized
 ;*************************************************************************************
 IF @dos >= "5.0"
       $hkcus = 'HKEY_CURRENT_USER\SOFTWARE'
       IF 1 <> ReadValue($hkcus+"\Microsoft\Windows NT\CurrentVersion\Winlogon", "RunLogonScriptSync")
             $ = WriteValue ($hkcus+"\Microsoft\Windows NT\CurrentVersion\Winlogon", "RunLogonScriptSync", "1", "REG_DWORD")
       ENDIF
 ENDIF

is what is in it... im using 2k3 not 2k.. this cod doesn't work... is there somthing that needs to be changed to make it owrk on 2k3?
0
 
LVL 3

Expert Comment

by:Thaaron
ID: 12077951
Try the steps listed in the last part of the articles.
0
 
LVL 1

Expert Comment

by:RichardKline
ID: 12078114
Rather than directly writing to the registry on each individual workstation, I seriously recommend that you investigate creating and propagating Domain policies.    The Microsoft URL
http://www.microsoft.com/technet/prodtechnol/windows2000serv/howto/grpolwt.mspx 
will help you get started.

Look for the policy "run logon scripts visible" and enable it.   The GPO is your friend (sometimes a "persnickety one" but still a friend).   Learn how to use it.

The policy editor is found by:
1.  Launching Active directory Users and Computers
2.  Right Clicking on Domain Name
3.  Select Group Policy
0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12078130
I ran Regedit on the server
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
is where I went to

I do not see a  RunLogonScriptSync

DO I make a new  a DWORD value calleded RunLogonScriptSync give it a value of 1 ?
0
 

Expert Comment

by:Neil_2004
ID: 12078270
what richard meant was to open active directory
find which domain your user is in
right click on that domain
select properties
click on the group policy tab
you should hopefully find your batch file in there
0
 

Expert Comment

by:Neil_2004
ID: 12078299
if needbe you can select "show files" to take you to the folder where the batch file has been put,
you can then edit the file if you need to
0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12078473
right click on that domain
select properties
click on the group policy tab


OK we re getting close on it hehehe
woudl it be under the

user configuration \ Administratve Templates\ system\Scripts

here I see
Run Logon scritps synchronously  I set to enabled
Run Legacy logon scritps hidden   I set to disabled
run logon scripts visible               I set to enabled
run logoff scritps visable             Not configured

Ok I think this is right sput but I still dont see it show on the screen.

we re close heeh
0
 
LVL 3

Expert Comment

by:Thaaron
ID: 12078554
Now just set the login script to run through Group Policy.

User Configuration \ Windows Settings \ Scripts \ Logon
0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12078689
Ok still in the Group Policy Object Editor

Forgive me please hehe I am still on a huge learning curver

Iwent to USER CONFIGURATION\Windows Settings\Scripts (Logon/Logoff)
I asume you are talking about here?
I have it set to point to the logon.bat file below

\\server.domain\sysvol\server.domain\scripts\logon.bat
0
 
LVL 3

Accepted Solution

by:
Thaaron earned 500 total points
ID: 12078704
No, set it to \\servername\netlogon
0
 
LVL 1

Author Comment

by:mrchaos101
ID: 12079047
Thaaron you rock!!!!!

I know this noob stuff... but belive me I am LEARNING as we go hehhe

The box comes up and shows what I want it to do. Drives are mapping as they should wiht the disply.

I feel bad as I am now thinking that the maximize should have been its own issue in its own thread  with points.

Q.) I wanted to find out WHY the logon.bat would not work.
A.) In reviewing all the help offered Thaaron had 2-3 posts that led me to find what I needed. He not only showed me how to set EACH USER to point to log in script.. but later on.. showed me where to set it up for the DOMAIN so I dont have to mess with it agian.

Q.) 2nd part of the issue was me wanting to DISLPAY the dirves being mapped and a welcome message.  This I now think should have been put in its on thread :(
A.) agian Thaaron came up with the solution of the dislpay not working.  This solution also showe me a of other things I wanted to know and he headed off some other posts I planed to make.

Thaaron I am awarding you the points for a Job well done.  
I want to thank EVERY BODY for offering help with my problem.
0
 
LVL 1

Expert Comment

by:mtc_com
ID: 12226945
Hi,

Do one thing...

use pause command so that u will come to know wether commands are executing or not.

1.     create a batch file called drives.bat ( name u can choose anythnig )...

2.    Copy this file to \\servername\SYSVOL\server.net\scripts folder.

3.    create a user called test.

4.    set his profile to use drives.bat file..simply put drives.bat in profiles...Active directory properties.

pl tell me if u have any problem.
0
 

Expert Comment

by:ITdesign
ID: 12284736
well, mapping the network drives this way would perform better

if exist h: net use h: /d
net use h: \\homedir   /PERSISTENT:Yes
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Xen 6.1, 6.2 Poor NIC performance in ShadowProtect/WinPE 9 73
SonicWALL SIP Transformation Problem 4 47
sync conflicts 1 55
Booster, Repeater, or Wireless Access Point 9 43
#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
I had an issue with InstallShield not being able to use Computer Browser service on Windows Server 2012. Here is the solution I found.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

932 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

13 Experts available now in Live!

Get 1:1 Help Now