Link to home
Start Free TrialLog in
Avatar of gdcobb
gdcobbFlag for United States of America

asked on

Windows scrip is not running on one specific pc

We are running win2003 server, and xp prof clients. Script logon.vbs doesn't work on one specific PC. Interesting is that same script works without problem for the same users on other clients. When user logs in on that not working pc scrip gives error:

---------------------------
Windows Script Host
---------------------------
Script:      \\backup\netlogon\logon.vbs
Line:      60
Char:      5
Error:      This network connection does not exist.

Code:      800708CA
Source:       WSHNetwork.RemoveNetworkDrive

---------------------------
OK  
---------------------------


I don't know is it network settings or something but everything looks the same to me. I don't think we have to look at script coz 50+ computers works with no problem just that on doesn't.


Any ideas?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of TyBeatty
TyBeatty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gdcobb

ASKER

Option Explicit

Dim objRootDSE, objTrans, strNetBIOSDomain, objNetwork, strNTName
Dim strUserDN, strComputerDN, objUser, strDNSDomain
Dim strComputer, objComputer, objGroup1, objGroup2
Dim strHomeDrive, strHomeShare
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path, strUNCPrinter

' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

Set objNetwork = CreateObject("Wscript.Network")

' Loop required for Win9x clients during logon.
strNTName = ""
On Error Resume Next
Do While strNTName = ""
  strNTName = objNetwork.userName
  Err.Clear
  If Wscript.Version > 5 Then
    Wscript.Sleep 100
  End If
Loop
On Error GoTo 0

' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://cxmserver/RootDSE")
on error resume next
strDNSDomain = objRootDSE.Get("defaultNamingContext")

' Use the NameTranslate object to find the NetBIOS domain name from the
' DNS domain name.
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_1779, strDNSDomain
strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove trailing backslash.
strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1)

' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strNTName
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)

' Bind to the user object in Active Directory with the LDAP provider.
Set objUser = GetObject("LDAP://" & strUserDN)


' Bind to a group object in Active Directory with the LDAP provider.
Set objGroup1 = GetObject("LDAP://cn=Software,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "S:", "\\cxmserver\data$\software"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "S:", True, True
    objNetwork.MapNetworkDrive "S:", "\\cxmserver\data$\software"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Kronos,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "K:", "\\Cxmserver\Data$\Kronos"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "K:", True, True
    objNetwork.MapNetworkDrive "K:", "\\Cxmserver\Data$\kronos"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Everyone Drive,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "I:", "\\Cxmserver\Data$\Everyone"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "I:", True, True
    objNetwork.MapNetworkDrive "I:", "\\Cxmserver\Data$\Everyone"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Minitab,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "M:", "\\Cxmserver\Data$\minitab 14"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "M:", True, True
    objNetwork.MapNetworkDrive "M:", "\\Cxmserver\Data$\minitab 14"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Bar Code Group,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "Q:", "\\cxmserver\data$\legi"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "Q:", True, True
    objNetwork.MapNetworkDrive "Q:", "\\cxmserver\data$\legi"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Payroll Group,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "Z:", "\\cxmserver\data$\Payroll"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "Z:", True, True
    objNetwork.MapNetworkDrive "Z:", "\\cxmserver\data$\Payroll"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=prism documentation group,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "X:", "\\axis\volumes"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "X:", True, True
    objNetwork.MapNetworkDrive "X:", "\\axis\volumes"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=jde documentation group,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "X:", "\\axis\volumes"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "X:", True, True
    objNetwork.MapNetworkDrive "X:", "\\axis\volumes"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Microxcel CMM Group,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "I:", "\\cxmserver\data$\everyone\engineer"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "I:", True, True
    objNetwork.MapNetworkDrive "I:", "\\cxmserver\data$\everyone\engineer"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Die Room EDM group,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "I:", "\\cxmserver\data$\everyone\engineer\dieroom\edm"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "I:", True, True
    objNetwork.MapNetworkDrive "I:", "\\cxmserver\data$\everyone\engineer\dieroom\edm"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=prints,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "I:", "\\cxmserver\data$\Everyone\ENGINEER\Prints"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "I:", True, True
    objNetwork.MapNetworkDrive "I:", "\\cxmserver\data$\Everyone\ENGINEER\Prints"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Die Room Inventory Group,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "I:", "\\cxmserver\data$\everyone\logs\EN - Engineering"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "I:", True, True
    objNetwork.MapNetworkDrive "I:", "\\cxmserver\data$\everyone\logs\EN - Engineering"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Judie,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "J:", "\\cxmserver\data$\Home\jcuprisin"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "J:", True, True
    objNetwork.MapNetworkDrive "J:", "\\cxmserver\data$\Home\jcuprisin"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Mobile Users,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "H:", "\\cxmserver\data$\Home\pbalson"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "H:", True, True
    objNetwork.MapNetworkDrive "H:", "\\cxmserver\data$\Home\pbalson"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=DWG,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "J:", "\\cxmserver\data$\Everyone\ENGINEER\DWG"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "J:", True, True
    objNetwork.MapNetworkDrive "J:", "\\cxmserver\data$\Everyone\ENGINEER\DWG"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=all Clear,ou=Groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "O:", "\\Cxmserver\Data$\AllClear"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "O:", True, True
    objNetwork.MapNetworkDrive "O:", "\\Cxmserver\Data$\AllClear"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=jmillermobile,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "H:", "\\cxmserver\data$\Home\jmiller"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "H:", True, True
    objNetwork.MapNetworkDrive "H:", "\\cxmserver\data$\Home\jmiller"
  End If
  On Error GoTo 0
End If

Set objGroup1 = GetObject("LDAP://cn=Maintenance schedule,ou=groups,dc=cxm,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
  On Error Resume Next
  objNetwork.MapNetworkDrive "H:", "\\Cxmserver\Data$\Everyone\Maintenance\Schedules"
  If Err.Number <> 0 Then
    On Error GoTo 0
    objNetwork.RemoveNetworkDrive "H:", True, True
    objNetwork.MapNetworkDrive "H:", "\\Cxmserver\Data$\Everyone\Maintenance\Schedules"
  End If
  On Error GoTo 0
End If

Set WshNetwork = WScript.CreateObject("WScript.Network")
On Error Resume Next
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
PrinterPath = "\\cxmserver\Finishing LJ 5si"
PrinterExists = False
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
        If WSHPrinters.Item(LOOP_COUNTER +1) = PrinterPath Then
          PrinterExists = True
        End If
Next
If PrinterExists = 0 Then
  WshNetwork.AddWindowsPrinterConnection "\\cxmserver\Finishing LJ 5si"
End If

Set objNetwork = Wscript.CreateObject ("WScript.Network")

objNetwork.AddWindowsPrinterConnection "\\cxmserver\Maintenance Dell1700"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Purchasing"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Shipping dell 1700"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Die Room LJ 2100"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Lab LJ1700"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Finishing lj4000"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Copier Canon IR5000"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\DellColor"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Customer service"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\HPLaserJet 2100"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Accounting Color"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Accounting Color (Black)"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\HR LJ3015"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Maintenance toshiba"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\HP Designjet Z2100 44in Photo"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Shipfax"
objNetwork.AddWindowsPrinterConnection "\\cxmserver\Casting LJ2100"

Set objNetwork = Wscript.CreateObject ("WScript.Network")


' Clean up.
Set objRootDSE = Nothing
Set objTrans = Nothing
Set objNetwork = Nothing
Set objUser = Nothing
Set objComputer = Nothing
Set objGroup1 = Nothing
Set objGroup2 = Nothing
Does the logon script complete the rest of it's jobs and is everthing ok at the end?

Basically it looks like that is the line that reads...
    objNetwork.RemoveNetworkDrive "S:", True, True

So if the S: drive does not exist it could throw that error because it cannot remove a drive mapping that is not there.
Avatar of gdcobb

ASKER

I deleted line 60
so now script gives me error on the line 60 again (original script would be line 61 you know what i mean)

---------------------------
Windows Script Host
---------------------------
Script:      C:\Documents and Settings\sjohnson\Desktop\logon.vbs
Line:      60
Char:      9
Error:      The system detected a possible attempt to compromise security. Please ensure that you can contact the server that authenticated you.

Code:      800704F1
Source:       WSHNetwork.MapNetworkDrive

---------------------------
OK  
---------------------------
SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Presumably this user is a member of the "software" group so continues to this section, and also may have an issues as suggested above.  Please check the real error which is occuring during the connection please as follows:

Running these commands instead:

 on error resume next
 wscript.echo "Trying S:"
 objNetwork.MapNetworkDrive "S:", "\\cxmserver\data$\software"
 if err.number <> 0 then wscript.echo "Error S:" & err.number & " " & err.description

for me for instance returns the following as I have a local "S:" drive:

Trying S:
Error S:-2147024811 The local device name is already in use.
 
Avatar of gdcobb

ASKER

This PC turns out has more problems windows just started to act  funny (some menu items missing, doesn't select options and etc) so I don't see reason to deal with it i'll go and rebuild it. Thanks for the thought i will spread the points
Avatar of gdcobb

ASKER

The problem is not related with script.
Fair enough, trouble when we let users at the Pc's :-)