jplatovsky
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.Netw ork")
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.AddWindowsPrinterConn ection "\\Printers\HP LaserJet M604 (OFFICE)", "HP LaserJet M604"
oNet.AddWindowsPrinterConn ection "\\Printers\Kyocera TASKalfa 6002i KX (Office)", "Kyocera TASKalfa 6002i KX"
oNet.SetDefaultPrinter "\\Printers\Kyocera TASKalfa 6002i KX (Office)"
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.Netw
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.AddWindowsPrinterConn
oNet.AddWindowsPrinterConn
oNet.SetDefaultPrinter "\\Printers\Kyocera TASKalfa 6002i KX (Office)"
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 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 PrintersUse 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
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 TRIALMembers 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.
https://blogs.technet.microsoft.com/askds/2009/01/07/using-group-policy-preferences-to-map-drives-based-on-group-membership/
https://blogs.technet.microsoft.com/canitpro/2015/02/03/step-by-step-setting-up-printers-via-group-policy/