Announcement

Collapse
No announcement yet.

Tools & Scripts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tools & Scripts

    I've been using Hyena for about 1 1/2 years. I, and my co-workers, use it religiously, to the point it's our primary tools for Network Administration.

    In my endeavor to make my job (and the ones around me) easier, Hyena tools is the way to go. Automate everything, I say.

    So, here goes. I'm going to post a tool and it's corresponding script (and instructions for installation, if need be) to this forum, because I think the Hyena users would get the most out of these. Some of these (you might think) are crap. Maybe so, but they work!

    I encourage all who read this to do the same, and post your tools/scripts. I bet it won't take long for this topic to grow with useful stuff!!

    I will ask this:

    If you have a script that does basically the same thing, just suggest the changes, don't repost the whole thing with your "adjustments" (unless, of course, you see a major flaw in the script).

    Actually, I'll start this out with configuration:

    Most of you know you should have a repository for your tools/scripts/support files when dealing with Hyena tools.

    I also have a batch file that installs the support files and registry entries:

    "Install Custom Hyena Tool.bat"
    ---------------------
    @echo off
    echo.
    echo Registering the form OCX...
    copy "\\server\Hyena\wshLWF\wshLWForm.ocx" %systemroot%\System32
    regsvr32 /s %systemroot%\System32\wshLWForm.ocx
    echo.
    echo Registering the Remote Registry control
    copy "\\server\Hyena\RegObji\REGOBJ.DLL" %systemroot%\System32
    regsvr32 /s %systemroot%\System32\REGOBJ.DLL
    echo.
    echo Adding Registy keys...
    echo You may receive a message if unsuccessful.
    echo.
    regedit.exe /s "\\server\Hyena\Custom Tools.reg
    --------------------------

    This installs the OCX required for some of my scripts, registers the remote registry object (now made a bit redundant thanks to Hyena 5) and installs a reg file created from this link:
    http://www.systemtools.com/toolboard...hared-settings

    The OCX comes from the kick-butt liteweight form module created by Mr. Warrington. Download the package from here:
    http://home.att.net/~wshvbs/wshLtWtFormPage.htm

    As for the RegObj.DLL ? Direct from Mothership Microsoft:
    http://download.microsoft.com/downlo...US/RegObji.exe

    Tomorrow is Valentine's Day (and my 10 year anniversary!!!), and Monday's President's Day. So hopefully I'll post my first tool on Tuesday.

    Until then!!

    Joel

    P.S. Since I forgot, I better say it up here and later in this topic:

    Some other tools that I use come from SysInternals (http://www.sysinternals.com) and their AWESOME package of PSTools. If you don't know what they are, hit their site and readup!

    Place the PSTools in an accessible directory (with appropriate NTFS permissions, of course, since these tools can be dangerous in the wrong/corrupt hands), and ensure you change the script/tool to match.

    [This message has been edited by The Supply Guy (edited 04-01-2003).]

  • #2
    Re: Tools & Scripts

    Well, the anniversary went well, then I show back up to work and all HELL breaks loose.

    I apologize for the delay (yeah, like you were "waiting in suspense" the entire time!).

    Here's my first script. Hope someone finds it useful. This one completely removes MSN Messenger from XP boxes, and keeps them from running it, even if it's installed again.

    xxxxxxxxxxxxxxxx Begin Script Here xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx

    '================================================= =========================
    '
    ' VBScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
    '
    ' NAME: Remove MSN Messenger.vbs
    '
    ' AUTHOR: Joel Thoreson
    ' DATE : 10/8/2002
    '
    ' COMMENT: Completely and utterly takes care of MSN Messenger on a
    ' Windows XP workstation
    '================================================= =========================
    Option Explicit
    Dim WshShell, fso, sResult, Process
    Set WshShell = WScript.CreateObject("WScript.Shell")
    ' Create FileSystemObject object to access file system.
    Set fso = WScript.CreateObject("Scripting.FileSystemObject")


    'tell the user where and who can use this script, and give them an early exit
    sResult = MsgBox ("This script is to be ran ONLY on Windows XP systems! Running this script " & _
    "on any other operating system may cause unexpected results." & vbCrLf & vbCrLf & _
    "Administrative rights are also required to run this script. If you do not have admin rights, please click ""Cancel""", _
    vbExclamation + vbOkCancel, "Warning!!")

    If sResult = vbCancel Then WScript.Quit

    'lay down the rules for running this script
    WshShell.Popup "Before running this script, the following MUST be adhered to:" & vbCrLf & vbCrLf & _
    "1. Close all active programs!!" & vbCrLf & _
    vbTab & "(be sure to close ANY programs running on the taskbar, except the icons)" & vbCrLf & vbCrLf & _
    "2. Be aware that this script may take up to 3 minutes (or more) to complete," & vbCrLf & _
    "and may appear not to be running at all." & vbCrLf & _
    vbTab & "(Be patient, and DO ** NOT ** use your mouse or keyboard unless told to do so," & vbCrLf & _
    vbTab & " and only when/where you are told)" & vbCrLf & vbCrLf & _
    "3. Be sure to read and follow each and every dialog box CAREFULLY before clicking ""OK""." & vbCrLf & _
    vbTab & "(inadvertant clicking without reading may cause this script to not function correctly)" & vbCrLf & vbCrLf & _
    "4. If you receive an error about unregistering and OCX file, it is to be expected." & vbCrLf & _
    vbTab & "(simply click ""OK"" to the error box)" & vbCrLf & vbCrLf & _
    "Allow the script to run it's course and guide you when it needs assistance.",,"Please read before you proceed...", _
    vbInformation + vbOkOnly

    '=======================================
    ' Thanks to Doug Knox (www.dougknox.com)
    ' for the reg keys/settings
    '=======================================

    On Error Resume Next

    'kill the MSN Messenger process, if it's running
    for each Process in GetObject("WinMgmts:{impersonationLevel=impersonat e}").ExecQuery ("select * from Win32_Process where name = 'msmsgs.exe'")
    sResult = Process.terminate
    If sResult <> 0 Then
    WshShell.Popup "The MSN Messenger service could not be terminated, possibly due to insufficient rights." & vbCrLf & vbCrLf & _
    "Ensure you have Admin rights when running this script." & vbCrLf & vbCrLf & _
    "The script will attempt to continue, but errors may pop up." & vbCrLf & vbCrLf & _
    "Error code returned is: " & sResult,5,"Uninstall Error", vbOkOnly + vbCritical
    Else
    WshShell.Popup "MSN Messenger terminated",3, "MSN Messenger Terminated", vbOkOnly + vbInformation
    End If
    Next
    WScript.Sleep(5000)

    'Put in the registry settings, in case MSN Messenger is ever re-installed
    WshShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Me ssenger\Client\PreventRun",1,"REG_DWORD"
    WshShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Me ssenger\Client\PreventAutoRun",1,"REG_DWORD"
    WshShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Outlook Express\Hide Messenger",2,"REG_DWORD"

    'uninstall MSN Messenger
    WshShell.Run "rundll32 advpack.dll,LaunchINFSection %systemRoot%\INF\msmsgs.inf,BLC.Remove"
    WScript.Sleep(5000)
    WshShell.SendKeys ("%{y}")
    WScript.Sleep(10000) 'pause to allow the uninstall to happen, a little long, to allow user to click on possible dialog boxes

    'tell the user what to do, if the uninstall asks questions
    sResult = InputBox ("Answer ""Yes"" to confirm the uninstall of MSN Messenger, if prompted." & vbCrLf & _
    "Click ""OK"", to complete the uninstall." & vbCrLf & _
    "If you have not been prompted for anything yet, click ""OK"" to this box NOW." & vbCrLf & _
    "After you received confirmation and clicked ""OK"" of the uninstall, click ""OK"" to this box to continue", _
    "Please read and wait...", "Do Not Change anything here. Wait, please...", 400, 400)

    WshShell.Run "rundll32 setupapi,InstallHinfSection BLC.Remove 128 %systemRoot%\INF\msmsgs.inf"
    WScript.Sleep(5000) 'pause to allow the uninstall to happen

    'open the sysoc.inf file
    WshShell.Run "%SystemRoot%\notepad.exe %systemRoot%\INF\sysoc.inf"
    WScript.Sleep(500) 'pause to ensure Notepad keeps the focus

    'replace the text in the sysoc.inf file, and save it
    WshShell.SendKeys ("^{h}")
    WshShell.SendKeys ("msmsgs=msgrocm.dll,OcEntry,msmsgs.inf,hide,7" )
    WshShell.SendKeys ("{tab}")
    WshShell.SendKeys ("msmsgs=msgrocm.dll,OcEntry,msmsgs.inf,,7")
    WshShell.SendKeys ("{tab}")
    WshShell.SendKeys ("{tab}")
    WshShell.SendKeys ("{tab}")
    WshShell.SendKeys ("{tab}")
    WshShell.SendKeys ("{enter}")
    WshShell.SendKeys ("{tab}")
    WshShell.SendKeys ("{enter}")
    WshShell.SendKeys ("%{f}")
    WshShell.SendKeys ("{x}")
    WshShell.SendKeys ("%{y}")
    WScript.Sleep(2000) 'pause so the system can save the sysoc.inf

    'launch the Windows Components list
    WshShell.Run "Control.exe APPWIZ.CPL,,2"
    WScript.Sleep(15000) 'pause script to allow sufficient time to display Windows Component list

    'tell the user to wait, and only continue when the Windows Component dialog list is displayed
    sResult = InputBox ("Please wait until the ""Windows Component"" dialog list is displayed before clicking ""OK"" on this dialog box. " _
    & vbCrLf & vbCrLf & "Use the taskbar (if need be) to switch back to this dialog box if it loses the focus.", _
    "Please read and wait...", "Do Not Change anything here. Wait, please...", 400, 400)

    'help the user by unchecking the first boxes
    WshShell.SendKeys ("{W}")
    WshShell.SendKeys ("{i}")
    WshShell.SendKeys ("{n}")
    WshShell.SendKeys ("{d}")
    WshShell.SendKeys ("{o}")
    WshShell.SendKeys ("{w}")
    WshShell.SendKeys ("{s}")
    WshShell.SendKeys ("{ }")
    WshShell.SendKeys ("{ }")
    WshShell.SendKeys ("{M}")
    WshShell.SendKeys ("{e}")
    WshShell.SendKeys ("{s}")
    WshShell.SendKeys ("{s}")
    WScript.Sleep(3000)
    WshShell.SendKeys ("{ }") 'uncheck the box
    WScript.Sleep(5000)

    WshShell.Popup "The ""Windows Components"" dialog list should now be displayed, with the ""Windows Messenger"" unchecked." & vbCrLf & vbCrLf & _
    "It is possible now (or more likely) that 2 ""Windows Messenger"" lines are displayed. One may be unchecked," & vbCrLf & _
    "and the other checked. Please uncheck BOTH ""Windows Messenger"" boxes, then click ""Next""" & vbCrLf & vbCrLf & _
    "After you click ""Next"" on the ""Windows Components"" dialog list, click ""OK"" to this dialog box",, _
    "Please read before you proceed...", _
    vbInformation + vbOkOnly

    WScript.Sleep(15000) 'pause script until uninstall is (hopefully) complete

    'delete the Messenger folder
    fso.DeleteFolder "%ProgramFiles%\Messenger",True

    WshShell.Popup "Windows (MSN) Messenger has been completely uninstalled, and/or will no longer run." & _
    "Click the ""Finish"" button to complete the XP Setup, and close the ""Add/Remove Programs box." ,5,_
    "Done",vbOkOnly
    WScript.Quit
    xxxxxxxxxxxxxxx End Script xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    This script must be run locally. I'm sure there are other ways for this to be tweaked, especially in an AD environment (I'm not quite that lucky...or am I?).

    I'll put up more as soon as I can!

    Joel

    [This message has been edited by The Supply Guy (edited 03-05-2003).]

    Comment


    • #3
      Re: Tools & Scripts

      Joel,

      I must admit I'm a bit of a complete idiot when it comes to script programming and using them within Hyena. I did successfully follow you firt message and downloaded the necessary files and created the batch file to install them. Now what do I do with your script and how do I make it available within Hyena? Do I save it as a .vbs file? what is the command line I enter to use it? Sorry to sound so stupid, but I hope to pick up some of this as time goes on.

      Regards

      Comment


      • #4
        Re: Tools & Scripts

        In between the "Begin Script" and "End Script", save the text to a vbs file. Save it to a place accessible by all who may need it.

        Then create a tool in Hyena. Most tools (for vbs files) will use the following syntax:

        cscript.exe "\\server\share\Hyena\Complete Scripts\RemoveMSNMsgr.vbs" //I //NoLogo %E%

        See: http://www.windows2000faq.com/Articl...rticleID=15226
        for a breakdown of the switches.

        You could use either cscript.exe or wscript.exe, depending on the output you want to see.

        And as for you sounding stupid...puuuhhhlease.

        What your asking is not ignorance, only part of the learning curve. And I hope I've helped.

        Joel

        Comment


        • #5
          Re: Tools & Scripts

          On to my next script/tool. There have been plenty of tools posted, most of them extremely useful, and some just damn-near REQUIRED.

          Such as:

          cmd /x /c ping.exe -a %E% & pause

          To see if a machine is even online. Because, c'mon, let's face it. Hyena, even the Windows Network itself doesn't know if something's still online until you hit with a request. And that tool is the one for job.

          Now, when it comes to administration of an entire network, usually, you're not alone. Others require the same tools you need/use, and although Hyena has the beauty of Shared Settings folder and other shared user settings, sometimes this isn't functional. Sometimes the tools need to be installed on each machine. This script will make it easy.

          This script, when run on a machine containing an installation of Hyena, will extract the registry keys to Hyena's tools, and create a registry file for other to double-click on and install those tools.

          Actually, if you look at my batch file from the first post, you'll see the last line installs the "Custom Tools.reg" file.

          WARNING: This script will extract all tools from the machine on which it's ran, and create (ergo, delete any old file) a new REG file of the same name.

          So my advice is this: Whoever is the "Script Guy/Gal" who will be the "creator" of most tools, that individual alone should have access to run this script!! You've been WARNED!!

          xxxxxxxxxxxxxxxx Begin Script Here xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx

          '================================================= =========================
          '
          ' VBScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
          '
          ' NAME: Export Hyena Tools.vbs
          '
          ' AUTHOR: Joel Thoreson
          ' DATE : 11/8/2002
          '
          ' COMMENT: Used to export the custom Hyena tools that have been created
          ' on Mr. Thoreson's machine.
          ' NOTES: Try to run this without any open windows. I've put pauses
          ' in here to try to ensure it stays focused on Notepad,
          ' but sometimes, well, it's finicky when using SendKeys
          ' I chose this method over using RegObj and reading each key
          ' due to the fact that certain programs (in this case, Hyena)
          ' store their tools
          '
          '================================================= =========================
          Option Explicit

          Const ForWriting = 2 ' write access
          Dim arrFileLines()
          Dim strComputer, fso, strFilePath, strTempFilePath, strKeyPath
          Dim objFile, strTextToFind, txtStreamOut, i

          Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")

          strComputer = "."

          ' Create FileSystemObject object to access file system.
          Set fso = WScript.CreateObject("Scripting.FileSystemObject")

          ' Check whether the file exists
          strFilePath = "\\server\share\Hyena\Custom Tools.reg"
          strTempFilePath = strFilePath & ".txt"

          If (Not fso.FileExists(strFilePath)) Then ' File doesn't exist so create it
          fso.CreateTextFile(strFilePath)
          Else ' if it does, delete the old, create a new
          fso.DeleteFile(strFilePath)
          fso.CreateTextFile(strFilePath)
          End If

          ' set the registry key we wish to export
          strKeyPath = "HKEY_CURRENT_USER\Software\Adkins Resource\Hyena\Customize"

          ' use RegEdit to export the key to the temp file
          WshShell.Run "Regedit /E """ & strTempFilePath & """ """ & strKeyPath & ""

          ' pause to ensure the export is done
          WScript.Sleep(2000)

          ' use notepad to save the file in ANSI format
          ' this must be done so the fso can read it correctly
          ' (default format of regedit export is UNICODE)
          WshShell.Run "%SystemRoot%\notepad.exe " & strTempFilePath
          WScript.Sleep(1000) 'pause to ensure Notepad keeps the focus

          WshShell.SendKeys ("%{f}") ' Alt+F
          WshShell.SendKeys ("{a}")
          WshShell.SendKeys ("{tab}")
          WshShell.SendKeys ("{tab}")
          WshShell.SendKeys ("{tab}")
          WshShell.SendKeys ("{tab}")
          WshShell.SendKeys ("{a}")
          WshShell.SendKeys ("{enter}")
          WshShell.SendKeys ("%{y}") ' Alt+Y
          WScript.Sleep(2000) 'pause so the system can save the file
          WshShell.SendKeys ("%{F4}") ' Alt+F4 - to close Notepad

          i = 0 ' set the counter
          Set objFile = fso.OpenTextFile(strTempFilePath) ' open the temp file
          Do Until objFile.AtEndOfStream
          Redim Preserve arrFileLines(i)
          arrFileLines(i) = objFile.ReadLine ' read the temp file, line by line
          i = i + 1
          Loop

          objFile.Close ' close the temp file
          fso.DeleteFile(strTempFilePath) ' delete the temp file

          ' Output the registry file.
          ' in this usage, we filter because we're only looking for certain keys
          Set txtStreamOut = fso.OpenTextFile(strFilePath, ForWriting, True) ' Open output
          txtStreamOut.WriteLine("Windows Registry Editor Version 5.00") ' could be changed to REGEDIT4
          txtStreamOut.WriteLine 'blank line
          txtStreamOut.WriteLine("[" & strKeyPath & "]") ' the registy key name

          strTextToFind = """IDM_TOOL" ' looking for ("IDM_TOOL)

          i = 0
          For i = Lbound(arrFileLines) to UBound(arrFileLines) Step 1 ' get the limits of the array
          If Left(arrFileLines(i),9) = strTextToFind Then ' filter it
          txtStreamOut.WriteLine(arrFileLines(i)) ' write it
          End If
          Next

          WScript.Quit ' properly quit
          xxxxxxxxxxxxxxx End Script xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


          Hope this helps someone! Next time, I'll get into tools that actually help... ;-p

          Joel

          Comment


          • #6
            Re: Tools & Scripts

            Ok, Im waiting for more tools. I was able to get the export and importing of the custom tools working. Very nice. I gave my self two ping commands. One without the pause. Keep them coming.

            Comment


            • #7
              Re: Tools & Scripts

              You're right. Sorry, but that's what happens when the in-laws visit from a different country...priorities change...hardwood floors get laid in your house...your garage gets a makeover... :-)

              ANYWAY...

              Since I forgot, I better say it up here and earlier in this topic:

              Some other tools that I use come from SysInternals (http://www.sysinternals.com) and their AWESOME package of PSTools. If you don't know what they are, hit their site and readup!

              Place the PSTools in an accessible directory (with appropriate NTFS permissions, of course, since these tools can be dangerous in the wrong/corrupt hands), and ensure you change the script/tool to match.

              Now about those "useful" tools I was talking about...

              When I run my script above, to genereate my REG file, here's what I get:

              "IDM_TOOL1"="- Updates"
              "IDM_TOOLCMD1"="wscript.exe \\\\server\\folder\\NTand2~1\\Hyena\\Comple~1\\Rem oteExec.vbs //I //NoLogo %E%"
              "IDM_TOOL2"="Get IP (from WINS)"
              "IDM_TOOLCMD2"="cmd /c cls & for /f "tokens=3" %V in ('ping -n 1 %E% ^| find "Pinging"') do @echo Workstation: %E% IP Address: %V & pause "
              "IDM_TOOL3"="IPConfig on Remote Machine"
              "IDM_TOOLCMD3"="cmd /c cls & \\\\server\\folder\\NTand2~1\\Hyena\\PsTools\\psex ec \\\\%E% ipconfig /all & pause"
              "IDM_TOOL4"="Launch NetSupport"
              "IDM_TOOLCMD4"="C:\\Progra~1\\NetSup~1\\PCICTLUI.E XE /N"%P1:Enter the config file to use. Standard, Special%" /F /C">%E%" /VW /E"
              "IDM_TOOL5"="NAV/SSC Server Info && Update"
              "IDM_TOOLCMD5"="wscript.exe \\\\server\\folder\\NTand2~1\\Hyena\\Comple~1\\SSC GRC.vbs //I //NoLogo %E%"
              "IDM_TOOL6"="NBTSTAT"
              "IDM_TOOLCMD6"="cmd /x /c nbtstat.exe -a %E% & pause"
              "IDM_TOOL7"="Ping"
              "IDM_TOOLCMD7"="cmd /x /c ping.exe -a %E% & pause"
              "IDM_TOOL8"="Process Killer"
              "IDM_TOOLCMD8"="cmd /c cls & \\\\server\\folder\\NTand2~1\\Hyena\\PsTools\\pski ll.exe \\\\%S% %C2% & pause"
              "IDM_TOOL9"="Remote Command Prompt"
              "IDM_TOOLCMD9"="cmd /c cls & \\\\server\\folder\\NTand2~1\\Hyena\\PsTools\\psex ec \\\\%E% cmd & pause"
              "IDM_TOOL10"="Remote Regedit"
              "IDM_TOOLCMD10"="wscript.exe "\\\\server\\folder\\NT and 2K-XP Pro Tools, Upgrades & Patches\\Hyena\\Complete Scripts\\Launch Remote Regedt32.vbs" %E%"
              "IDM_TOOL11"="Restore Admin Shares"
              "IDM_TOOLCMD11"="wscript.exe \\\\server\\folder\\NTand2~1\\Hyena\\Comple~1\\Res etAdminShares.vbs //I //NoLogo %E%"
              "IDM_TOOL12"="Scan Domain for Specific HotFix"
              "IDM_TOOLCMD12"="wscript.exe "\\\\server\\folder\\Nt and 2K-XP Pro Tools, Upgrades & Patches\\Hyena\\Complete Scripts\\Scan Domain for Specific HotFix.vbs" //I //NoLogo %E%"
              "IDM_TOOL13"="Scan Machine for HotFixes"
              "IDM_TOOLCMD13"="wscript.exe "\\\\server\\folder\\Nt and 2K-XP Pro Tools, Upgrades & Patches\\Hyena\\Complete Scripts\\Scan Machine for HotFixes.vbs" //I //NoLogo %E%"
              "IDM_TOOL14"="Service Doesn't Exist on Domain"
              "IDM_TOOLCMD14"="cscript.exe "\\\\server\\folder\\NT and 2K-XP Pro Tools, Upgrades & Patches\\Hyena\\Complete Scripts\\SvcNoExist.vbs" //I //NoLogo %E%"
              "IDM_TOOL15"="Services Check"
              "IDM_TOOLCMD15"="wscript.exe "\\\\server\\folder\\NT and 2K-XP Pro Tools, Upgrades & Patches\\Hyena\\Complete Scripts\\Services Check.vbs" //I //NoLogo %E%"
              "IDM_TOOL16"="Symantec Ghost Client Uninstall"
              "IDM_TOOLCMD16"="cmd /c cls & \\\\server\\folder\\NTand2~1\\Hyena\\PsTools\\psex ec \\\\%E% c:\\progra~1\\symantec\\ghost\\ngctw32.exe -uninstall & pause"
              "IDM_TOOL17"="Terminal Service / Remote Desktop"
              "IDM_TOOLCMD17"="MSTSC.EXE /v:%E% /w:1024 /h:768"
              "IDM_TOOL18"="Windows Update Registy Additions"
              "IDM_TOOLCMD18"="wscript.exe \\\\server\\folder\\NTand2~1\\Hyena\\Comple~1\\Win dowsUpdateRegAdd.vbs //I //NoLogo %E%"
              "IDM_TOOL19"="DoD Banner Registy Entries"
              "IDM_TOOLCMD19"="wscript.exe \\\\server\\folder\\NTand2~1\\Hyena\\Comple~1\\DOD Dis~1.vbs //I //NoLogo %E%"
              "IDM_TOOL20"="Enum"
              "IDM_TOOLCMD20"="cmd /c cls & \\\\server\\folder\\ntand2~1\\hyena\\pstools\\enum .exe -UMSPGL %E% & pause"
              "IDM_TOOL21"="Test - MBSA"
              "IDM_TOOLCMD21"=""C:\\Program Files\\Microsoft Baseline Security Analyzer\\mbsacli.exe""
              "IDM_TOOL22"="Test - Remote Assistance"
              "IDM_TOOLCMD22"=""c:\\Program Files\\Internet Explorer\\iexplore.exe" hcp://CN=Microsoft%20Corporation,L=Redmond,S=Washington, C=US/Remote%20Assistance/Escalation/unsolicited/unsolicitedrcui.htm"
              "IDM_TOOL23"="Test - Reset Page File Size"
              "IDM_TOOLCMD23"="wscript.exe \\\\server\\folder\\NTand2~1\\Hyena\\Comple~1\\Res etPageFileSize.vbs //I //NoLogo %E%"
              "IDM_TOOL24"="Test - Remote Registry Search"
              "IDM_TOOLCMD24"="cscript.exe \\\\server\\folder\\NTand2~1\\Hyena\\Comple~1\\Sea rchRemReg.vbs //I //NoLogo %E%"

              Now, some of these are simple enough, and some are already posted in this forum (thanks to the guys and gals who first posted them).

              I'll start by going down the list (skipping the obvious...because, c'mon, if you've read this much, you should know what you're doing):

              1-Updates
              (A big script that presents the user with a list of updates to be remotely applied to a computer. I'll get to this one later...)
              2-Get IP (from WINS)
              (never mind...removed...not needed with Hyena's Network tab)
              3-IPConfig on Remote Machine
              (Uses PSEXEC to run IPCONFIG on the remote machine. Not really needed anymore, but I keep it, just in case)
              4-Launch NetSupport
              (Old tool to launch NetSupport and prompt for Configuration name. Not really needed since STRCM does it all for us now)

              *** I'm sensing a "not needed" pattern ***
              *** hmmmm.......................... ***

              5-Norton AV/Symantec Service Center Info and Update
              (updates the remote system with a grc.dat file from a selected server, then stops and restarts the remote service)
              6-NBTSTAT
              (Again, not needed, but nice to have around for non-domain systems)
              7-Ping
              (ol' faithful...to make sure a machine is online before locking up Hyena for 60 seconds attempting to access a resource that doesn't exist...whoops, did I say that out loud...)
              8-Process Killer
              (uses PSKILL to kill a process on a remote system. Great for unlocking someone's system...usually...realistically, it's fun to kill someone's Internet Explorer while they're surfing the wrong sites at lunch)
              9-Remote Command Prompt
              (uses psexec to do...just that)
              10-Remote Regedit
              (you see, here I go and create a script that makes the appropriate registry entries in the local computer, lauches RegEdt32.exe and connects to the remote system, showing you the HKLM and HKCU hives, then when it closes, it resets the local registry...and the Hyena implements remote registy in 5.0....cheese -n- crackers...)
              11-Restore Admin Shares
              (When a machine loses the C$, ADMIN$ shares, run this)
              12-Scan Domain for Specific HotFix
              (does just that, searching for a Q article)
              13-Scan Machine for HotFixes
              (take a wild guess what this script does)
              14-Service Doesn't Exist on Domain
              (got a process/service that's SUPPOSED to be running on ALL systems, like Norton AV? Then run this script and you'll see who ISN'T running it)
              15-Services Check
              (in our environment, Win32Time, Security Policy (IPSEC), and other services are NOT to be running, and other services (like NAV) are to be running, and set properly (to automatically start or be disabled). This sets those services correctly)
              16-Symantec Ghost Client Uninstall
              (remotely does...hmmm...)
              17-Terminal Service / Remote Desktop
              (easy one, and not really needed since STRCM.)
              18-Windows Update Registy Additions
              (this one adds the appropriate registry entries to a remote system that forces it to use a localize Windows SUS server [for approved critical updates])
              19-DoD Banner Registy Entries
              (this script adds the registry entries to a remote machine to ensure it's compliance with DoD Information policy...modify as needed)
              20-Enum
              (just runs ENUM on a remote system)
              21, 22, 23, 24 are test scripts and functions for now. 24 works, but it needs to be fine tuned before public release.

              I'll post #5 here in a few hours.

              Thanks!

              Joel

              Comment


              • #8
                Re: Tools & Scripts

                Well, here we go!

                This script updates a remote machine's NAV/SAV to be managed by a select list of servers.

                You MUST have these tools installed and registered:
                (...but if you've read this far, you've already done that, right??)

                RegObj.DLL
                wshLWForm.ocx

                Here you go!

                'SCRIPT BEGINS HERE
                '================================================= =========================
                '
                ' VBScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
                '
                ' NAME: SSCGRC.vbs
                '
                ' AUTHOR: Joel Thoreson
                ' DATE : 10/16/2002
                '
                ' COMMENT: Updates a remote machine's Symantec System Center (Norton AV)
                ' server information with a list of known servers
                '
                ' TO DO: have the script automatically install/register the form's OCX file
                ' and the RegObj.dll
                ' have the script automatically install WMI and/or ADSI (if possible)
                ' CLEAN UP (CHECK) THE VARIABLES, THERE ARE PROBABLY EXTRAS THAT
                ' NEED TO BE REMOVED (to save memory)
                '================================================= =========================

                Option Explicit

                ' instantiate ActX components here...
                ' (note: using "call instantiate" to provide better info in case obj is missing)
                Dim oLWF : Call Instantiate (oLWF, "wshLWForm.ucLWF", "oLWF_")

                ' --- declare the variables used -----------------
                Dim WshShell, WshNetwork, fso, objLocator, objSvc, strQuery
                Dim oForm, sClickEvent, btnID, sUserComputer ' as String
                Dim strCurrentSvr, sPropMsgcbo ' as String
                Dim objArgs, strTargetComp 'as String
                Dim OS_Set, strSystemSet, strOSVN
                Dim objRegistry, objRemoteRegistry

                ' --- constant declarations ----------------------
                Const sUserClick = "BtnClick"
                Const sUserClose = "UserClose"
                Const crDkGray = &H808080
                ' --- end of declarations and constants ----------


                ' --- Set the environment ------------------------
                Set WshShell = WScript.CreateObject("WScript.Shell")
                Set WshNetwork = WScript.CreateObject("WScript.Network")
                Set fso = CreateObject("Scripting.FileSystemObject")

                ' --- collect the argument sent ------------------
                Set objArgs = WScript.Arguments ' create object with collection
                If objArgs.Count >= 1 Then
                strTargetComp = objArgs(0) 'assign the passed computer name to a variable
                Else 'quit the script, no variable given, or too many variables passed
                WScript.Echo("Could not determine the target computer's name, or too many arguments passed to the script.")
                strTargetComp = InputBox ("Enter the computer name for the system you wish to connect to." & vbCrLf & vbCrLf & "Click ""Cancel"" to close.", "Need a name of a computer...")
                If strTargetComp = "" Then WScript.Quit
                End If

                ' --- Set the remote registry object -------------
                On Error Resume Next
                Set objRegistry = CreateObject("RegObj.Registry")
                If Err.Number <> 0 Then ' a little error check
                WshShell.Popup "You most likely have not installed the proper tools on this workstation to run this utility. " & vbCrLf & vbCrLf & _
                "An attempt will now be made to install the proper tools to utilize this script." & vbCrLf & vbCrLf & _
                "The file: """"Install Required Custom Files.bat"""" batch file will now run.", 10, "Error - RegObj not installed"
                WshShell.Run """\\server\folder\NT and 2K-XP Pro Tools, Upgrades & Patches\Hyena\Install Required Custom Files.bat""",0,True
                WshShell.Popup "Please run this script again to ensure the tools installed properly. You must have" & _
                " administrative rights to install these tools, and to effectively run this script.", 10, "Tool installation complete"
                WScript.Quit
                End If
                On Error GoTo 0

                'if we made it this far, set the actual remote registry object
                Set objRemoteRegistry = objRegistry.RemoteRegistry(strTargetComp)

                ' --- Get Machine Info ---------------------------
                GetMachineInfo

                ' --- Get the currently installed server ---------
                GetServerName

                ' --- Show "LaunchBrowser" Demo Form -------------
                Call Create_LaunchUpdateForm

                ' --- show the form (Modally) --------------------
                oLWF.ShowForm

                ' no more readprop, so use oForm go read the user input...
                Set oForm = oLWF.frmDialog

                ' upon returning, check up on how the user closed the form...
                If sClickEvent <> "" Then
                Select Case btnID ' check btnClick
                Case "Update Server Info" ' user clicked the Launch Update button
                sPropMsgcbo = oForm.cboBox(1).Text 'get the contents of the combo box
                ' delete "LaunchBrowser" form, we only allow one form at a time, and it frees up some memory.
                oLWF.DeleteForm
                ' execute the selections, using the text from the form's combo box, the target computer's name
                ' and the Machine Info collected, in order to copy the GRC.DAT file to the proper directory.
                Call UpdateServer
                Case Else ' if the user clicked anything else, quit the script
                WScript.Quit
                End Select
                End If

                ' Stop and restart the "Norton AntiVirus Server" service
                Call SvcStopStart

                WshShell.Popup "You will receive a prompt in about 10 seconds after closing this dailog box, showing the the name of the managing server for " & strTargetComp & ". " & _
                "If this does not match the server information you entered, or if the script ends with an error, run this script again to confirm your " & _
                "requested change took affect.", 15, "Almost complete...PLEASE READ!"
                WScript.Sleep(5000)

                ' --- Get the currently installed server ---------
                ' - which is hopefully updated now ---------------
                Set strCurrentSvr = Nothing 'reset the variable
                Call GetServerName 're-read the server info

                WshShell.Popup strTargetComp & " is now reporting to be managed by " & strCurrentSvr & ". If this is incorrect, please run this script " & _
                "again in about 1 minute, to ensure the service has had time to implement the requested change.", 7, _
                strTargetComp & " managed by " & strCurrentSvr


                ' --- finished -----------------------------------

                ' just in case an IPC session was established, disconnect it

                WshShell.Run "net use \" & strTargetComp & "\IPC$ /delete", False

                Set oLWF = Nothing ' proper object etiquette...
                WScript.Quit ' end of script


                ' ================================================
                ' === SUBROUTINES FOLLOW =========================
                ' ================================================

                '================================================= =================================================
                ' --- VBScript using WMI to gather OS information and system role
                ' --- thanks for Cornell University for providing the basics on this
                '================================================= =================================================
                Function GetMachineInfo

                'Local variables
                Dim os_version, os_svcpk
                Dim strSystem
                Dim system_role, system_roletmp, strMessage

                On Error Resume Next ' so we can catch the errors and "do the right thing"

                ' - here we attempt to connect using straight up WMI connection (with existing username/pw)
                Set OS_Set = GetObject("winmgmts:{impersonationLevel=impersonat e}//" & strTargetComp).InstancesOf ("Win32_OperatingSystem")

                'MsgBox Err.Number & vbCrLf & Err.Description ' for testing/debugging

                ' - if there's an error, we catch the ADSI/WMI error (usually on NT & 9x machines), then...
                If Err.Number = 429 Then
                strMessage = "ADSI 5.2 **AND** WMI must be installed on local workstation to be able to update this machine." & vbCrLf & VbCrLf & _
                "These updates can be found at:" & vbCrLf & VbCrLf & _
                "\\server\folder\NT and 2K-XP Pro Tools, Upgrades & Patches\Patches, Upgrades and Updates from Microsoft" & vbCrLf & VbCrLf & _
                "'Windows Management Instrumentation (WMI) CORE 1.5 (Windows NT 4.0).EXE'" & vbCrLf & _
                "'Microsoft Active Directory Services Interfaces 2.5 for Intel X86 - Windows NT.exe'" & vbCrLf & VbCrLf & _
                "Failure to install the required software will result in this message every time you run this utility."
                WshShell.Popup strMessage,0,UCASE(strTargetComp) & " must be updated",vbCritical
                'maybe put something in here to install the updates automatically, or launch a web page where the user can install them
                GetServerName
                Select Case Err.Number
                Case -2147024891
                WshShell.Popup "Could not read registry entry:" & vbCrLf & _
                strFullKeyPath & vbCrLf & _
                vbCrLf & _
                "Error Code: " & Err.Number & vbCrLf & _
                "Error Description: You must have administrative rights on the target machine to run this script. Registry " & _
                "connections are not permitted by non-admins.", 5, "Admin Rights Required", vbExclamation + vbOkOnly
                Case Else
                WshShell.Popup "Could not read registry entry:" & vbCrLf & _
                strFullKeyPath & vbCrLf & _
                vbCrLf & _
                "Error Code: " & Err.Number & vbCrLf & _
                "Error Description: " & Err.Description, 3, "Error", vbExclamation + vbOkOnly
                End Select

                WshShell.Popup strTargetComp & " is managed by " & strCurrentSvr, 10, "NAV/SSC Managing Server"

                WScript.Quit
                ' - ...we catch the "Access Denied" or "Permission Denied", if it comes up. We then attempt to use WBEM to connect
                Elseif Err.Number = -2147217405 Or Err.Number = 70 Then
                Err.Clear
                On Error GoTo 0 'reset the error trap
                Call AttemptwbemConnect
                Else ' if there weren't any errors, we establish another connection to set the strSystemSet
                Set strSystemSet = GetObject("winmgmts:{impersonationLevel=impersonat e}//" & strTargetComp).InstancesOf ("Win32_ComputerSystem")
                End If

                On Error GoTo 0 'reset the error trap, just in case it wasn't reset before

                For each strSystem in OS_Set
                os_version = strSystem.Version
                os_svcpk = strSystem.CSDVersion
                'Get the proper name for the version
                ' and set the system_role variable for 9x Workstations so that
                ' it can be utilized a little farther down to skip a step
                If os_version = "4.00.950" and os_svcpk = "" then
                'Windows 95 Retail, OEM
                strOSVN = "95"
                system_role = "Windows 9x Workstation"
                ElseIf os_version = "4.00.950" and os_svcpk = "A" then
                'Windows 95 Retail SP1
                strOSVN = "95"
                system_role = "Windows 9x Workstation"
                ElseIf os_version = "4.00.1111" then
                'Windows 95 OEM Release 2 (95B)
                strOSVN = "95"
                system_role = "Windows 9x Workstation"
                ElseIf os_version = "4.00.1212" then
                'Windows 95 OEM Relase 2.1 (95B)
                strOSVN = "95"
                system_role = "Windows 9x Workstation"
                ElseIf os_version = "4.00.1215" then
                'Windows 95 OEM Relase 2.1 (95C)
                strOSVN = "95"
                system_role = "Windows 9x Workstation"
                ElseIf os_version = "4.10.1998" then
                'Windows 98 Retail, OEM
                strOSVN = "98"
                system_role = "Windows 9x Workstation"
                ElseIf os_version = "4.10.2222" then
                'Windows 98 Second Edition
                strOSVN = "98SE"
                system_role = "Windows 9x Workstation"
                ElseIf os_version = "4.90.3000" then
                'Windows Millenium Edition (ME)
                strOSVN = "ME"
                system_role = "Windows 9x Workstation"
                ElseIf os_version = "4.0.1381" then
                'Windows NT 4.0
                strOSVN = "NT"
                ElseIf os_version = "5.0.2195" then
                'Windows 2000 Professional
                strOSVN = "2K"
                ElseIf os_version = "5.1.2600" then
                'Windows XP Professional
                strOSVN = "XP"
                End If
                Next

                For each strSystem in strSystemSet
                ' If system_role <> "Windows 9x Workstation" then 'set the system role and update the strOSVN variable
                If strOSVN = "NT" OR strOSVN = "2K" OR strOSVN = "XP" then 'update the strOSVN variable for NT Type machines
                system_roletmp = strSystem.DomainRole 'apparently Win2K, XP specific
                Select Case system_roletmp
                Case 0
                'Standalone Workstation
                strOSVN = strOSVN & "_WS"
                Case 1
                'Member Workstation
                strOSVN = strOSVN & "_WS"
                Case Else ' it's either a Standalone or Member Server, or a Domain Controller
                WshShell.Popup "This script is not meant to run on Servers in a Symantec System Center " & _
                "controlled environment. This script will now exit.", 5, "Machine is a server...exiting script!"
                WScript.Quit
                End Select
                End If
                Next
                'MsgBox "Machine info: " & strOSVN
                End Function
                '================================================= =================================================


                '================================================= =================================================
                ' - Use WBEM to connect to the computer, asking the user for alternate credentials
                '================================================= =================================================
                Sub AttemptwbemConnect
                Dim strNameSpace : strNameSpace="root\cimv2"
                Dim strTitle : strTitle = "User Credentials for <" & UCASE(strTargetComp) & "> insufficient"
                Dim strUser, strPassword
                Dim sInstructions ' as String

                sInstructions = "The credentials under which this script has been launched apparently are insufficient " & _
                "to connect to <" & UCASE(strTargetComp) & ">. Please enter a username and password that have " & _
                "Administrative credentials on <" & UCASE(strTargetComp) & ">."

                With oLWF ' save some typing...
                ' create the FORM...
                ' for CreateForm, syntax is (Horz Location, Vert Location, Horz Size, Vert Size)
                .CreateForm 50, 50, 350, 220, strTitle

                .frmDialog.Icon = oLWF.frmDialog.NullIco.Picture ' reset titlebar icon

                ' create the CONTROLS to go on form
                ' for Add(Control), syntax is (Horz Location on Form, Vert Location on Form, Horz Size, Vert Size)
                .frmDialog.vbLine 20, 75, 300, 0, crDkGray 'dark grey accent line

                .AddLabel 20, 10, 300, 60, sInstructions
                .AddLabel 40, 93, 50, 25, "Username"
                .AddLabel 40, 118, 50, 25, "Password"
                .AddTxtBox 120, 90, 145, 20, WshNetwork.UserDomain & "" & WshNetwork.UserName
                .AddTxtBox 120, 115, 145, 20, ""
                .AddCmdBtn 50, 150, 110, 25, "OK"
                .AddCmdBtn 190, 150, 100, 25, "Cancel"
                End With ' oLWF

                ' use oForm
                Set oForm = oLWF.frmDialog

                ' set the second field as a password
                oForm.txtBox(2).PasswordChar = "*"

                ' --- show the form (Modally) --------------------
                oLWF.ShowForm


                ' upon returning, check up on how the user closed the form...
                If sClickEvent <> "" Then
                Select Case btnID ' check btnClick
                Case "OK" ' user clicked the Launch Update button
                strUser = oForm.TxtBox(1).Text 'get the username
                strPassword = oForm.TxtBox(2).Text ' get the password
                ' delete "LaunchBrowser" form, we only allow one form
                ' at a time, and it frees up some memory.
                oLWF.DeleteForm
                Case Else ' if the user clicked anything else, quit the script
                WScript.Quit
                End Select
                End If

                On Error Resume Next

                Set objLocator = CreateObject("WbemScripting.SWbemLocator")
                Set objSvc = objLocator.ConnectServer(strTargetComp,strNamespac e,strUser,strPassword)
                If err.number<>0 Then
                WshShell.Popup "There was an error connecting to " & UCASE(strTargetComp) & VBCRLF & _
                "Make sure you specified the correct credentials and/or a valid server name." & VBCRLF & _
                "Error #" & err.number & " - " & err.description, 10, strTitle, vbOkOnly + vbCritical
                wscript.quit
                End If

                Err.Clear

                On Error GoTo 0

                objSvc.Security_.ImpersonationLevel=3

                ' - Set OS information queries -------------------
                strQuery="Select * from Win32_OperatingSystem"

                Set OS_Set=objSvc.ExecQuery(strQuery,,0)

                If err.number<>0 Then
                WshShell.Popup "There was an error executing the query on " & UCASE(strTargetComp) & _
                VBCRLF & "Error #" & err.Number and " - " & err.description, 10, strTitle, vbOkOnly + vbCritical
                WScript.quit
                End If

                Err.Clear

                strQuery="Select * from Win32_ComputerSystem"

                Set strSystemSet=objSvc.ExecQuery(strQuery,,0)

                If err.number<>0 Then
                WshShell.Popup "There was an error executing the query on " & UCASE(strTargetComp) & _
                VBCRLF & "Error #" & err.Number and " - " & err.description, 10, strTitle, vbOkOnly + vbCritical
                WScript.quit
                End If

                ' If WBEM is required to connect to the machine to get the machine info, Then
                ' RegObj won't be able to function unless an authenticated IPC session is established

                WshShell.Run "net use \" & strTargetComp & "\IPC$ /USER:" & strUser & " " & strPassword, True

                End Sub
                '================================================= =================================================


                '================================================= =================================================
                ' --- Create the form, populate it with the options
                '================================================= =================================================
                Sub Create_LaunchUpdateForm()
                Dim sInstructions, sInstructions1, sInstructions2, sCboBoxItems ' as String

                ' initialize cboBox items (comma delimited)...
                ' list your servers here, seperated by commas
                sCboBoxItems = "Select from the list,server1,server2,server3,server4"

                ' check to see if the target system is even being managed
                If strCurrentSvr = "" Then
                sInstructions = UCASE(strTargetComp) & " is apparently not being managed."
                Else
                sInstructions = UCASE(strTargetComp) & " is currently managed by: " & UCASE(strCurrentSvr)
                End If

                sInstructions1 = "In order to update " & UCASE(strTargetComp) & " with a " & _
                "new/different server of your choice, " & _
                "select the server name from the following " & _
                "drop-down list." & vbCrLf & vbCrLf & _
                "(Click """"Cancel"""" if you're just checking the current info)"

                'On Error Resume Next 'In case we fail to create object then display our custom error

                sInstructions2 = "In order to allow this action to execute remotely, " & _
                "you must have administrative credentials on the remote system. " & vbCrLf & vbCrLf &_
                "Please ensure that the username under which you launched this process " & _
                "has administrative rights on the remote system."

                With oLWF ' save some typing...
                ' create the FORM...
                ' for CreateForm, syntax is (Horz Location, Vert Location, Horz Size, Vert Size)
                .CreateForm 50, 50, 350, 320, " SSC Parent Server information for " & UCASE(strTargetComp)

                .frmDialog.Icon = oLWF.frmDialog.NullIco.Picture ' reset titlebar icon

                .frmDialog.vbLine 20, 40, 300, 0, crDkGray 'dark grey accent line

                ' create the CONTROLS to go on form
                ' for Add(Control), syntax is (Horz Location on Form, Vert Location on Form, Horz Size, Vert Size)
                .AddLabel 20, 20, 300, 20, sInstructions
                .AddLabel 20, 45, 300, 40, sInstructions1
                .AddCboBox 20, 95, 200, 30, sCboBoxItems
                .AddLabel 20, 140, 275, 130, sInstructions2
                .AddCmdBtn 50, 240, 110, 25, "Update Server Info"
                .AddCmdBtn 190, 240, 100, 25, "Cancel"
                End With ' oLWF
                ' use oForm
                Set oForm = oLWF.frmDialog

                ' use the form object to adjust label font...
                With oForm.Label(1)
                .Font.Name = "Arial" : .Font.Size = 8.5 : .Font.Italic = False : .Font.Bold = True : .ForeColor = vbBlue
                End With

                ' set the font of the drop down box
                With oForm.CboBox(1).Font
                .Name = "Tahoma" : .Size = 10
                End With

                End Sub
                '================================================= =================================================


                '================================================= =================================================
                ' --- Update the target system with the GRC.DAT file from the selected server
                '================================================= =================================================
                Function UpdateServer

                Select Case strOSVN
                ' Haven't figured out what to do with these just yet...but hold on to them.
                ' Case "95"
                ' Dim oGRCFile
                ' 'set the filename
                ' If fso.FileExists(sGRCFile) Then
                ' Set oGRCFile = fso.GetFile (sGRCFile)
                ' oGRCFile.Copy("\" & objTargetComp & "\C$\Program Files\NavNT")
                ' End If
                ' Set oGRCFile = Nothing
                ' 'C:\Program Files\Norton AntiVirus
                ' Case "98"
                ' 'C:\Program Files\Norton AntiVirus
                ' Case "98SE"
                ' 'C:\Program Files\Norton AntiVirus
                ' Case "ME"
                ' 'C:\Program Files\Norton AntiVirus
                Case "NT_WS"
                If KeyExists("\HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\N orton AntiVirus NT\Install\7.50") = True Then
                CopyGRCFile("\C$\WINNT\Profiles\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5")
                Else
                'version 7.0 or earlier
                CopyGRCFile("\C$\Program Files\NavNT")
                End If
                Case "2K_WS"
                If KeyExists("\HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\N orton AntiVirus NT\Install\7.50") = True Then
                If (fso.FolderExists("\" & strTargetComp & "\C$\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5")) Then
                CopyGRCFile("\C$\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5")
                Else ' OS has been upgraded from an earlier version
                CopyGRCFile("\C$\WINNT\Profiles\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5")
                End If
                Else
                'version 7.0 or earlier
                CopyGRCFile("\C$\Program Files\NavNT")
                End If
                Case "XP_WS"
                'set the filename (no registry check, because NAV 7.0 and earlier won't install on XP)
                If (fso.FolderExists("\" & strTargetComp & "\C$\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5")) Then
                CopyGRCFile("\C$\Documents and Settings\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5")
                Else' OS has been upgraded from an earlier version
                CopyGRCFile("\C$\WINNT\Profiles\All Users\Application Data\Symantec\Norton AntiVirus Corporate Edition\7.5")
                End If
                End Select

                End Function
                '================================================= =================================================


                '================================================= =================================================
                ' - Sub to copy the GRC.DAT file to the remote system
                '================================================= =================================================
                Sub CopyGRCFile(GRCPath)
                Dim sGRCFile, oGRCFile

                sGRCFile = "\" & sPropMsgcbo & "\VPHOME\GRC.DAT"

                If fso.FileExists(sGRCFile) Then
                Set oGRCFile = fso.GetFile (sGRCFile)
                On Error Resume Next
                WshNetwork.MapNetworkDrive "X:", "\" & strTargetComp & GRCPath
                If Err.Number <> 0 Then
                WshShell.Popup "There was an error mapping a drive to the remote system. The most likely " & _
                "cause of this error is that the Administrative shares on the machine (i.e.: " & _
                "C$, Admin$) have been altered. Check the remote system to ensure the Admin " & _
                "shares are available." & vbCrLf & vbCrLf & _
                "If they are not, run the ""Restore Admin Shares"" tool.", 0, "Check the Administrative Shares", vbOkOnly + vbCritical
                WScript.Quit
                End If
                oGRCFile.Copy "x:", True 'Overwrite if it exists
                WshNetwork.RemoveNetworkDrive("X:")
                Else
                WshShell.Popup "There was an problem verifying the existance of the GRC.DAT file." & vbCrLf & vbCrLf & _
                "Filename: " & UCASE(sGRCFile) & vbCrLf & vbCrLf & _
                "Please check your network connections, or rights to the parent server.", 0, "Error getting GRC.DAT file", vbOkOnly + vbCritical
                wscript.quit
                End If
                Set oGRCFile = Nothing

                End Sub
                '================================================= =================================================


                '================================================= =================================================
                ' - Check to see if a registry key exists --------
                '================================================= =================================================
                Function KeyExists(key)
                Dim strRegKey

                'On Error Resume Next
                Set strRegKey = objRemoteRegistry.RegKeyFromString(key)
                If strRegKey = "" Then
                KeyExists = False
                Else
                KeyExists = True
                End If
                'On Error GoTo 0

                End Function
                '================================================= =================================================


                '================================================= =================================================
                ' - Service Stop/Start ---------------------------
                '================================================= =================================================
                Function SvcStopStart
                Dim objTargetCompSvc, strService

                strService = "Norton AntiVirus Server"
                Set objTargetCompSvc = GetObject("WinNT://" & strTargetComp & "/" & strService & ",service")

                'if the service startup isn't set to "Automatic", set it that way
                If objTargetCompSvc.StartType <> 2 Then
                objTargetCompSvc.StartType = 2
                objTargetCompSvc.SetInfo
                End If

                'if status is "Paused", make it "Continue"
                If objTargetCompSvc.Status = 7 Then 'check to see if it's "Paused", because it requires special handling
                objTargetCompSvc.Continue
                End If

                objTargetCompSvc.Stop

                On Error Resume Next 'for some reason, error code "-2147023835" can get generated, so just continue

                While objTargetCompSvc.Status <> 1 'loop in case the status in not "Stopped"
                WScript.Sleep(1000)
                'WshShell.Popup "#1: " & objTargetCompSvc.Status & vbCrLf & Err.Number,5 'for testing/debugging
                Wend

                objTargetCompSvc.Start
                WScript.Sleep(5000) 'allow a little time for the service to start
                'WshShell.Popup "#2: " & objTargetCompSvc.Status & vbCrLf & Err.Number,5 'for testing/debugging

                On Error GoTo 0 'reset

                End Function
                '================================================= =================================================


                '================================================= =================================================
                ' --- Get the currently installed server ---------
                '================================================= =================================================
                Function GetServerName

                Dim strRegSvrKey

                WshShell.Run "net use \" & strTargetComp & "\IPC$", True

                On Error Resume Next
                Set strRegSvrKey = objRemoteRegistry.RegKeyFromString("\HKEY_LOCAL_MA CHINE\Software\Intel\LANDesk\VirusProtect6\Current Version")
                strCurrentSvr = strRegSvrKey.Values("Parent").Value
                If Err.Number <> 0 Then
                ' maybe do a service check on the machine to see if it's even installed.
                MsgBox "Most likely, this machine, " & strTargetComp & ", does not have NAV/SAV installed." & vbCrLf & _
                "It's also possible that you have to make an IPC connection to this box first to read the registry. Please investigate." & _
                vbcrlf & vbcrlf & _
                Err.Number & vbcrlf & Err.Description
                WScript.Quit
                End If
                'MsgBox "connected. machine info found. Remote Registy connected. Servername found"

                End Function
                '================================================= =================================================


                '================================================= =================================================
                ' --- Event Handlers -----------------------------
                '================================================= =================================================
                Sub oLWF_UserClick(index, sTag)
                'MsgBox (" .. User Click Event Detected") & vbCrLf & sUserClick ' for debugging
                sClickEvent = sUserClick
                ' set btn ID return parameter...
                btnID = sTag
                End Sub

                Sub oLWF_UserClose()
                'MsgBox (" .. User Click Event Detected") & vbCrLf & sUserClose ' for debugging
                sClickEvent = sUserClose
                End Sub
                '================================================= =================================================


                '================================================= =================================================
                ' --- INSTANTIATE ACTX OBJ and BUGASSERT ---------
                '================================================= =================================================

                ' --- INSTANTIATE ACTX OBJECT (or class) AND CHECK ----
                ' (using a sub to get this ugly instantiation code out of main line code)...
                Sub Instantiate (oObject, sProgramID, sEventPrefix)
                Const sME = "[sub Instantiate], "

                ' check variant sub-type parameters...
                BugAssert (VarType(sProgramID) = vbString), sME & "sProgramID must be a STRING!"
                BugAssert (VarType(sEventPrefix) = vbString), sME & "sEventPrefix must be a STRING!"
                On Error Resume Next ' turn on error checking
                Set oObject = WScript.CreateObject(sProgramID, sEventPrefix)
                BugAssert (err.number = 0), sME & "This script requires: " & sProgramID & vbCrlf _
                & " kindly INSTALL and REGISTER this ActiveX component... " & vbCrlf & vbCrlf _
                & " It can be installed by running 'Install Required Custom Files.bat'" & vbCrlf _
                & " located in \\server\folder\NT and 2K-XP Pro Tools, Upgrades & Patches\Hyena"
                On Error goto 0 ' turn off error checking...
                End Sub
                '================================================= =================================================


                '================================================= =================================================
                ' --- BUGASSERT (yes, it's for debugging) --------
                '================================================= =================================================

                Sub BugAssert (bTest, sErrMsg)
                Dim sDblSpace : sDblSpace = vbCrLf & vbCrLf

                ' BugAssert is a Bruce McKinney creation.
                ' It is used to test for intermediate results...

                If bTest Then Exit Sub ' normally (hopefully) test returns true...

                MsgBox "Error Message reported by BugAssert: " & sDblSpace _
                & sErrMsg & sDblSpace & " this script will terminate NOW. ", _
                vbCritical, " << BugAssert FAILED in Script: " & Wscript.ScriptName & " >> "
                WScript.Quit

                End Sub
                '================================================= =================================================
                'SCRIPT ENDS HERE

                That's it...

                I'm sure I should explain a little about how this works....nnnnaaaaaaaaaaaaahhhhhhhh

                You'll figured it out!! Yous gotz skillz...

                Later!!

                Joel

                [This message has been edited by The Supply Guy (edited 04-04-2003).]

                [This message has been edited by The Supply Guy (edited 04-14-2003).]

                Comment


                • #9
                  Re: Tools & Scripts

                  My god that is a long one! I installed the Symantec System Center Console that allows me to view parent servers and there client. Those that need to be moved, I just copy the GRC from the NAV server installation folder to the client and it moves withen 5 to 10 minutes. I am not sure if all this up here is worth it. Is it? :-)

                  Comment


                  • #10
                    Re: Tools & Scripts

                    T,

                    Notice this script pretty much does just that. It just automates the process. Plus this ensures the NAV/SAV service is running correctly on the remote system, and returns to you the managing server of the machine. This allows you to troubleshoot in case you don't get the response you want.

                    I provide this script to keep you from having to open SSC's MMC, and the other Windows Explorers to do that task.

                    Is that so wrong...long...?

                    Anywho...Yeah, the script is a bit large, but only because it's thorough, and documented.

                    Joel

                    Comment


                    • #11
                      Re: Tools &amp; Scripts

                      ;-) Hmmmm, maybe I will see if I can get this one working. I think the size of it scares me

                      Comment


                      • #12
                        Re: Tools & Scripts

                        Don't be.

                        Really, all you would need to change is the list of servers, and this should work. As long as the other things have been installed (LWForm, RegObj).

                        Enjoy! More to come next week.

                        (Matter of fact, this script is my second largest "active" script.)

                        Joel

                        Comment


                        • #13
                          Re: Tools & Scripts

                          Ok, how about detailing in this big one (only cuz Im nervous were to copy) The beiging and the end of each script I need to create. Or is this one BIG single script?

                          I am going through the script but it is hard to see were I need to make changes for my enviroment. Thanks

                          [This message has been edited by Trammel (edited 04-03-2003).]

                          Comment


                          • #14
                            Re: Tools & Scripts

                            T,

                            I've edited the script with START and END. The only things you should have to change are the list of servers, and the pointers to your files (where I've put "server/folder").

                            Cool?

                            Joel

                            Comment


                            • #15
                              Re: Tools & Scripts

                              I've been busting my butt lately on a new script/database to do hardware/software/operating system inventory, so there's my excuse for not checking in lately.

                              I've updated the NAV/SSC script above. Under the Function "UpdateServer", there is a situation where an Windows XP or 2K box was upgraded from a previous operating system. In this case, the original NAV/SAV settings are maintained. I've put in a "FolderExists" checker to verify where the GRC.DAT file is to be dropped.

                              I'm still working on the Computer Inventory script...hopefully I'll be done by the end of the month (it's working now, but I'm not happy with it's error checking and simple functionality).

                              I'll be posting another script next week, but with all the company visiting, and that pesky WORK thing getting in the way...I've got limited time to do the things I love...

                              Later!

                              Joel

                              Comment

                              Working...
                              X