Click to See Complete Forum and Search --> : How to make a logon script, that maps network drives ???


jtice
April 29th, 2004, 11:47 AM
We just installed a Windows 2003 server, and are having alot of trouble getting a logon script to work.

We have read the help files, and done what they say, but it still doesn nothing when trying to login to the server.

It will log us in, and let us in the apropriate files, but I dont think the script is wroking, or running at all.
Becuase it is not mapping the network drives and folders, as we told it to.

Please tell me how to write a simple script to map drives and folders at logon, and how to make it run.

Thanks alot.

jtice
April 29th, 2004, 11:56 AM
Here is the script that we are trying to use.


Const ENGINEERING_GROUP = "cn=engineering"
Const FINANCE_GROUP = "cn=finance"
Const HUMAN_RESOURCES_GROUP = "cn=human resources"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "G:", "\\test_share" & wshNetwork.UserName

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, ENGINEERING_GROUP) Then

wshNetwork.MapNetworkDrive "L:", "\\R Folder"

end if

kato2274
April 29th, 2004, 11:57 AM
it's pretty simple. what have you already done? if you can detail what you tried it will make things a lot easier.

but basically the script is just a batch file that utilizes net use commands

i.e.

net use z: \\server\share

and you execute it from the user properties in active directory users and computers. under the profile tab there is a place to specify a logon script.

you must be sure to have the permissions set correctly on the shares so that when you are mapping a share to a drive for a user he/she actually has permissions to use the resource.

kato2274
April 29th, 2004, 12:01 PM
Here is the script that we are trying to use.


Const ENGINEERING_GROUP = "cn=engineering"
Const FINANCE_GROUP = "cn=finance"
Const HUMAN_RESOURCES_GROUP = "cn=human resources"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "G:", "\\test_share" & wshNetwork.UserName

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, ENGINEERING_GROUP) Then

wshNetwork.MapNetworkDrive "L:", "\\R Folder"

end ifif this running server side or client side? this would be SO much easier to do via active directory users and computers

example:
in profiles of engineering group set a logon script of engine.bat

the engine.bat has the command
net use L: \\server\share

for the user specific maps, the %username% variable works in a batch script
ie.
net use Z: \\server\home\%username%

jtice
April 29th, 2004, 12:04 PM
I have tried placing the script in the user part, and under the startup/shutdown parts.

I actually placed the script in EVERY place I could see that you could put a script.

We need this to be a global script, not one that is placed in each users profile. That would take more time to do.

This needs to be a script that is ran when ever ANYone logs in.
Then that script looks to see who logged in, and what drive is supposed to be mapped to them.

When we goto login, it basically does nothing, acts like the script isnt even there.

jtice
April 29th, 2004, 12:07 PM
I dont see where I can assign a script to a group.
I went to properties of the group, as I would a user, and I dont see anythign about it there.

If I goto a users properties, I see where I can add a script.
But not for a group.

kato2274
April 29th, 2004, 12:18 PM
I dont see where I can assign a script to a group.
I went to properties of the group, as I would a user, and I dont see anythign about it there.

If I goto a users properties, I see where I can add a script.
But not for a group.
you're right. I got ahead of myself. what I usually do is setup one user for a group. then just copy that user when I need another user in that group. gives them the same properties. ......I was just thinking of it this way because we have group logon scipts.....i.e. development.bat etc. they aren't actually applied in the group properties, but they are applied to the group when creating a new user and I copy an existing development group user

jtice
April 29th, 2004, 12:25 PM
you're right. I got ahead of myself. what I usually do is setup one user for a group. then just copy that user when I need another user in that group. gives them the same properties. ......I was just thinking of it this way because we have group logon scipts.....i.e. development.bat etc. they aren't actually applied in the group properties, but they are applied to the group when creating a new user and I copy an existing development group user

Ah I see what you are doing.
So, there is no way to assign a script to a group?
Shouldnt there be a way to make a script run when ANYone logs in?
And that script map drives according to who that user is?

I also went to a users profile, and told it to use this script, but it still didnt do anything.

Also, your are mentioning a .bat file, not a .vbs script file, could that be part of it? Or can they both work?

kato2274
April 29th, 2004, 12:32 PM
Ah I see what you are doing.
So, there is no way to assign a script to a group?
Shouldnt there be a way to make a script run when ANYone logs in?
And that script map drives according to who that user is?

I also went to a users profile, and told it to use this script, but it still didnt do anything.

Also, your are mentioning a .bat file, not a .vbs script file, could that be part of it? Or can they both work?vbs scripts should work. have you tried instead of setting the script in users profiles to setting it in the domain group policy. this may be the way to get it to work. try under user configuration - administrative templates - logon - run these programs at user logon setting. set the permissions to everyone.

again . . . . not the way I'd do it. . . . . but this seems viable and may be your answer.

kato2274
April 29th, 2004, 12:59 PM
the script works fine. I ran it on my local machine. (had to change shares and groups and such) but it works just fine.

I would try the group policy approach. I think it should work and would keep it on the server side so that even if someone brings a laptop in and logs onto the domain, the script executes......let me know if it works. I'm curious....but I'm not going to apply it to our production domain http://forums.windrivers.com/images/smilies/wink.gif

jtice
April 29th, 2004, 01:33 PM
the script works fine. I ran it on my local machine. (had to change shares and groups and such) but it works just fine.

I would try the group policy approach. I think it should work and would keep it on the server side so that even if someone brings a laptop in and logs onto the domain, the script executes......let me know if it works. I'm curious....but I'm not going to apply it to our production domain http://forums.windrivers.com/images/smilies/wink.gif


I must be missing something.

I tries everything you said, nothing is mapping the drives.

I even tried your .bat file.
all it has in the command:
use net L \\server1\R Folder

server1 is the name of our server
R Folder is the name of the folder I want to map.

I dont get any error messages at all during logon either.

I went to Group Policy Editor > User Config > Admin Templates > System > Logon > Run these programs at user Logon

NooNoo
April 29th, 2004, 04:17 PM
I even tried your .bat file.
all it has in the command:
use net L \\server1\R Folder



net use L: .....

jtice
April 29th, 2004, 06:30 PM
net use L: .....


Heh, yea, i noticed that.
Still doesnt work. :(

Is there maybe something that I dont have installed?
Or a setting thats not right?

kato2274
April 29th, 2004, 07:02 PM
Heh, yea, i noticed that.
Still doesnt work. :(

Is there maybe something that I dont have installed?
Or a setting thats not right?
OK you gotta attack this one piece at a time. run your script locally on a client machine and also try the net use commands from the local machine. if the script and net use commands work there then you can move to trying to deploy the scripts. if it doesn't you gotta find out why. forget logging in right now. just verify your commands, then worry about deploying themhttp://forums.windrivers.com/images/smilies/bigok.gif

jtice
April 29th, 2004, 09:57 PM
OK you gotta attack this one piece at a time. run your script locally on a client machine and also try the net use commands from the local machine. if the script and net use commands work there then you can move to trying to deploy the scripts. if it doesn't you gotta find out why. forget logging in right now. just verify your commands, then worry about deploying themhttp://forums.windrivers.com/images/smilies/bigok.gif


I now know that
net use Z: \\CompName\Folder
Does work if ran on a machine locally.

Now, there must be something either making the script not run, or the login itself not calling it up properly.

What this is from, I do not know yet, i am betting some configurration i am missing.

jtice
April 30th, 2004, 09:37 AM
It also seems that the other computers are actually logging on, becuase they will goto the folders on the server, and have access to them.

So they are logging on, but they are not running the bat scripts.
Which do work, if ran locally on the machines.

thelight
June 22nd, 2004, 05:00 PM
It also seems that the other computers are actually logging on, becuase they will goto the folders on the server, and have access to them.

So they are logging on, but they are not running the bat scripts.
Which do work, if ran locally on the machines.

We just had this exact same problem. Not sure if our solution will be the same as yours, though. Our problem was that we were editing the wrong group policy (we were editing the domain controller policy by mistake).

Here we go...
[ctrl+c] your script (not the contents, but the file itself) to copy it to your clipboard.

Start up the MMC and add a snap in for editing group policies. When prompted to select a group policy to edit, hit browse. Make sure you select the default domain policy.

Open the default policy snap in, go to User Configuration -> Windows Settings -> Scripts. In the details pain, double click logon

In the box that opens, click “Add”. This should be looking familiar.

Under script name, press browse.

Right-click on the file list and Press Paste.

Select your neatly copied script.

Ok everything.

Run gpupdate on your test machine to update your group policy.

Test it out.

Hope this helps.

NooNoo
June 24th, 2004, 11:44 AM
Welcome to Windrivers thelight and thanks for your solution.