[dba-Tech] Windows Update

Jim Lawrence accessd at shaw.ca
Sat Oct 18 14:34:52 CDT 2014


HI Gustav:

Thanks for the scripts. 

It looks pretty straightforward but I would guess an installation of VS express would be required? Would there be a powertools equivalent for a new POS system install?  This code appears to assume that all particulars are in place...can it assign/setup the appropriate credentials to new unconfigured station being added to existing or new network or is that too complex of a task?

Jim   

----- Original Message -----
From: "Gustav Brock" <gustav at cactus.dk>
To: "Discussion of Hardware and Software issues" <dba-tech at databaseadvisors.com>
Sent: Saturday, October 18, 2014 1:34:18 AM
Subject: Re: [dba-Tech] Windows Update

Hi Jim

Sure. Nothing fancy:

<vbscript>
Option Explicit

' Main script

  Dim strNetBIOSDomain
  Dim strNTName
  Dim strNTPath
  Dim strNTProvider
  Dim varNull
  Dim IsMemberOfCactusData
  Dim IsMemberOfTeamCactus

  Dim objShell
  Dim objNetwork
  Dim objGroupNames

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

  strNetBIOSDomain = EnvString("userdomain")
  strNTName = EnvString("username")
  strNTPath = strNetBIOSDomain & "/" & strNTName
  strNTProvider = "WinNT://" & strNTPath

  IsMemberOfCactusData = IsMemberOfGroup("CactusData")
  IsMemberOfTeamCactus = IsMemberOfGroup("TeamCactus")

  If IsMemberOfTeamCactus Then
    Call MapDrive("i", "\\cactus.dom\cactus data\inst")
    Call MapDrive("s", "\\cactus.dom\cactus data\data\database")
    Call MapDrive("t", "\\cactus.dom\cactus data\data\document")
    Call MapDrive("u", "\\cactus.dom\cactus data\data\internal\privat")
  ElseIf IsMemberOfCactusData Then
    Call MapDrive("i", "\\cactus.dom\cactus data\inst")
    'Call MapDrive("n", "\\cactus.dom\cactus data\data")
    Call MapDrive("p", "\\cactus.dom\cactus data\data\internal")
    Call MapDrive("r", "\\cactus.dom\cactus data\data\codebase")
    Call MapDrive("s", "\\cactus.dom\cactus data\data\database")
    Call MapDrive("t", "\\cactus.dom\cactus data\data\document")
    Call MapDrive("u", "\\cactus.dom\cactus data\data\internal\privat")
  ElseIf LCase(strNTName) = "skan" Then
    Call MapDrive("i", "\\cactus.dom\cactus data\inst")
    Call MapDrive("t", "\\cactus.dom\cactus data\data\document")
  ElseIf LCase(strNTName) = "backuser" Then
    Call MapDrive("i", "\\sanzibar\inst")
    Call MapDrive("m", "\\sanzibar\data")
  Else
    Call MapDrive("i", "\\cactus.dom\cactus data\inst")
    Call MapDrive("s", "\\cactus.dom\cactus data\data\database")
    Call MapDrive("t", "\\cactus.dom\cactus data\data\document")
    Call MapDrive("u", "\\cactus.dom\cactus data\data\internal\privat")
  End If
  If LCase(strNTName) = "gustav" Or LCase(strNTName) = "cactus" Then
    Call MapDrive("q", "\\cactus.dom\cactus data\data\external")
  End If

  varNull = objGroupNames.RemoveAll()
  Set objGroupNames = Nothing
  Set objNetwork = Nothing
  Set objShell = Nothing

' End script
' -----------------------------------------------------

Private Sub MapDrive(strDriveLetter, strUNC)
' Map a drive to strUNC.
'''    On Error Resume Next
    strDriveLetter = Chr(Asc(strDriveLetter)) & ":"
    objNetwork.MapNetworkDrive strDriveLetter, strUNC
    If (Err.Number <> 0) Then
        On Error GoTo 0
        objNetwork.RemoveNetworkDrive strDriveLetter, True, True
        objNetwork.MapNetworkDrive strDriveLetter, strUNC
    End If
    On Error GoTo 0

End Sub
 

Private Function IsMemberOfGroup(strGroupName)
' Checks if the current user is a group member of groupName.

    Dim objUser
    Dim objGroup

    If IsEmpty(objGroupNames) Then
        Set objGroupNames = CreateObject("Scripting.Dictionary")
        objGroupNames.CompareMode = vbTextCompare
        Set objUser = GetObject(strNTProvider & ",user")
        For Each objGroup in objUser.Groups
            objGroupNames.Add objGroup.Name, True
        Next
        Set objGroup = Nothing
        Set objUser = Nothing
    End if

    IsMemberOfGroup = CBool(objGroupNames.Exists(strGroupName))

End Function


Private Function EnvString(strEnvironmentVariable)
' Returns the value from Environment of the environment variable strEnvironmentVariable.

    strEnvironmentVariable = "%" & strEnvironmentVariable & "%"
    EnvString = objShell.ExpandEnvironmentStrings(strEnvironmentVariable)

End Function
</vbscript>

/gustav
________________________________________
Fra: dba-tech-bounces at databaseadvisors.com <dba-tech-bounces at databaseadvisors.com> på vegne af Jim Lawrence <accessd at shaw.ca>
Sendt: 18. oktober 2014 04:21
Til: Discussion of Hardware and Software issues
Emne: Re: [dba-Tech] Windows Update

Hi Gustav:

Would you have a script that I could take a look at? If you don't think that is a good idea, fine but if its OK, sent it either online or offline. :-)

Jim

----- Original Message -----
From: "Gustav Brock" <gustav at cactus.dk>
To: "Discussion of Hardware and Software issues" <dba-tech at databaseadvisors.com>
Sent: Friday, October 17, 2014 3:01:02 PM
Subject: Re: [dba-Tech] Windows Update

Hi Jim

I've never heard of such issues. On the other hand, I do all testing connecting to our AD; then DNS etc. are assigned by the login script, so it always works. I never touch the hostfile.

/gustav
_______________________________________________
dba-Tech mailing list
dba-Tech at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-tech
Website: http://www.databaseadvisors.com



More information about the dba-Tech mailing list