Link to home
Start Free TrialLog in
Avatar of alanheaton
alanheaton

asked on

Logon Scripts

I must be missing something here !!

I am running W2k3 server with AD

I want to create some logon scripts for user to share some network drives stored on the server.

I have created a folder on my server xcalled 'Logon Scripts' and shared it appropriately.

I have created a text document and put in it EG
net use n:\\servername\music

Saved this in 'Logon Scripts' as 'test.vbl'

When I go into AD and for the user under profile put \\servername\test.vbl

When I log onto a workstation, nothing.

I am probably do the whole thing wrong.

Any help please, or point me in the right direction.
Avatar of Lazarus
Lazarus
Flag of United States of America image

your login scripts need to go into your NETLOGON directory. i.e... \\SERVERNAME\NETLOGON
Also, your login scripts will need to either be .BAT (batch files) or .VBS (Visual Basic Script)
SAMPLE VBS Login script. named: login.vbs

Set objNetwork = CreateObject("WScript.Network")
' Forces script to skip errors (rem below line to see errors)
on error resume next
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")

WshNetwork.RemoveNetworkDrive "J:"

WshNetwork.MapNetworkDrive "J:", "\\haw-9000\ERI"

'deletes all network printers
Set clPrinters = WshNetwork.EnumPrinterConnections
On Error Resume Next
For i = 0 to clPrinters.Count - 1 Step 2
wshNetwork.RemovePrinterConnection clPrinters.Item(i+1), true
Next

Set WshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\H-student-1\HPLaserJ"
PrinterDriver = "hP LaserJet 6P"
WshNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver
WshNetwork.SetDefaultPrinter "\\H-student-1\HPLaserJ"

' WScript.Echo "Your Drive & Printer Mappings are complete and you belong to the STUDENTS Group"

WSCript.Quit
'  End of Jim's VBScript
Avatar of alanheaton
alanheaton

ASKER

So I have now created a simple text doc

net use n:\\myservername\music

saved it as a .VBS file in my NETLOGON folder on my file server

So when I go into the user profile how do I get it to access the share

I have tried \\servername\NETLOGON\test.vbs

and

\\servername\test.vbs

Which way?
well if its a vb.s file it has to be written in visual basci. If you want to use NET USE, thats in the BATCH file for that would be called:
test.bat

The questin is where are you telling the user login in that the file should be used? from a GP or from the User Properties in Active Directory Users and Computers > Profile Tab, Login Script ?
User Properties in AD under profile then in login scripts?

Take on board batch file

sorted that one

just need to know how to get them to work now

Thanks.

I have increased points for your patience, keep them coming
Just enter the login script name, as you did during testing. For example, enter "login.bat" not "c:\login.bat".
I still cant get this to work.

Lets recap

I am running W2k3 server, set up as a file server. Within the file server there is a shared folder called NETLOGON.
Within NETLOGON I have created a file in Notepad, which reads

net use n:\\myservername\music

Music is a shared folder I have set up on my F drive and shared with all users. I saved this file as test.bat

I then went in Active directory, under account test and then on profile tab.
at Logon Script I typed '\\myservername\test.bat'

When I log onto test I am expecting a network drive under My Computer 'N:Music'

But nothing. I have changed it in profiles to 'test.bat' but still nothing.

I am obviously making a mess of this somewhere?
ok, I'll go over this again: on your SERVER (lets say the server name is "HAL-9000" plave your login.bat inside the directory: \\HAL-9000\NETLOGON
Your script should look exactly like this inside:

@net use I: \\notb\music /y

The" /y" will auto-answer yes for that mapping instead of giving the user a choice.

Then in your "Active Directory Users and Computers"   which is "C:\WINDOWS\system32\dsa.msc" got to the users that you want to make them use a login script for and in their properties go to "PROFILE" tab and in the "LOGIN SCRIPT" place the name of your login script in your case: "login.bat" withou parenthesis of course.

I have tested this out exactly as I have done for ages, again to see if I was doing something wrong and as always it still works correctly for me. If it does not work for you, inside your script at the bottom of the text place a pause so that it will stop the bat file. This will allow you to be able to copy and paste what it says is erroring to me. The script would then look like this

@net use I: \\notb\music /y
pause

Let me know how that goes... Good luck
Just a quick question

do I have to put the '@' at the start ?

and what is the '\\notb' (Sorry not seen that abreviation before.) or is 'name of the base'
ah.. sorry.. about the flaw in the script.. plave the name of your server where notb is.. That was a careless mistake on my part. Thats from an example script i used before.. and yes place the @sign before it
It should be:

@net use I: \\YOURSERVERNAME\music /y
Well it dont work.

Nothing happenning.

I have followed everything as you have put.

I have just had a look at my file server, and I have a folder called NETLOGON and a folder called SYSVOL

Both of these folders contain my Logon Script

But either way it aint workin. I have even put the pause on the end, but nothing happening.
NETLOGON is the share for C:\WINDOWS\sysvol\sysvol\SERVERNAME\scripts.
Please place the pause at the botom of you batch file. When you logon you batch file should come up and then stop when it hits the pause. Copy and paste what it say in you DOS box here so that i can see it, perhaps I can then tell you whats going on... Unless of course it's not even coming up.

Can you please tell me more detail about what and how you are testing this?  Does the login.bat work if you just run it?
Can you provide any screen shots perhaps?
When I logon to test nothing happens.

The way I understand it you should get a black box for a second while it connects, but I dont even get the box

How can I test it?

When I double click it the screen flashes black but that is it?

Hang On.

C:\WINDOWS\sysvol\sysvol\SERVERNAME\scripts.

were it says servername mine shows my domainname not server name?

EG Server caled test1 : Domain called test2.co.uk

C:\WINDOWS\sysvol\sysvol\test2.co.uk\scripts.
yes.. thats is correct. the SERVERNAME is just representative of anyname that the server is given... please in your script.. place PAUSE on the last line of the script.
then just goto your NETLOGON directory and run the batch file and paste what it say in the DOS BOX so that I may see what might be in error.
I have put pause in

When I double click the batch file, it just flashes black for a mili second. I can even read what it says
Somehting is wrong then. for sure. It should pause and stay open. Can you please paste your script that you have.
@net use N:\\server2003\Music /y
pause

server2003 is the name of my server and Music is the name of the shared folder that I want to map.

and N is the letter that I want to assign.
ok.. I see one error...

@net use N:\\server2003\Music /y
should be:

@net use N: \\server2003\Music /y

there is no space after the N:, you have to have that space...

but that does not explain why it is not pausing.. Try it though and see if it maps your drive though, but leave the PUASE in there. Your script should look like this:

rem ======= BEGIN SCRIPT========
@net use N: \\server2003\Music /y

pause
rem ======= END SCRIPT========

I only placed the REM statments to show start and end

OK I have changed it.

But it still doesn't stay on the screen, the screen just flashes black.

I am assuming the box should stay up so I can read what is in it.
I have just tried it on MY XP machine, and it does exactly the same just flashes.
So, can you run any batch file of any sort at all? This is pretty wierd so far. You have something wrong, but I can not place what it could be at the moment.
Perhaps let us try this instead for the moment. its a VB script instead that will do the same thing. but it will be called login.vbs instead. place it in the same place as the other.

sample script:

Set objNetwork = CreateObject("WScript.Network")
' Forces script to skip errors (rem below line to see errors)
on error resume next
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")

WshNetwork.MapNetworkDrive "N:", "\\server2003\Music"

WSCript.Quit
'  End of Jim's VBScript


Let me know if that works at all...
Sorry Nothing

I dont believe this

I have spent the last 2 weeks trying to get Outlook 2003 to talk to My Exchange server, and couldn't get that to work either.

Now I can't get Logon Scripts to work either !!!

Not having much success?

I have copied your script into Notepad and saved it in the same folder as the other but called it logon.vbs

change user test/profiles/logon scripts to 'logon.vbs'

Nothin

When I click on it to test it the screen doesn't even flash
ASKER CERTIFIED SOLUTION
Avatar of Lazarus
Lazarus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK

I will leave this for the min.

MAybe come back to it later

Thanks for your time and effort

My next mission is a VPN Connection, see if I can get that to work

LOL