Advertisement

09.04.2007 at 11:47AM PDT, ID: 22806105
[x]
Attachment Details

VBS Script not running on Vista

Asked by bheroniphr in Windows Vista, Windows XP Operating System, VB Script

Tags: vista, script, vbs, running

Hi,

I run a domain of ~50 nodes all on XP Pro. I have a GPO that runs a vbs script upon login to map various network drives. This works very nicely.

I have just put our first Vista system on the network and it doesn't want to map the drives. In case the script was using functions from .NET 1.1 or .NET 2.0 I have installed these but this has made no difference. The script is below.

Anyone got any ideas why it is not working?

Thanks





'      Main Script for xxxx Drive Mappings
'      03/10/06 - Benjamin xxxx
'      ben.xxx@domain.com


'      ----------------------------------------------------------------------------------




'
'Group Identification
'

Const IT_GROUP = "cn=it"
Const ANIMATION_GROUP = "cn=animation"
Const ART_GROUP = "cn=art"
Const AUDIO_GROUP = "cn=audio"
Const CODE_GROUP = "cn=code"
Const DESIGN_GROUP = "cn=design"
Const EXEC_GROUP = "cn=exec"
Const LEADS_GROUP = "cn=leads"
Const MANAGEMENT_GROUP = "cn=management"
Const PRODUCTION_GROUP = "cn=production"
Const RENDERS_GROUP = "cn=renders"
Const VFX_GROUP = "cn=vfx"




'
' Constants for Emailing Errors
'

Const MAIL_SERVER = "mailserver.domain.com"
Const TO_ADDRESS = "ben.xxxx@domain.com"




'
' Subroutines
'

Sub MapDrive(strDrive, strShare)
     If objFileSystem.DriveExists(strDrive) Then
          strErrorMessage = strErrorMessage & "Failed to Map " & strDrive &_
               " to " & strShare & ": Drive Exists" & VbCrLf
          Exit Sub
     End If

     On Error Resume Next
     Err.Clear
     wshNetwork.MapNetworkDrive strDrive, strShare
     If Err.Number <> 0 Then
          strErrorMessage = strErrorMessage & "Failed to Map " & strDrive &_
               " to " & strShare & ": " & Err.Description & VbCrLf
      
     End If
     On Error Goto 0
End Sub



Sub SendMail(strTo, strBody)
     Dim objMail

     Set objMail = CreateObject("CDO.Message")

     objMail.Subject = "Logon Script Errors, " + objUser.Get("displayName")
     objMail.From = "LogonScriptErrors@domain.com"
     objMail.To = strTo
     objMail.TextBody = strBody

     objMail.Configuration.Fields.Item _
          ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
     objMail.Configuration.Fields.Item _
          ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
          = MAIL_SERVER
     objMail.Configuration.Fields.Item _
          ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
          = 25
     objMail.Configuration.Fields.Update

     objMail.Send
     Set objMail = Nothing
End Sub




'
'Main Code
'

Dim wshNetwork, wshShell
Dim objFileSystem, objADsysInfo, objUser
Dim strGroups, strErrorMessage

strErrorMessage = ""

Set wshNetwork = CreateObject("WScript.Network")
Set wshShell = CreateObject("WScript.Shell")
Set objFileSystem = CreateObject("Scripting.FileSystemObject")




'
'Drive Instructions
'


' Drive Mappings for everyone

     MapDrive "B:", "\\fileserver\folder"
     MapDrive "S:", "\\fileserver\folder"
     MapDrive "T:", "\\DC\folder"
     MapDrive "U:", "\\DC\folder"
     MapDrive "V:", "\\DC\folder"
     MapDrive "X:", "\\fileserver\folder"
     MapDrive "y:", "\\fileserver\folder"

     
' Get the Group Membership and store it in strGroups

Set ADSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(join(objUser.GetEx("MemberOf")))

' Group Based Drive Mappings

If InStr(strGroups, ANIMATION_GROUP) Then
     MapDrive "w:", "\\fileserver\folder"
     MapDrive "M:", "\\fileserver\folder"
End If


If InStr(strGroups, AUDIO_GROUP) Then
     MapDrive "w:", "\\fileserver\folder"
End If


If InStr(strGroups, ART_GROUP) Then
     MapDrive "R:", "\\fileserver\folder"
End If


If InStr(strGroups, DESIGN_GROUP) Then
     MapDrive "Z:", "\\fileserver\folder"
     MapDrive "w:", "\\fileserver\folder"
End If


IF InStr(strGroups, EXEC_GROUP) Then
     MapDrive "O:", "\\fileserver\folder"
     MapDrive "Q:", "\\fileserver\folder"
End If


IF InStr(strGroups, LEADS_GROUP) Then
     MapDrive "L:", "\\fileserver\folder"
End If


IF InStr(strGroups, PRODUCTION_GROUP) Then
     MapDrive "K:", "\\fileserver\folder"
     MapDrive "L:", "\\fileserver\folder"
End If





'
' Display the Errors if there are any
'

If strErrorMessage <> "" Then
     strErrorMessage = "Errors encountered in the Login Script:" & vbCrLf & _
         Replace(strErrorMessage, " Failed", vbCrLf & "Failed")
          
     On Error Resume Next
     strUserName = "" : strUserName = objUser.Get("displayName")
     strComputerName = wshNetwork.ComputerName
     On Error Goto 0

     strErrorMessage = "User Name: " & strUserName & VbCrLf &_
          "Computer Name: " & strComputerName & VbCrLf & VbCrLf &_
          strErrorMessage & VbCrLf

     SendMail TO_ADDRESS, strErrorMessage
End If
Start Free Trial
[+][-]09.04.2007 at 12:16PM PDT, ID: 19827631

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.05.2007 at 03:12AM PDT, ID: 19830993

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.05.2007 at 03:38AM PDT, ID: 19831082

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.06.2007 at 02:48AM PDT, ID: 19838710

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.06.2007 at 03:51AM PDT, ID: 19838951

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2007 at 08:45AM PDT, ID: 19877338

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.05.2007 at 06:21AM PDT, ID: 20021588

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]10.05.2007 at 11:40AM PDT, ID: 20024453

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.09.2007 at 07:00AM PDT, ID: 20040998

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.13.2007 at 04:33PM PDT, ID: 20072313

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Windows Vista, Windows XP Operating System, VB Script
Tags: vista, script, vbs, running
Sign Up Now!
Solution Provided By: Computer101
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628