logon script to add default printer and a network drive

rookie_b
rookie_b used Ask the Experts™
on
Hi guys,

I have a group of users that need to have a printer added and set as default, and also add a network drive. So, basically a need a script and then a way to add the script to the group of users. Can you help?

Thank you!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
fairly simple.

Map drives using:

net use <drive letter> <share ie \\server\share>

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true

set the default printer

I'd personally go for rundll32 printui as it's free and easy:

http://www.computerperformance.co.uk/Logon/logon_printer_computer.htm
I have customized the script from computerperformance in the better way for your requirement.

You need to create Group Policy (Say LoginScript_DepName_verXX) , where you should configure - user configuration - logon script , and add the below script.

Things to note :

Uncheck authenticated users - from Apply Policy - from the Security Permission of the Group policy

Create a group with the same of Group Policy

Add those users in the Group

Now add this Group in the security permission of Group Policy Object and give apply policy Permission

---

In Short, only users who is member of this particular group will be affected by this policy

Make sure that Group policy is linked to the OU where users are located

Please let me know if you have any queries


Dim objNetwork 
Dim strDriveLetter, strRemotePath
 
Dim objNetwork, strUNCPrinter
 
 
strDriveLetter = "J:" 
strRemotePath = "\\alan\home" 
 
strUNCPrinter = "\\LittleServer\HP LaserJet 2420"
 
' Purpose of script to create a network object. (objNetwork)
' Then to apply the MapNetworkDrive method.  Result J: drive
Set objNetwork = CreateObject("WScript.Network") 
 
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath 
WScript.Quit
 
 
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection strUNCPrinter
 
' Here is where we set the default printer to strUNCPrinter
objNetwork.SetDefaultPrinter strUNCPrinter
 
 

Open in new window

Author

Commented:
ok, thanks. I got the script I want and it works fine. How do I add it to all users in a group or OU?

Thanks!
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

PLease go through my above comment.Please let me know if you have any queries.

 

Author

Commented:
Ok,

I created the policy at the OU level
I chose the login script from the logon user settings of the policy
I un-tick apply policy on authenicated users
I add the group to the security settings of the policy and ticked apply policy

Cannot get it to work
It works if I manually add the logon script to the user

Author

Commented:
Created the  policyat the OU level and copied the script from the sysvol to the logon folder (where you are prompted to browse by default) and then worked great. Thank you for your help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial