Recommended Posts

So our old login script has been failing quite often so it was my job to make a new one and get it working optimally. For the last 2 weeks I've had 5 people in our office running the test script. And while I haven't been getting any errors I've been noticing some delays in the script actually launching.

On the server I enabled \Computer Configuration\Administrative Templates\System\Logon- Run Login Scripts Synchronously. But that only created problems with the computer hanging or taking extremely long time for the OS to load.

So I then tried \Computer Configuration\Administrative Templates\System\Logon\Always wait for the network at computer startup / shutdown and that really didn't workl.

I currently have the Group Management Policy Console doing the handling of the script. Would it work more efficiently if I just went into Active Director and specified the logon script there?

During the week every time they log in it works. But after the weekend is over, where we haven't logged in for a while, the script either fails to execute or take a few minutes then will execute.

Link to comment
https://www.neowin.net/forum/topic/622055-logon-script/
Share on other sites

Attaches 3 network drives and 9 printers.

Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3, shell
Dim strDriveLetter1, strDriveLetter2, strDriveLetter3, strUserName
Dim strDrive, objshell, objunc, strLoggedOnUser, strNewName1, strNewName2, strNewName3

strDriveLetter1 = "R:"
strDriveLetter2 = "S:"
strDriveLetter3 = "T:"
strRemotePath1 = "\\rdaserver\rda files"
strRemotePath2 = "\\rdaserver\base files"
strRemotePath3 = "\\rdaserver"
strNewName1 = "RDA Shared Files"
StrNewName2 = "RDA Base Files"

Set objNetwork = CreateObject("WScript.Network")

' Section which maps the drives
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2

strUserName = objNetwork.UserName

objnetwork.MapnetworkDrive strDriveLetter3, strRemotePath3 & "\" & strUserName

strNewName3 = strUserName & "'s Personal Folder"

' Section which actually (re)names the Mapped Drive
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter1).Self.Name = strNewName1
objShell.NameSpace(strDriveLetter2).Self.Name = strNewName2
objShell.NameSpace(strDriveLetter3).Self.Name = strNewName3

set shell=createobject("wscript.shell")
shell.run "logon.bat"
set shell=nothing

objNetwork.AddWindowsPrinterConnection "\\RDAServer\Cottonwood"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Maple"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Pine"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Rainbow"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Starburst"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Redwood"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Oak"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Sequoia"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Skittles"

Wscript.Quit

The code itself is very efficient and I've never gotten errors. It just seems that login is not authenticating automatically and pulling the GOP right away.

Edited by Unholee
Link to comment
https://www.neowin.net/forum/topic/622055-logon-script/#findComment-589232023
Share on other sites

The default update interval for Group Policy on the Domain controllers is 5 minutes.

The default update interval for User Group Policy is 90 minutes with a random offset of 30 minutes.

The default update interval for Computer Group Policy is 90 minutes with a random offset of 30 minutes.

Unless you do a gpupdate /force

And I've had good success with using it as a users logon script in gpo

Link to comment
https://www.neowin.net/forum/topic/622055-logon-script/#findComment-589248953
Share on other sites

  • 1 month later...

The first thing I would do is split your printers part into their own vbs.

Printer drivers can be very tempremental and if the install of a driver has a error the script will die.

Also you can check to see if the mapped drive already exists before mapping it.

I dont have my scripts to hand, they have error logging as well built in to track problems.

I will upload on monday.

Link to comment
https://www.neowin.net/forum/topic/622055-logon-script/#findComment-589315756
Share on other sites

  ZeroHour said:
The first thing I would do is split your printers part into their own vbs.

Printer drivers can be very tempremental and if the install of a driver has a error the script will die.

Also you can check to see if the mapped drive already exists before mapping it.

I dont have my scripts to hand, they have error logging as well built in to track problems.

I will upload on monday.

if you're running Ad (Active Directory) it's best to load the login script into the AD-groups & users logon.bat;i have setup several AD networks which require automatic mapping of network drives, ras servers and the sort, and found it works best when the AD-user logon.bat executes the command.

and if i'm not mistaken, anytime you load code into group policy ect, it has to reload it into the network startup load. which takes awhile.

Link to comment
https://www.neowin.net/forum/topic/622055-logon-script/#findComment-589319191
Share on other sites

Well I've pretty much figured out the problem of what happened.

The IT guy before me set up the AD with a Windows 2000 AD with cached log in. All the desktop computers recognized the script on startup but the laptops were having an issue. I tweaked some settings and right now I'm having a 100% success.

Instead of having the GPMC handle the script, I've just gone to their profile in dsa.msc and having the .vbs script run there. That's what I've changed.

Zerohour I'm pretty new at .vbs scripting but I changed the script to have this end if statement (so far it's worked just fine)

Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3, shell
Dim strDriveLetter1, strDriveLetter2, strDriveLetter3, strUserName
Dim strDrive, objshell, objunc, strLoggedOnUser, strNewName1, strNewName2, strNewName3
Dim objDrive, objFSO

On Error Resume Next
If objFSO.DriveExists(strDrive) = False Then

strDriveLetter1 = "R:"
strDriveLetter2 = "S:"
strDriveLetter3 = "T:"
strRemotePath1 = "\\rdaserver\rda files"
strRemotePath2 = "\\rdaserver\base files"
strRemotePath3 = "\\rdaserver"
strNewName1 = "RDA Shared Files"
StrNewName2 = "RDA Base Files"

Set objNetwork = CreateObject("WScript.Network")

' Section which maps the drives
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2

strUserName = objNetwork.UserName

objnetwork.MapnetworkDrive strDriveLetter3, strRemotePath3 & "\" & strUserName

strNewName3 = strUserName & "'s Personal Folder"

' Section which actually (re)names the Mapped Drive
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter1).Self.Name = strNewName1
objShell.NameSpace(strDriveLetter2).Self.Name = strNewName2
objShell.NameSpace(strDriveLetter3).Self.Name = strNewName3

set shell=createobject("wscript.shell")
shell.run "logon.bat"
set shell=nothing

objNetwork.AddWindowsPrinterConnection "\\RDAServer\Cottonwood"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Maple"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Pine"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Rainbow"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Starburst"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Redwood"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Oak"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Sequoia"
objNetwork.AddWindowsPrinterConnection "\\RDAServer\Skittles"

Wscript.Quit
end if

Would you recommend I just set up another end if statement on a new printers script?

P.S I've never had a problem with the printers loading in the script.

Link to comment
https://www.neowin.net/forum/topic/622055-logon-script/#findComment-589324081
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.