troubleshooting Question

VB logon script only works at second logon

Avatar of yccdadmins
yccdadmins asked on
VB Script
13 Comments1 Solution724 ViewsLast Modified:
Greetings all,

I've run into a strange VBScript error with a logon script I've created.  At one point the script has to copy a shortcut to the end users desktop.  This has to be copied at each logon because the URL will change from one server to another depending on which is the primary.

When the URL in the source file is changed to a new server, end users log in and the script should overwrite the existing file with the new one that has the correct URL.

Problem is, the script only seems to work the second time the end users log in.  Below is the script and any help would be great....

On Error Resume Next

'-----------------------------------------------------
'Set variables for group determination etc.
'-----------------------------------------------------
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
Set WSHShell = CreateObject("Wscript.Shell")
Set WSHProcess = WSHShell.Environment("Process")
'Set objShell = CreateObject(wscript.shell)

'-----------------------------------------------------
'Get the distinguished name of the user that logged on
'-----------------------------------------------------
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)


'-----------------------------------------------------
'Report back the groups the user belongs to.
'-----------------------------------------------------
For Each strGroup in objUser.MemberOf
    strGroupPath = "LDAP://" & strGroup
    Set objGroup = GetObject(strGroupPath)
    strGroupName = objGroup.CN

'-----------------------------------------------------
'Get the Logon Server and end script if not xxxxxxx
'-----------------------------------------------------
'DomainLogonServer = WSHProcess("LogonServer")



'---------------------------------------------------------------
' Call the AD Security Group and copy appropriate shortcut.
'---------------------------------------------------------------


      Select Case strGroupName

        Case "TN-BACS Users"
           
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            set WshShell = WScript.CreateObject("WScript.Shell")
            tDesktopPath = WshShell.SpecialFolders("Desktop")
            objFSO.CopyFile "C:\Scripts\Shortcut\Picture Perfect 4 Client.*", tDesktopPath, True

        Case "TN-BACSWEB-Users"
           
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            set WshShell = WScript.CreateObject("WScript.Shell")
            tDesktopPath = WshShell.SpecialFolders("Desktop")
            objFSO.CopyFile "C:\Scripts\Shortcut\BACSWEB.*", tDesktopPath, True


    End Select



Next
ASKER CERTIFIED SOLUTION
alicain

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros