logon script to add default printer and a network drive

rookie_b used Ask the Experts™
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!
Watch Question

Do more with

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

fairly simple.

Map drives using:

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


set the default printer

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

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 
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


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?

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.




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


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