'========================================================================== ' ' VBScript Source File -- Created With SAPIEN Technologies PrimalScript 3.1 ' ' NAME: DHLongonie2.vbs ' DATE : 11/22/2004 ' ' COMMENT: Please make sure to check with other LAN members before making changes to this script ' '========================================================================== Dim oTheEnd ' important that this Is dimmed as a global variable!!! On Error Resume Next '***************************************************************************** 'Determine User and Computer name Set objADsystemInfo= CreateObject("ADSystemInfo") strUserDN = objADSystemInfo.Username Set objNetwork = CreateObject("WScript.network") strComputer = objNetwork.ComputerName Set oIE = CreateObject("InternetExplorer.Application") '******************************************************************************** ' Sync time with SMS server ' SetTime() '******************************************************************************** ' get Ipaddress strhost = "." Set objWMIService = GetObject("winmgmts:\\" & strHost & "\root\cimv2") Set IPConfigSet = objWMIService.ExecQuery _ ("Select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) arrIp = split(IPConfig.IPAddress(i), ".") arrsub= (arrIp(0) & "." & arrIp(1) & "." & arrIp(2) & "."& arrIp(3)) strsubnet= arrsub Next End If Next '********************************************************************************* 'Create log files Const ForReading = 1, ForWriting = 2, ForAppending = 8 Set StdOut= WScript.StdOut Set StdIn= WScript.StdIn set oWshShell= WScript.CreateObject("wscript.shell") Set oFSO= CreateObject("Scripting.FileSystemObject") Set oLog = CreateObject("Scripting.FileSystemObject") sDate = Date Set fLog = oLog.OpenTextFile("\\dhhbgdohshare\dohshare\survey.txt", ForAppending, True) Set flog2 = oLog.OpenTextFile("c:\logonsurvey.txt", ForAppending, True) fLog2.WriteLine "" fLog2.WriteLine "new Logon........................................................" fLog2.WriteLine "" fLog2.WriteLine "Users Groups....................................................." '******************************************************************************** ' Start IE window SetupMSIE MsgMSIE "" & sTitle & "" MsgMSIE "Processing Logon Script..." MsgMSIE "

" '******************************************************************************** '******************************************************************************** ' Put the message you want the users to read at the begining of the logon script in StrMessage1 strMessage1 = "This Is the Network Health Check Script." MsgMSIE ""& strMessage1 & "" MsgMSIE "


" '******************************************************************************** ' Give users 3 seconds to read message WScript.Sleep 3000 '***************************************************************** ' Determine Domain Set objSysInfo = CreateObject("ADSystemInfo") 'Change Domain controller To your gif location MsgMSIE "" MsgMSIE "
Domain name: " & objSysInfo.DomainShortName & "" MsgMSIE "
Your PC name is: " & strComputer & "" '******************************************************************************* ' Determine Computer Role Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") Set colComputers = objWMIService.ExecQuery ("Select DomainRole from Win32_ComputerSystem") For Each objComputer In colComputers Select Case objComputer.DomainRole Case 0 strComputerRole = "Standalone Workstation" Case 1 strComputerRole = "Member Workstation" Case 2 strComputerRole = "Standalone Server" Case 3 strComputerRole = "Member Server" Case 4 strComputerRole = "Backup Domain Controller" Case 5 strComputerRole = "Primary Domain Contoller" End Select Next '***************************************************************************** 'If server exit script If strComputerRole = "Member Server" Or strComputerRole = "Standalone Server" Or strComputerRole = "Backup Domain Controller" Or strComputerRole = "Primary Domain Contoller" Then MsgMSIE "
This Is a Server" MsgMSIE "
Create T drive share....." 'change to Server mapped drive objNetwork.MapNetworkDrive "T:", "\\{Servername}\tools" MsgMSIE "
No Scripting will run" oIE.Quit WScript.quit End If MsgMSIE "
" & "This Is a Workstation" MsgMSIE "
Your IP address is: " & strsubnet & "" '**************************************************************************** 'display cheezy greeting To the user Set objWSHShell = CreateObject("WScript.Shell") MyUserName = objWSHShell. ExpandEnvironmentStrings("%username%") strusername = MyUserName MyDC = objWSHShell. ExpandEnvironmentStrings("%Logonserver%") strDC = MYDC Set oShell = CreateObject("Wscript.Shell") Set oNet = CreateObject("Wscript.Network") set oFSO = CreateObject("Scripting.FileSystemObject") Dim sTime, sDate, sMessage, sAdsPath, GreetingTime, oUser sTime = Hour(Now) sDate = Now If sTime <= 11 Then GreetingTime = "morning" ElseIf sTime <= 18 Then GreetingTime = "afternoon" Else GreetingTime = "evening" End If sMessage = "
" & sDate & VbCrLf & VbCrLf sMessage = sMessage & "

" & "Good " & GreetingTime & " " & strusername & " welcome To the Department Of Health Domain," sMessage = sMessage & "
" MsgMSIE "
" & (sMessage) MsgMSIE "


" WScript.Sleep 4000 '******************************************************************************* '******************************************************************************* 'Map Drives Based On group MemeberShip For Burea Shares 'use this to tell yours what group they are In MsgMSIE "
You are a member of the following groups:" & "
" ' Use this if you are hiding groups ' MsgMSIE "
Proccessing:" & "" 'Set objUser = GetObject("LDAP://" & strUserDN) 'For Each strGroup In objUser.memberOf ' Set objGroup = GetObject("LDAP://" & strGroup) Set objUser = GetObject("LDAP://" & strUserDN) For Each objGroup In objUser.groups 'WScript.Echo objGroup.Name fLog2.WriteLine objGroup.name ' uses this if you want to see groups MsgMSIE "
" & objGroup.name ' Uses this to hide groups ' MsgMSIE "." '******************************************************************************* '**************************************************************************** ' Network Team Script ' Need to figure this part out If LCase(objGroup.name) = "cn=XXXX" Then WSH.echo "You entered: ", join(PasswordBox("Please enter your UserID for DOHNETSRVR1", "Testing123"), ", ") End If '*************************************************************************** Next '*************************************************************************** ' Add legal Notice to registry Set WSHShell = WScript.CreateObject("WScript.Shell") WSHShell.RegWrite "HKLM\software\microsoft\windows nt\currentversion\winlogon\logonprompt", "The system is to be used only by authorized users. By continuing to use the system, the user represents that he/she is an authorized user. The user agrees to being monitored by the Commonwealth." '*************************************************************************** ' Write to survey.xxx strtime= Time fLog.WriteLine "Logged On To network On "& sDate & ", " & strtime & ", " & strusername & ", " & strComputer & ", " & strsubnet & ", " & strdc & "." fLog2.WriteLine "" fLog2.WriteLine "Logged On To network On " & strusername &", " & sDate & ", " & strtime & ", , " & strComputer & ", " & strsubnet & ", " & strdc & "." '**************************************************************************** 'little display to show the user what is mapped Dim DriveCollection, PrinterCollection, MsgString, i Set DriveCollection = oNet.EnumNetworkDrives Set PrinterCollection = oNet.EnumPrinterConnections MsgString = "
" & "The following network shared drives are connected:" & "
" fLog2.WriteLine "The following network shared drives are connected:" For i = 0 To DriveCollection.Count - 1 Step 2 MsgString = MsgString & "
" & DriveCollection(i) & " " & DriveCollection(i + 1) fLog2.WriteLine DriveCollection(i) & " " & DriveCollection(i + 1) Next MsgMSIE "


" MsgMSIE "

" &(MsgString) MsgMSIE "

" &"" MsgString = "
" & "The following printers are connected to your machine:"& "
" fLog2.WriteLine "The following printers are connected to your machine:" For i = 1 To PrinterCollection.Count - 1 Step 2 MsgString = MsgString & "
" & PrinterCollection(i) fLog2.WriteLine PrinterCollection(i) Next MsgMSIE "

" MsgMSIE "
" & (MsgString & "

") MsgMSIE "

" WScript.Sleep 3000 '****************************************************************** ' Execute additional apps 'Change {Servername} and execution to what you want MsgMSIE "Executing ESS_ICON.exe ..........." Run "\\{Servername}\NETLOGON\apps\ess_icon.exe" '***************************************************************** ' Closing statment MsgMSIE "
" & "Logon Script Complete." MsgMSIE "
Closing in 3 seconds..." MsgMSIE "" WScript.Sleep 3000 oIE.Quit '***************************************************************** 'End Script WScript.Quit '**************************************************************** ' This sub sets up Internet explorer Sub SetupMSIE Dim sTitle, SWidth,SHeight, SWidthW, SHeightW sTitle = "AD Logon" With oIE .AddressBar = False .ToolBar = False .StatusBar = False .Resizable = False .Navigate("about:blank") Do Until .readyState = 4: WScript.sleep 100: Loop With .document With .ParentWindow SWidth = .Screen.AvailWidth SHeight = .Screen.AvailHeight SWidthW = .Screen.AvailWidth / 2 SHeightW = .Screen.AvailHeight / 1.1 .resizeto SWidthW, SHeightW .moveto (SWidth - SWidthW)/2, (SHeight - SHeightW)/2 End With .Open .Write "" .Close Set oTheEnd = .all.theEnd .Title = sTitle With .ParentWindow.document.body .style.backgroundcolor = "LightBlue" .style.Font = "10pt 'Arial'" '.style.borderStyle = "outset" '.style.borderWidth = "4px" ' .scroll="no" End With oIE.Visible = True End With ' document End With ' oIE End Sub Sub MsgMSIE(sMsg) On Error Resume Next oTheEnd.insertAdjacentHtml "beforeBegin", sMsg & "
" oTheEnd.scrollIntoView End Sub '*************************************************************** ' Sub To Execute Any app ' Put this line were you want it ' Example ' Run "C:\Program Files\MyFile.exe" Sub Run(ByVal sFile) Dim shell Set shell = CreateObject("WScript.Shell") shell.Run Chr(34) & sFile & Chr(34), 1, False Set shell = Nothing End Sub ' ***************************************************************** ' Time Sub ' Probably Not needed anymore Sub SetTime() Const ForReading = 1, ForWriting = 2 Set WSHShell = WScript.CreateObject("WScript.Shell") Set WshProcessEnvironment = WshShell.Environment("Process") '* Sets the system time To SMS Server Time */ WshShell.Run("net Time \\{SMSServer} /Set /y") End Sub '****************************************************************** ' Function to create Network team share Function PasswordBox(sPrompt, sDefault) Set oSH = CreateObject("WScript.Shell") set oIE2 = CreateObject("InternetExplorer.Application") With oIE2 .RegisterAsDropTarget = False .Resizable = False : .FullScreen = True .width = 400 : .height = 200 .Navigate "about:blank" Do Until .ReadyState = 4 : WScript.Sleep 100 : Loop .document.open .document.write _ "<" & "script>bboxwait=true;Password _"_ & "
" _ & " " & sPrompt & " 

" _ & "
User:" _ & "" _ & "
Password:" _ & "

" _ & "" _ & "

" .document.close Do Until .ReadyState = 4 : WScript.Sleep 100 : Loop With .document oIE2.left = .parentWindow.screen.width \ 2 - 200 oIE2.top = .parentWindow.screen.height\ 2 - 100 .all.user.focus .all.user.Select ' Optional On Error Resume Next Do While .parentWindow.bBoxWait oSH.Appactivate "Password _" oIE2.Visible = True if Err Then Exit Function WScript.Sleep 100 Loop oIE2.Visible = False StrUser= .all.user.value StrPassword= .all.pass.value '********************************************************************** 'Connect to network share ' For testing Set objNetwork = CreateObject("WScript.network") objNetwork.MapNetworkDrive "n:", "\\Servername\netcntr" , , strUser , strPassword End With ' document End With ' IE End Function '***********************************************************************************