Announcement

Collapse
No announcement yet.

Shared tools, but not shared settings

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

  • Shared tools, but not shared settings

    In my organization, each Admin uses Hyena, but they all like their own setups/layouts. Using the "shared.ini" file is great if all of the users want the same settings, but around here, all everyone wants are just the tools I've created for Hyena! Well, here's the script to do just that:

    '================================================= =========================
    '
    ' 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\Public\NT and 2K-XP Pro Tools, Upgrades & Patches\Hyena\Custom Tools2.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 objFile = fso.OpenTextFile(strTempFilePath)
    Do Until objFile.AtEndOfStream
    Redim Preserve arrFileLines(i)
    arrFileLines(i) = objFile.ReadLine
    i = i + 1
    Loop

    objFile.Close
    fso.DeleteFile(strTempFilePath)

    ' 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 & "]")

    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
    ==========================================

    Of course, the file it saves to has locked down permissions, so no one else can modify. When I update/create tools, I run this, then send a note to my other Admins to run the created REG file.

    Viola! All the tools/updates are at their disposal!

    Hope this can be of assistance to someone!

    Joel

  • #2
    Re: Shared tools, but not shared settings

    Thanks!. This can come in handy for a few users I'm sure.

    One (undocumented) tip, that 'might' work: If Hyena does not find a setting in the shared settings file, it will still read the registry value. So, if you create a shared settings file, then manually remove the entries that you don't want to share with others (in theory), Hyena will read the other values from the local registry.

    I have not tested this out, but that is what is supposed to happen...if anyone tests this out, please let us know so that we can document it as being an advanced feature.

    Thanks again for your support.
    Kevin Stanush
    SystemTools Software Inc.

    Comment

    Working...
    X