?
Solved

Logon Scripts

Posted on 2005-04-23
24
Medium Priority
?
16,013 Views
Last Modified: 2010-08-05
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.
0
Comment
Question by:alanheaton
  • 12
  • 12
24 Comments
 
LVL 20

Expert Comment

by:Lazarus
ID: 13851808
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)
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 13851820
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
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13851839
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?
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 20

Expert Comment

by:Lazarus
ID: 13851903
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 ?
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13851914
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
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 13851927
Just enter the login script name, as you did during testing. For example, enter "login.bat" not "c:\login.bat".
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13853540
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?
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 13854197
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
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13854280
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'
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 13854302
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
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13854802
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.
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 13854827
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?
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13854855
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.
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 13854883
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.
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13854886
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
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 13854896
Somehting is wrong then. for sure. It should pause and stay open. Can you please paste your script that you have.
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13854915
@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.
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 13854940
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

0
 
LVL 2

Author Comment

by:alanheaton
ID: 13854975
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.
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13854982
I have just tried it on MY XP machine, and it does exactly the same just flashes.
0
 
LVL 20

Expert Comment

by:Lazarus
ID: 13855013
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...
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13855111
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
0
 
LVL 20

Accepted Solution

by:
Lazarus earned 1500 total points
ID: 13855762
Well the .vbs script should not show at all. It should just give you the Drive Mapping. If that is not working you have something blocking things. Unfortunately, I'd need alot more info on your system to even get close as to why it's not working. A VB script or BAT file should work on either computer just by running it. If it were doing that at least I could say that the only thing wrong was your Active Directory or something. But with them not running at all... Thats somehting much more involved for sure.
0
 
LVL 2

Author Comment

by:alanheaton
ID: 13856339
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
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.

Question has a verified solution.

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

I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

809 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