• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9488
  • Last Modified:

Windows 2003 Logon Script

Hello I am having trouble executing a logon script from Windows 2003 to a Windows XP client and a Windows 2000 Pro client.

This is the sample script I got from here

If Exist x:\ Net use x: /delete
If Exist y:\ Net use y: /delete
if "%uername%" == "CFOAccountName" Net Use x: \\Server\Share1
if "%uername%" == "CFOAccountName" Net Use y: \\Server\Share2

I modified it and copied it to a notepad and saved it as .bat, I then put the file in the sysvol\corpnet.net\scripts\logon.bat

I then put only the file name on the user profile path tab in active directory. I did not put anything on profile path, local path, or connect.

It does not work. Any help is appreciated.

Note "%uername%" >>>>>>> do i have to fill in the username in between                       ("%accountname%") or correct the mispelling i tried it both ways

Thanks again
0
elyrodriguez
Asked:
elyrodriguez
  • 7
  • 5
  • 5
  • +1
1 Solution
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Can you be more specific... It doesn't run?  It runs but doesn't connect the drive?  What happens when you run the script manually?
0
 
elyrodriguezAuthor Commented:
when I log in the user, it does not run and it does not map. nothing happens. when i double click the script it does not give me any errors.
0
 
haim96Commented:
note that it sould be %username% so if yo ucopy paste,you have it worng in your script.
any way %username% is system variable. try to type "echo %username%"
in command line and you will get the user that you logon with.

what you tring to do with your script ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
elyrodriguezAuthor Commented:
my original question and task was to try to automatically map a network folder to follow my CFO that uses different PCs joined to the domain. He does not know how to map network drives and he does not have the patience for it either. So I was trying script that network folder.

thanks for the help
0
 
haim96Commented:
you need to put the script name  in the logon script line
in the profile tab. (should be like: "logon.bat" or somthing ...)
i test your code and it should work .(just fix to "username")
0
 
oBdACommented:
Your problem, apart from the obvious typo, is the check for the user name. %Username% will contain the name as typed by the user in the logon screen, and the check if two environment variables have the same value is by default case sensitive. Use the parameter "/i" in the "if ..." statement:

if /i "%username%"=="CFOAccountName" Net Use x: \\Server\Share1
if /i "%username%"=="CFOAccountName" Net Use y: \\Server\Share2

and it should work.
0
 
elyrodriguezAuthor Commented:
Ok, tried a few things.This is my script word by word:

If Exist G:\ Net use G: /delete
if echo "%username%" == "Jeff" Net Use G: \\PDC\share1

However, under "Home folder" I connected G: To \\PDC\share1 on the User Profile in Act. Dir. and it give me an Act Dir warning:

"The \\PDC\share1 home folder was not created because you do not have create access on the server. the user account has been updated with the new home folder value but you must create the directory manually after obtaining the required access rights."

However, when the user logs in, it gives me this question in the command prompt:

there are open files and/or imcomplete directory searches pending on the connection to G:. Is it OK to continue disconnecting and force them closed?(Y/N):

The only way I am able to map the network folder to the user is when I do the above which gives me that message. If I do not connect the drive on the Home folder section nothing happens: i cannot find the network folder.

 
0
 
oBdACommented:
If you enter a drive letter and a share path as home folder in the user's profile, this drive will be mapped automatically during logon; there's no need to remap it manually in the logon script. The share mapped should be per user, though, something like
\\SomeServer\HomeShare\%Username%
Just correct the two lines as I mentioned above, and remove the G: drive mapping from the logon script.
0
 
haim96Commented:
did you share the folder  " \\PDC\share1 " ?
(right click on the folder,select "sharing" from the menu)
if you didn't share it you won't be abale to map it with NET USE
and maping it with "home folder" give you the messege you write.
0
 
elyrodriguezAuthor Commented:
Thanks It worked I took the settings off the "Home folder connect" and modified the script to

if /i "%username%"=="CFOAccountName" Net Use x: \\Server\Share1

it worked beautifully.

please reply so i can accept to OBDA

thanks everyone else for the help
0
 
haim96Commented:
great you have it work !
chears.
0
 
oBdACommented:
elyrodriguez,
seems like you accepted the wrong answer; you can post a zero-point question at Community Support (http://www.experts-exchange.com/Community_Support/) to have this question re-opened.
0
 
haim96Commented:
buhhhh ..... yes he did !! sorry oBdA ... didn't ment to "steal" your point....  :(
0
 
elyrodriguezAuthor Commented:
Ok, sorry but I encountered another problem. I was able to map the network folder to the account I wanted to. However, I tried with another account and it didnt map.

The settings are still the same.

If exist D:\ Net use D: /delete
if /i "%username%"=="CFOAccountName" Net Use D: \\Server\Share1

the name of the script is logon.bat and is sitting in windows\sysvol\...\...\scripts

then logon.bat is in the user profile under logon script.

dont know exactly what I missed. Please Help.
0
 
oBdACommented:
I suspect that D: is already taken by a CD-ROM drive.
0
 
elyrodriguezAuthor Commented:
No, C: and D: are hard drives. E:>>CD DRIVE and F:>>DVD DRIVE
0
 
oBdACommented:
Doesn't matter whether it's a CD or a hard drive; if a drive letter is already taken by a local drive, then you can't use it for a network drive (unless you free the drive using the drive management console, which may lead to other problems ...). Use a free drive letter, and use one that is not used locally on any machine the user will be logging on to.
0
 
elyrodriguezAuthor Commented:
excellent it worked, thanks for the help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 5
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now