Link to home
Start Free TrialLog in
Avatar of jplatovsky
jplatovskyFlag for United States of America

asked on

User Logon Script

I am trying to create a login script that will map a network drive and add printers
below is the script i am using and every time it gets to the map drive it errors and says  the drive is already mapped.
so i thought about adding the removenetworkdrive prior so that helped a little but when it is a new user the remove error that there is no drive to delete.

any ideas and / or suggestions would be greatly appreciated

' VBScript.
Option Explicit
Dim oNet, sUser, cInitial, startTime
Set oNet = CreateObject("WScript.Network")
sUser = oNet.UserName
startTime = Now

   oNet.RemoveNetworkDrive "F:", True, True
   oNet.RemoveNetworkDrive "H:", True, True

   oNet.MapNetworkDrive "F:", "\\DataServer\Yeshiva", True
   oNet.MapNetworkDrive "H:", "\\DataServer\" & sUser & "$", True

   oNet.AddWindowsPrinterConnection "\\Printers\HP LaserJet M604 (OFFICE)", "HP LaserJet M604"
   oNet.AddWindowsPrinterConnection "\\Printers\Kyocera TASKalfa 6002i KX (Office)", "Kyocera TASKalfa 6002i KX"

   oNet.SetDefaultPrinter "\\Printers\Kyocera TASKalfa 6002i KX (Office)"
Avatar of M A
M A
Flag of United States of America image

Avatar of jplatovsky

ASKER

I do not see - In the Group Policy Management Editor, navigate to Computer Configuration > Policies > Windows Settings > Deployed Printers

I have a designated VM printer server. the drivers currently do not show up in the Printer Server of the DC.
I do not see - In the Group Policy Management Editor, navigate to Computer Configuration > Policies > Windows Settings > Deployed Printers
Use GPO Printer Preferences instead
Hi,

As Shaun said, you're using 15 years old technology, you should do it with GPO preferences today...

Well, if you really want to go on using vbscript, why not put this statement at the begining of the script:

On Error Resume Next


Have good day
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.