<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TAZ: TheTAZZone Network &#187; scripts</title>
	<atom:link href="http://www.thetazzone.com/category/security-tutorials/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetazzone.com</link>
	<description>Welcome to Internet Chaos: 960+ Games; Security, Networking, and General Tutorials; IRC Chat; and an Active Forum Community</description>
	<lastBuildDate>Sat, 21 Nov 2009 13:25:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mass EXE deployment</title>
		<link>http://www.thetazzone.com/mass-exe-deployment/</link>
		<comments>http://www.thetazzone.com/mass-exe-deployment/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 02:28:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=367</guid>
		<description><![CDATA[ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>Often times a rather useful utility is packaged as an EXE and you&#8217;d like to run it against multiple workstations. That&#8217;s easy enough, but can you do it with full accounting?</p>
<p>Here&#8217;s a pair of scripts (to be used together) that I&#8217;ve developed that will do just that. You&#8217;ll also need SOON.EXE, LOGEVENT.EXE, Microsoft Excel, and a text file containing the names of your workstations, one on each line (and administrative access from the command line).</p>
<p>2008.03.29 Edit: I added some error handling to the script to deal with machines that weren&#8217;t on the network (as I don&#8217;t always know which ones are and which ones aren&#8217;t at any given time). I also found that the functions using the WMI queries would hang on the odd workstation that didn&#8217;t have WMI configured correctly, so added error handling for that as well. Finally, I added a bit of feedback to the script, I like to know what the script is doing and where it is in execution. I&#8217;ve replaced deployEXE.VBS with the new script. (I&#8217;m making further changes to runEXE.VBS, I&#8217;ll post it when I&#8217;m done.)</p>
<p>2008.03.31 Edit: I modified the runEXE.VBS script to be OS aware, since the EVENTCREATE utility isn&#8217;t built into Windows 2000. Instead, the script makes use of the LOGEVENT.EXE utility (found in the Windows 2000 Resource Kit) located on a share. I also decided to add a bit of &#8220;debugging&#8221; output to a text file. If it&#8217;s unnecessary in your particular circumstance, feel free to remove it.</p>
<p>Script 1:</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>' File Name:   deployEXE.VBS<br />
' Script Name:   deployEXE.VBS<br />
' Created:      2008.03.12<br />
' Author:      Rob Durkin, STuladhar, Talen<br />
' E-mail:<br />
' ------------------------------------------------------------------------------<br />
' ARGUMENTS :<br />
'   None<br />
' ------------------------------------------------------------------------------</p>
<p>' ------------------------------------------------------------------------------<br />
' PURPOSE :<br />
'   Runs an executable on a remote workstation from a network share and logs the<br />
'   result to an Excel spreadsheet.<br />
'   - The main script will copy the EXE file and one other VBS script to the<br />
'   target machine.<br />
'   - The main script will execute SOON.EXE (available via download from<br />
'   Microsoft) to schedule the second VBS script on the target machine.<br />
'   - The second script will execute the EXE and make an entry in the<br />
'   application log based on success or failure.<br />
'   - The main script will then follow up and parse through the application log<br />
'   and check the result of the EXE.<br />
'   * NOTE: Excel must be installed on the workstation the script is run from.<br />
' ------------------------------------------------------------------------------<br />
'<br />
' ------------------------------------------------------------------------------<br />
' REVISION HISTORY :<br />
' Date:      2008.03.28<br />
' Time:<br />
' Issue:      Needed error handling in the event of unreachable workstations or<br />
'            other issues that would cause a workstation not to respond.<br />
' Solution:   Added workstation availability checks using ping as well as an On<br />
'            Error trap around the call to the Functions using WMI queries.<br />
'<br />
' ------------------------------------------------------------------------------</p>
<p>Option Explicit</p>
<p>' ------------------------------------------------------------------------------<br />
' FUNCTION LISTINGS<br />
' ------------------------------------------------------------------------------<br />
' Function:   getInstallStatus<br />
' Created:   2007.12.26<br />
' Author:   STuladhar<br />
' Arguments: strSuccess &amp; strFailed, defined in verifyInstall subroutine.<br />
' ------------------------------------------------------------------------------<br />
' Purpose:<br />
'   Checks the installation status in the remote workstation Application log.<br />
' ------------------------------------------------------------------------------<br />
Function getInstallStatus(strSuccess, strFailed, strComputer)<br />
Dim intCount, intFailed</p>
<p>intCount = getEventLogCount(strSuccess, strComputer)</p>
<p>If intCount &gt; 0 Then<br />
getInstallStatus = "P"<br />
Else<br />
intFailed = getEventLogCount(strFailed, strComputer)<br />
If intFailed &gt; 0 Then<br />
getInstallStatus = "F"<br />
Else<br />
getInstallStatus = "U"<br />
End If<br />
End If<br />
End Function</p>
<p>' ------------------------------------------------------------------------------<br />
' Function:   getEventLogCount<br />
' Created:   2007.12.26<br />
' Author:   STuladhar<br />
' Arguments: strWQL, success or failure WQL defined in verifyInstall subroutine.<br />
' ------------------------------------------------------------------------------<br />
' Purpose:<br />
'   Counts the number of events in an event log matching specific criteria<br />
'   defined via WQL query (see subVerifyInstall).<br />
' ------------------------------------------------------------------------------<br />
Function getEventLogCount(strWQL, strComputer)<br />
Dim colLoggedEvents<br />
Dim objWMISvc</p>
<p>Set objWMISvc = GetObject("winmgmts:" &amp; "{(Security)}\\" &amp; strComputer &amp; _<br />
"\root\cimv2")<br />
Set colLoggedEvents = objWMISvc.ExecQuery(strWQL)</p>
<p>getEventLogCount = colLoggedEvents.Count<br />
End Function</p>
<p>' ------------------------------------------------------------------------------<br />
' Function:   getEventLogMsg<br />
' Created:   2007.12.26<br />
' Author:   STuladhar<br />
' Arguments: strWQL, success or failure WQL defined in verifyInstall subroutine.<br />
' ------------------------------------------------------------------------------<br />
' Purpose:<br />
'   Collects the event log descriptions for each event log entry collected<br />
'   according to the WQL query in Function getEventLogCount.<br />
' ------------------------------------------------------------------------------<br />
Function getEventLogMsg(strWQL, strComputer)<br />
Dim colLoggedEvents<br />
Dim objEvent, objWMISvc<br />
Dim strMsg</p>
<p>Set objWMISvc = GetObject("winmgmts:" &amp; "{(Security)}\\" &amp; strComputer &amp; _<br />
"\root\cimv2")<br />
Set colLoggedEvents = objWMISvc.ExecQuery(strWQL)</p>
<p>For Each objEvent In colLoggedEvents<br />
strMsg = strMsg &amp; chr(13) &amp; objEvent.Message<br />
Next</p>
<p>' This is the length of the event log description. Change the length as<br />
' necessary (the event log descriptions are defined in runEXE.VBS)<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
getEventLogMsg = Left(strMsg, 255)<br />
End Function</p>
<p>' ==============================================================================<br />
' SCRIPT BODY<br />
' ==============================================================================<br />
Dim a, b, DD, MM, YYYY, vDy, vMo<br />
Dim errReturn, FileName, intProcessID<br />
Dim strExcelFile, strCmd, strComputer, strDest01, strDest02, strFile01<br />
Dim strFile02, strList, strPing, strText, strVBS, strWkstn<br />
Dim objExcel, objExecObject, objFileCopy, objFSO, objSheet, objShell, objTxtFile</p>
<p>Const ForReading = 1, ForWriting = 2, ForAppending = 8</p>
<p>' Bind to the file system object<br />
Set objFSO = CreateObject("Scripting.FileSystemObject")</p>
<p>' Bind to the shell object<br />
Set objShell = CreateObject("WScript.Shell")</p>
<p>' Call the subroutines in the correct order (they're listed in alphabetical<br />
' in the script body)<br />
subGetDate<br />
subCreateExcelWorkbook<br />
subMain<br />
' Pause the script for two and a half minutes (unnecessary if deploying to a<br />
' large number of workstations)<br />
WScript.Echo "Pausing script for 2 minutes and 30 seconds at " &amp; Now<br />
WScript.Sleep 150000<br />
subVerifyInstall<br />
subCleanUp</p>
<p>Sub subCleanUp<br />
WScript.Echo "Beginning clean up..."</p>
<p>' Save the spreadsheet and close the workbook<br />
objExcel.ActiveWorkbook.SaveAs strExcelFile<br />
objExcel.ActiveWorkbook.Close<br />
objExcel.Application.Quit</p>
<p>WScript.Echo "Clean up and script complete."<br />
End Sub</p>
<p>Sub subCreateExcelWorkbook<br />
' Define the filename for the Excel file, change to .XLSX if using Excel 2007<br />
strExcelFile = YYYY &amp; vMo &amp; vDy &amp; "deployEXE.XLS"</p>
<p>' Bind to the Excel application object<br />
Set objExcel = CreateObject("Excel.Application")</p>
<p>' If Excel not found, exit script<br />
If (Err.Number &lt;&gt; 0) Then<br />
WScript.Echo "Excel application not found."<br />
WScript.Quit<br />
End If</p>
<p>' Create a new workbook<br />
objExcel.Workbooks.Add</p>
<p>' Bind to and name the first worksheet in the workbook<br />
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
objSheet.Name = "Worksheet Name"</p>
<p>' Populate spreadsheet cells (column headings) with user-defined attributes<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
objSheet.Cells(1, 1).Value = "Target Computer"<br />
objSheet.Cells(1, 2).Value = "Time"<br />
objSheet.Cells(1, 3).Value = "Ping"<br />
objSheet.Cells(1, 4).Value = "SOON Execution"<br />
objSheet.Cells(1, 5).Value = "Utility Execution"<br />
End Sub</p>
<p>' This subroutine gets the year, month and day for the purposes of building the<br />
' Excel filename in the subroutine subCreateExcelWorkbook<br />
Sub subGetDate<br />
YYYY = Year(Now)<br />
MM = Month(Now)<br />
DD = Day(Now)</p>
<p>If MM &lt; 10 Then<br />
vMo = "0" &amp; MM<br />
Else<br />
vMo = MM<br />
End If</p>
<p>If DD &lt; 10 Then<br />
vDy = "0" &amp; DD<br />
Else<br />
vDy = DD<br />
End If<br />
End Sub</p>
<p>Sub subMain<br />
WScript.Echo "Deploying software..."</p>
<p>' Variable containing UNC path to workstation list text file<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strList = "\\SERVER\Share" &amp; _<br />
"\workstationList.TXT"</p>
<p>' Variable containing UNC path to executable that needs to be copied to<br />
' remote machine<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strFile01 = "\\SERVER\Share" &amp; _<br />
"\Utility.EXE"</p>
<p>' Variable containing UNC path to script that needs to be copied to remote<br />
' machine<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strFile02 = "\\SERVER\Share" &amp; _<br />
"\runEXE.VBS"</p>
<p>' Variable containing script that will launch executable on remote machine<br />
strVBS = "runEXE.VBS"</p>
<p>' Open the text file containing the list of workstation names for reading<br />
Set objTxtFile = objFSO.OpenTextFile(strList, ForReading)</p>
<p>' Set the Excel row variable to start on the second row<br />
a = 2</p>
<p>' Begin looping through workstations<br />
Do Until objTxtFile.AtEndOfStream<br />
' Get machine name from text file (and remove any whitespaces)<br />
strWkstn = Trim(objTxtFile.ReadLine())</p>
<p>' Ping the workstation, skipping it if it is unreachable on the network<br />
strPing = "%comspec% /c ping -n 3 -w 1000 " &amp; strWkstn &amp; ""<br />
Set objExecObject = objShell.Exec(strPing)</p>
<p>Do While Not objExecObject.StdOut.AtEndOfStream<br />
strText = objExecObject.StdOut.ReadAll()</p>
<p>If InStr(strText, "Reply") &gt; 0 Then<br />
WScript.Echo "Starting on " &amp; strWkstn &amp; "..."</p>
<p>' UNC path to destination where executable and script needs to be<br />
' copied to on the remote machine<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strDest01 = "\\" &amp; strWkstn &amp; "\C$" &amp; _<br />
"\Utility.EXE"<br />
strDest02 = "\\" &amp; strWkstn &amp; "\C$" &amp; _<br />
"\runEXE.VBS"</p>
<p>' Copy the executable package to the target PC<br />
Set objFileCopy = objFSO.GetFile(strFile01)<br />
objFileCopy.Copy(strDest01), True</p>
<p>' Copy the VBScript to the target PC<br />
Set objFileCopy = objFSO.GetFile(strFile02)<br />
objFileCopy.Copy(strDest02), True</p>
<p>' Variable to hold the construction of the SOON command<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strCmd = """\\SERVER\Share\SOON.EXE"" \\" &amp; _<br />
strWkstn &amp; " 120 ""cscript C:\" &amp; strVBS &amp; """"</p>
<p>' Variable to hold the error return code of the SOON command<br />
errReturn = objShell.Run(strCmd)</p>
<p>' Time stamp the spreadsheet<br />
objSheet.Cells(a, 2).Value = Now</p>
<p>' Evaluate the error return code of the SOON command and write<br />
' results to Excel spreadsheet<br />
If errReturn = 0 Then<br />
objSheet.Cells(a, 1).Value = strWkstn<br />
objSheet.Cells(a, 4).Value = "Success"<br />
Else<br />
objSheet.Cells(a, 1).Value = strWkstn<br />
objSheet.Cells(a, 4).Value = "Failure"<br />
End If<br />
Else<br />
WScript.Echo vbTab &amp; strWkstn &amp; " unreachable on network."<br />
objSheet.Cells(a, 1).Value = strWkstn<br />
objSheet.Cells(a, 2).Value = Now<br />
objSheet.Cells(a, 3).Value = "Unreachable on network."<br />
objSheet.Cells(a, 4).Value = "Failure"<br />
End If<br />
Loop</p>
<p>' Increment the Excel row variable to move to the next row down<br />
a = a + 1<br />
Loop</p>
<p>' Close the text file<br />
objTxtFile.Close<br />
WScript.Echo "Deployment complete."<br />
End Sub</p>
<p>Sub subVerifyInstall<br />
WScript.Echo "Verifying execution..."</p>
<p>Dim strEvtMsg, strFailed, strStatus, strSource, strSuccess<br />
Dim intEvtCode01, intEvtCode02</p>
<p>' Define the Source being looked for in the Application log<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strSource = "Utility"</p>
<p>' Define the Event IDs being looked for in the Application log<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
intEvtCode01 = 990 ' Success<br />
intEvtCode02 = 991 ' Failure</p>
<p>' WQL query definition to look for any entries from a specific source with a<br />
' specific event code<br />
strFailed = "Select * From Win32_NTLogEvent Where Logfile = 'Application'" _<br />
&amp; " and SourceName = '" &amp; strSource &amp; "' and EventCode = " &amp; intEvtCode02<br />
strSuccess = "Select * From Win32_NTLogEvent Where Logfile = 'Application'" _<br />
&amp; " and SourceName = '" &amp; strSource &amp; "' and EventCode = " &amp; intEvtCode01</p>
<p>' Set the Excel row variable to start on the second row<br />
b = 2<br />
Do While objSheet.Cells(b, 1).Value &lt;&gt; ""<br />
strComputer = objSheet.Cells(b, 1).Value</p>
<p>' Ping the workstation, skipping it if it is unreachable on the network<br />
strPing = "%comspec% /c ping -n 3 -w 1000 " &amp; strComputer &amp; ""<br />
Set objExecObject = objShell.Exec(strPing)</p>
<p>Do While Not objExecObject.StdOut.AtEndOfStream<br />
strText = objExecObject.StdOut.ReadAll()</p>
<p>If InStr(strText, "Reply") &gt; 0 Then<br />
' Parse the application log based upon the value of the cell in the<br />
' fourth column of the spreadsheet<br />
Select Case objSheet.Cells(b, 4).Value<br />
Case "Success"<br />
WScript.Echo "Verifying execution on " &amp; strComputer &amp; "..."</p>
<p>On Error Resume Next<br />
strStatus = getInstallStatus _<br />
(strSuccess, strFailed, strComputer)</p>
<p>If strStatus = "F" Then<br />
strEvtMsg = getEventLogMsg(strFailed, strComputer)<br />
'objSheet.Cells(b, 5).Value = strEvtMsg<br />
Else<br />
strEvtMsg = getEventLogMsg(strSuccess, strComputer)<br />
'objSheet.Cells(b, 5).Value = strEvtMsg<br />
End If<br />
objSheet.Cells(b, 5).Value = strEvtMsg<br />
On Error Goto 0</p>
<p>Case Else<br />
End Select<br />
Else<br />
WScript.Echo vbTab &amp; strComputer &amp; " unreachable on network."<br />
End If<br />
Loop</p>
<p>b = b + 1<br />
Loop</p>
<p>WScript.Echo "Verification complete."<br />
End Sub<br />
' ==============================================================================<br />
' END OF SCRIPT: deployEXE.VBS<br />
' ==============================================================================</code></dd>
</dl>
<p>Script 2:</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>' File Name:   runEXE.VBS<br />
' Script Name:   runEXE.VBS<br />
' Created:      2008.03.14<br />
' Author:      Talen<br />
' E-mail:<br />
' ------------------------------------------------------------------------------<br />
' ARGUMENTS :<br />
'   None<br />
' ------------------------------------------------------------------------------</p>
<p>' ------------------------------------------------------------------------------<br />
' PURPOSE :<br />
'   This script will run an executable on a workstation and create a custom entry<br />
'   in the application log.<br />
'   * NOTE: EVENTCREATE is a command line utility in Windows XP/Vista used to<br />
'   create custom events in   the application log. See 'EVENTCREATE /?' for more<br />
'   information. LOGEVENT is a command line utility found in the Windows 2000<br />
'   Resource Kit and performs more or less the same function. See 'LOGEVENT /?'<br />
'   for more information<br />
' ------------------------------------------------------------------------------<br />
'<br />
' ------------------------------------------------------------------------------<br />
' REVISION HISTORY :<br />
' Date:<br />
' Time:<br />
' Issue:<br />
' Solution:<br />
'<br />
' ------------------------------------------------------------------------------</p>
<p>' ==============================================================================<br />
' SCRIPT BODY<br />
' ==============================================================================<br />
Option Explicit</p>
<p>Dim colItems, errReturn<br />
Dim objFSO, objItem, objNet, objShell, objTxtFile, objWMI<br />
Dim strCmd, strExe, strEvtFailure, strEvtSuccess, strOS, strRunEXEDebug<br />
Dim strWkstn</p>
<p>Const ForWriting = 2</p>
<p>' Bind to the file system, network and shell objects<br />
Set objFSO = CreateObject("Scripting.FileSystemObject")<br />
Set objNet = CreateObject("WScript.Network")<br />
Set objShell = CreateObject("WScript.Shell")</p>
<p>' Define the name of the debug output file<br />
strRunEXEDebug = "C:\runEXEDebugOutput.TXT"</p>
<p>' Create the text file and close it<br />
Set objTxtFile = objFSO.CreateTextFile(strRunEXEDebug)<br />
objTxtFile.Close</p>
<p>' Open the text file for writing<br />
Set objTxtFile = objFSO.OpenTextFile(strRunEXEDebug, ForWriting, True)</p>
<p>' Time stamp the debug file<br />
objTxtFile.WriteLine(Now)</p>
<p>' Get the NetBIOS name of the workstation<br />
strWkstn = objNet.ComputerName<br />
objTxtFile.WriteLine("Workstation name: " &amp; strWkstn)</p>
<p>' Define the executable and any parameters/arguments<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strExe = "Utility.EXE Parameters"</p>
<p>' Contruct the command to be run from the shell<br />
strCmd = "C:\" &amp; strExe<br />
objTxtFile.WriteLine("Shell command: " &amp; strCmd)</p>
<p>' Bind to the WMI service and query for the OS of the workstation<br />
Set objWMI = GetObject("winmgmts:\\" &amp; strWkstn &amp; "\root\CIMV2")<br />
Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)</p>
<p>' Set the strOS variable to the version number of the OS<br />
For Each objItem in colItems<br />
strOS = Left(objItem.Version, 3)<br />
Next<br />
objTxtFile.WriteLine("OS version number: " &amp; strOS)</p>
<p>' Use the appropriate commands to create a custom application log entry based<br />
' upon the installed OS (Vista is 6.0 and uses EVENTCREATE)<br />
Select Case strOS<br />
Case "5.0" ' Windows 2000<br />
' Define the command to create a successful entry in the application log<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strEvtSuccess = "\\SERVER\Share\LOGEVENT.EXE -S I " &amp; _<br />
"-R Utility -E 990 -T 10000 ""Utility execution success."""</p>
<p>' Define the command to create a successful entry in the application log<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strEvtFailure = "\\SERVER\Share\LOGEVENT.EXE -S E " &amp; _<br />
"-R Utility -E 991 -T 10000 ""Utility execution failure."""</p>
<p>objTxtFile.WriteLine("OS version: Windows 2000")<br />
Case "5.1" ' Windows XP<br />
' Define the command to create a successful entry in the application log<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strEvtSuccess = "EVENTCREATE /T INFORMATION /SO Utility /ID 990 /L " &amp; _<br />
"APPLICATION /D ""Utility execution success."""</p>
<p>' Define the command to create an unsuccessful entry in the application<br />
' log<br />
' *** CHANGE TO SUIT NEEDS AS NECESSARY ***<br />
strEvtFailure = "EVENTCREATE /T ERROR /SO Utility /ID 991 /L " &amp; _<br />
"APPLICATION /D ""Utility execution failure."""</p>
<p>objTxtFile.WriteLine("OS version: Windows XP")<br />
End Select</p>
<p>' Execute the command and populate the errReturn variable with the result code<br />
errReturn = objShell.Run(strCmd)<br />
objTxtFile.WriteLine("errReturn: " &amp; errReturn)</p>
<p>' Evaluate the result code and create the appropriate entry in the workstation<br />
' application log<br />
If errReturn = 0 Then<br />
objTxtFile.WriteLine("Logging command: " &amp; strEvtSuccess)<br />
' Shell command to make success entry in application log.<br />
objShell.Run strEvtSuccess<br />
Else<br />
objTxtFile.WriteLine("Logging command: " &amp; strEvtFailure)<br />
' Shell command to make failure entry in application log.<br />
objShell.Run strEvtFailure<br />
End If</p>
<p>objTxtFile.Close<br />
' ==============================================================================<br />
' END OF SCRIPT: deployEXE.VBS<br />
' ==============================================================================</code></dd>
</dl>
<p>Just modify the scripts in the areas I&#8217;ve commented to get the script to work for you.</p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/mass-exe-deployment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cisco devices: Rather than create the folder structure by hand</title>
		<link>http://www.thetazzone.com/cisco-devices-rather-than-create-the-folder-structure-by-hand/</link>
		<comments>http://www.thetazzone.com/cisco-devices-rather-than-create-the-folder-structure-by-hand/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 02:25:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=366</guid>
		<description><![CDATA[ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>I manage a *lot* of network devices (all of them Cisco), so I maintain a repository of configurations which are all text files. I devised a method to keep all the configurations straight, and essentially maintain a kind of change control system.</p>
<p>I have a folder on my system named &#8220;Network Device Configurations&#8221;. Inside this folder are folders named with the hostname of each individual device. Each device folder has subfolders named by year (e.g. 2008). Each year subfolder has twelve subfolders, 01 through 12, for each month of the year. Rather than create the folder structure by hand, I use the following script:</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>Set objFSO = CreateObject("Scripting.FileSystemObject")<br />
Set WshShell = WScript.CreateObject("WScript.Shell")</p>
<p>strDeviceName = InputBox("Enter the device name:", "Network Device Name")</p>
<p>If strDeviceName = "" Then<br />
WshShell.Popup "You must provide a device name!", 10, "Missing Device " &amp; _<br />
"Name!", 48<br />
WScript.Quit<br />
End If</p>
<p>' * * * Change This Line ! ! ! * * *<br />
strTopLevelFldr = "C:\PathToYour\Network Device Configurations\" &amp; _<br />
strDeviceName<br />
strYFldr = strTopLevelFldr &amp; "\" &amp; Year(Date)</p>
<p>If objFSO.FolderExists (strTopLevelFldr) Then<br />
WshShell.Popup "Top level folder already exists and will not be created." &amp; _<br />
vbCrLf, 10, "Folder Exists!", 48<br />
subCreateYFldr<br />
Else<br />
WshShell.Popup "Folder does not already exist and will be created." &amp; _<br />
vbCrLf, 10, "New Folder", 48<br />
Set objFldr = objFSO.CreateFolder(strTopLevelFldr)<br />
subCreateYFldr<br />
End If</p>
<p>Sub subCreateYFldr<br />
If objFSO.FolderExists (strYFldr) Then<br />
WScript.Quit<br />
Else<br />
Set objFldr = objFSO.CreateFolder(strYFldr)<br />
subCreateMFldrs<br />
End If<br />
End Sub</p>
<p>Sub subCreateMFldrs<br />
intM = 1</p>
<p>Do Until intM = 10<br />
strMFldr = strYFldr &amp; "\0" &amp; intM<br />
Set objFldr = objFSO.CreateFolder(strMFldr)<br />
intM = intM + 1<br />
Loop</p>
<p>Do Until intM = 13<br />
strMFldr = strYFldr &amp; "\" &amp; intM<br />
Set objFldr = objFSO.CreateFolder(strMFldr)<br />
intM = intM + 1<br />
Loop<br />
End Sub</p>
<p>WshShell.Popup "Creation of:" &amp; vbCrLf &amp; vbCrLf &amp; strTopLevelFldr &amp; _<br />
vbCrLf &amp; vbCrLf &amp;   "and all subfolders complete.", 10, _<br />
"Folders Created!", 48</code></dd>
</dl>
<p>Then, any and every time I edit a device configuration, the first thing I do is take a copy of the current configuration and save it to the appropriate folder and name it using the following convention:</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>YYYYMMDD HHMM DeviceName Backup Config.TXT</code></dd>
</dl>
<p>When I&#8217;m done making any changes, I&#8217;ll save the new file using a similar convention:</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>YYYYMMDD HHMM DeviceName New ACL.TXT</code></dd>
</dl>
<p>Generally using short, but descriptive nomenclature for whatever change I made. I also rarely save the entire config in this file, but usually just the changes made.</p>
<p>This is helpful in that I can review historical configurations and see what changes were made when (and the above naming convention keeps everything organized in chronological order when sorted by name).</p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/cisco-devices-rather-than-create-the-folder-structure-by-hand/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>quickly bomb through a directory</title>
		<link>http://www.thetazzone.com/quickly-bomb-through-a-directory/</link>
		<comments>http://www.thetazzone.com/quickly-bomb-through-a-directory/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 02:22:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=365</guid>
		<description><![CDATA[ORIGINALLY POSTED BY DINO FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY DINO FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>Sometimes I just need to quickly bomb through a directory.</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>'# GLOBALS ##########################################################################<br />
Dim   intCounter</p>
<p>'#########################################################################<br />
Private Sub TraverseDir(objFolder)<br />
Dim objFile<br />
For Each objFile in objFolder.Files<br />
WScript.Echo "Checking file: "&amp; objFile.Path<br />
intCounter = intCounter + 1<br />
Next<br />
</code></dd>
</dl>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/quickly-bomb-through-a-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enumerate the users of a AD Group</title>
		<link>http://www.thetazzone.com/enumerate-the-users-of-a-ad-group/</link>
		<comments>http://www.thetazzone.com/enumerate-the-users-of-a-ad-group/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 02:19:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=364</guid>
		<description><![CDATA[ORIGINALLY POSTED BY CEMETRIC FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY CEMETRIC FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7215">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>Enumerate the users of a AD Group. Very easy script, but can come in handy sometimes, save from having to use Users &amp; Computers, also it will write the list of users to a file you can specify. You could make the script easier to use if you implement a prompt for entering the groupname you want to enumerate.</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code><br />
strDom = "DomainName"<br />
strGrp = "GroupName"</p>
<p>strMbrs = "Members of: " &amp;  strGrp &amp; vbCRLF</p>
<p>set objDom = GetObject("WinNT://" &amp; strDom &amp; "/" &amp; strGrp)</p>
<p>for each objMbr in objDom.Members</p>
<p>strMbrs = strMbrs &amp; objMbr.FullName &amp; " (" &amp; objMbr.Class &amp;")" &amp; vbCRLF</p>
<p>Next</p>
<p>Set oFilesys = CreateObject("Scripting.FilesystemObject")<br />
Set oFiletxt = oFilesys.CreateTextFile("Pathtotextfile", True)<br />
sPath = oFilesys.GetAbsolutePathName("Pathtotextfile")</p>
<p>sFilename= oFilesys.GetFileName(sPath)</p>
<p>oFiletxt.WriteLine(strMbrs)</p>
<p>oFiletxt.Close</p>
<p>'If you also want to see the users in a prompt enable following line</p>
<p>'Wscript.Echo strMbrs</p>
<p></code></dd>
</dl>
<p>Hope I didn&#8217;t type any errors, had to manually write it :s</p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/enumerate-the-users-of-a-ad-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>deploy an MSI package to a group of workstations</title>
		<link>http://www.thetazzone.com/deploy-an-msi-package-to-a-group-of-workstations/</link>
		<comments>http://www.thetazzone.com/deploy-an-msi-package-to-a-group-of-workstations/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 02:30:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=368</guid>
		<description><![CDATA[ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>Much like the last script I posted, this script will deploy an MSI package to a group of workstations (provided in a text file). All you need is the list of workstations, the software package, and Microsoft Excel (and again, administrative access to each workstation from the command line).</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>' File Name:   deployMSI.VBS<br />
' Script Name:   deployMSI.VBS<br />
' Created:      2008.03.28<br />
' Author:      Rob Durkin, STuladhar, Talen<br />
' E-mail:<br />
' ------------------------------------------------------------------------------<br />
' ARGUMENTS :<br />
'   None<br />
' ------------------------------------------------------------------------------</p>
<p>' ------------------------------------------------------------------------------<br />
' PURPOSE :<br />
' PURPOSE :<br />
'   Installs an MSI on a remote workstation from a network share and logs the</code></dd>
</dl>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/deploy-an-msi-package-to-a-group-of-workstations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>change the &#8220;My Computer&#8221; name from &#8220;My Computer&#8221; to whatever the NetBIOS name of the (Windows) workstation is</title>
		<link>http://www.thetazzone.com/change-the-my-computer-name-from-my-computer-to-whatever-the-netbios-name-of-the-windows-workstation-is/</link>
		<comments>http://www.thetazzone.com/change-the-my-computer-name-from-my-computer-to-whatever-the-netbios-name-of-the-windows-workstation-is/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 02:17:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=363</guid>
		<description><![CDATA[ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>Adding this little chunk of code to your login script will change the &#8220;My Computer&#8221; name from &#8220;My Computer&#8221; to whatever the NetBIOS name of the (Windows) workstation is. Handy if you use a DNS-based remote access solution in the enterprise. Most users, without fail, can&#8217;t tell you the name of their workstation.</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>Const MY_COMPUTER = &amp;H11&amp;</p>
<p>Set objNetwork = CreateObject("Wscript.Network")<br />
objComputerName = objNetwork.ComputerName<br />
Set objShell = CreateObject("Shell.Application")<br />
Set objFolder = objShell.Namespace(MY_COMPUTER)<br />
Set objFolderItem = objFolder.Self<br />
objFolderItem.Name = objComputerName</code></dd>
</dl>
<p>I find it helpful.</p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/change-the-my-computer-name-from-my-computer-to-whatever-the-netbios-name-of-the-windows-workstation-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>prevent a logoff from happening if a specific program is running</title>
		<link>http://www.thetazzone.com/prevent-a-logoff-from-happening-if-a-specific-program-is-running/</link>
		<comments>http://www.thetazzone.com/prevent-a-logoff-from-happening-if-a-specific-program-is-running/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 02:14:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=362</guid>
		<description><![CDATA[ORIGINALLY POSTED BY KBERN3 FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY KBERN3 FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>This script is designed to prevent a logoff from happening if a specific program is running, otherwise, if the program isn&#8217;t found, let the logoff process continue. I don&#8217;t know everyone&#8217;s script knowledge level so just in case I need to clarify I use the words process/program/executible interchangeably throughout the following explanation:</p>
<p>When the script is double-clicked it searches through the process list for an executible file. In the example below the executible is called vmware-vmx.exe. If this process is running on the computer the script will display a message to the user stating <span style="font-style: italic;">&#8220;x VMs are running.  Please turn them off before continuing to logoff&#8221;. </span>If the process is not found the script will logoff the user. In order for this to work you need to put a shortcut to this script in the Start menu (and/or desktop) and edit local group policy so that the logoff button no longer appears in the Start or Ctrl+Alt+Del menu. This will force users to click on the script whenever they want to logoff. You also need to change the process/program name to whatever program you want the script to search for. <span style="font-weight: bold;">Replace where it says vmware-vmx and VMware with your program&#8217;s name.</span> You can also use this script to prevent shutdown and restart.  I made a comment towards the end of the script as to how.</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310">Select all</a></dt>
<dd><code>'************************************************************<br />
' PREVENT LOGOFF SCRIPT<br />
' Created: 6/14/2007<br />
' Updated: 7/3/2007<br />
'<br />
' A big THANK YOU to Adam, Jaker, Guy Thomas, and Lisa<br />
' ***********************************************************</code></p>
<p>&#8216; Require all variables to be declared before they can be used.<br />
&#8216; This helps with debugging issues<br />
Option Explicit</p>
<p>&#8216; Define all of the variables<br />
Dim strComputer, objWMIService, colProcesses,<br />
Dim objProcess, strList, VMcount</p>
<p>&#8216; Establish variables<br />
strComputer = &#8220;.&#8221; &#8217;setting strComputer to &#8220;.&#8221; connects to the local machine.<br />
VMcount = 0 &#8217;starts the process count at 0</p>
<p>&#8216; All WMI scripts begin by connecting to the Windows Management Instruments interface<br />
Set objWMIService = GetObject(&#8221;winmgmts:&#8221; _<br />
&amp; &#8220;{impersonationLevel=impersonate}!\\&#8221; _<br />
&amp; strComputer &amp; &#8220;\root\cimv2&#8243;)</p>
<p>&#8216; Get a collection of all running processes<br />
Set colProcesses = objWMIService.ExecQuery(&#8221;Select * FROM Win32_Process&#8221;)</p>
<p>&#8216; Cycle through every currently running process<br />
For Each objProcess in colProcesses<br />
&#8216;Check to see if the program is currently running<br />
If objProcess.Name = &#8220;vmware-vmx.exe&#8221; Then<br />
&#8216;the program is running if the above statement is true.<br />
VMcount = VMcount + 1 &#8216;Count the number of running processes<br />
End If<br />
Next<br />
If VMcount &gt; 0 Then<br />
&#8216;Build the message box text notifying the user of any running processes<br />
strList = strList &amp; VMcount _<br />
&amp; &#8221; VMware process(es) running.&#8221; _<br />
&amp; &#8220;  Please power off before continuing to logoff.&#8221; &amp; vbCr<br />
&#8216;This message box will only appear if the process was found<br />
WSCript.Echo strList<br />
Else<br />
&#8216;Create another variable to connect to the Windows shell service.<br />
Dim objWSHShell<br />
&#8216;Connect to the Windows shell service<br />
Set objWSHShell = CreateObject(&#8221;WScript.Shell&#8221;)<br />
&#8216;Execute the logoff command to logoff<br />
objWSHShell.Run &#8220;shutdown -l&#8221; &#8216;change to -s to shutdown or -r to restart<br />
End if<br />
&#8216;Quit the script<br />
WScript.Quit</p>
</dd>
</dl>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/prevent-a-logoff-from-happening-if-a-specific-program-is-running/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>create a new user in AD as well as a new mailbox on an Exchange server</title>
		<link>http://www.thetazzone.com/create-a-new-user-in-ad-as-well-as-a-new-mailbox-on-an-exchange-server/</link>
		<comments>http://www.thetazzone.com/create-a-new-user-in-ad-as-well-as-a-new-mailbox-on-an-exchange-server/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 02:12:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=361</guid>
		<description><![CDATA[ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7215">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>This script should create a new user in AD as well as a new mailbox on an Exchange server. Use this one with caution, I haven&#8217;t really tested it yet.</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>Option Explicit</p>
<p>Dim RootDSE, myDomain<br />
'-------------------------------------------------------------------------------<br />
Set RootDSE = GetObject("LDAP://RootDSE")<br />
Set myDomain = GetObject("LDAP://" &amp; RootDSE.Get("DefaultNamingContext"))</p>
<p>myDomainADSPath = myDomain.ADSPath      ' LDAP://DC=myDomain,DC=com<br />
myDomainPath = MID(myDomain.ADSPath,8)   'DC=myDomain,DC=com</p>
<p>strTitle = "New User with Exchange Mailbox"<br />
strUserName = InputBox("What is the name of the new user?", strTitle, "John Doe")<br />
strSAM = InputBox("What will the be the user's SAMAccount name?", strTitle, "JDoe")</code></dd>
</dl>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/create-a-new-user-in-ad-as-well-as-a-new-mailbox-on-an-exchange-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>check the storage limits on all mailboxes *not* using the default storage limits</title>
		<link>http://www.thetazzone.com/check-the-storage-limits-on-all-mailboxes-not-using-the-default-storage-limits/</link>
		<comments>http://www.thetazzone.com/check-the-storage-limits-on-all-mailboxes-not-using-the-default-storage-limits/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 02:07:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=360</guid>
		<description><![CDATA[ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>This is a script I found that will check the storage limits on all mailboxes *not* using the default storage limits on an Exchange server. It outputs to a CSV file and is very handy for keeping track of users who&#8217;ve had their limits modified. If you&#8217;re an Exchange Admin, you know precisely what I&#8217;m talking about.</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>' emailStorageLimts.vbs<br />
' VBScript program to document users who do not have "Use Defaults"<br />
' checked for their email storage.<br />
' Copyright (c) 2005 Burt Johnson - bdjsoftware<br />
'#######################################################################<br />
Option Explicit</p>
<p>Dim objFSO, logFile<br />
Dim oConnection1, oCommand1, rs, objUser<br />
Dim Query</p>
<p>Const LDAP_TREE = "LDAP://DC=myDomain,DC=com"<br />
Const ADS_SCOPE_SUBTREE   = 2<br />
Const LOG_FILE   = "eMailStorageLimts.CSV"<br />
'--------------------------------------------------------------------<br />
' Set up log file<br />
'--------------------------------------------------------------------<br />
Set objFSO = CreateObject("Scripting.FileSystemObject")<br />
Set logFile = objFSO.CreateTextFile(LOG_FILE)<br />
'--------------------------------------------------------------------<br />
' Create the connection and command object.<br />
'--------------------------------------------------------------------<br />
Set oConnection1 = CreateObject("ADODB.Connection")<br />
Set oCommand1 = CreateObject("ADODB.Command")<br />
'--------------------------------------------------------------------<br />
' Open the connection.<br />
'--------------------------------------------------------------------<br />
oConnection1.Provider = "ADsDSOObject"  ' This is the ADSI OLE-DB provider name<br />
oConnection1.Open "Active Directory Provider"<br />
'---------------------------------------------------------------------<br />
' Create a command object for this connection.<br />
'---------------------------------------------------------------------<br />
Set oCommand1.ActiveConnection = oConnection1<br />
'---------------------------------------------------------------------<br />
' Compose a search string.<br />
'----------------------------------------------------------------------<br />
oCommand1.CommandText = "Select distinguishedName from '" &amp; LDAP_TREE &amp; "' WHERE objectCategory='Person' AND objectClass='user'"<br />
oCommand1.Properties("Page Size") = 7000<br />
oCommand1.Properties("Timeout") = 120<br />
oCommand1.Properties("Searchscope") = ADS_SCOPE_SUBTREE<br />
oCommand1.Properties("Cache Results") = False<br />
'----------------------------------------------------------------------<br />
' Execute the query.<br />
'----------------------------------------------------------------------<br />
Set rs = oCommand1.Execute<br />
'----------------------------------------------------------------------<br />
' Navigate the record set<br />
'----------------------------------------------------------------------<br />
MsgBox("Starting Search")</p>
<p>While Not rs.EOF</p>
<p>Query = "LDAP://" &amp; rs.Fields("distinguishedName")<br />
Set objUser = GetObject(Query)<br />
If objUser.mDBUseDefaults = "False" Then<br />
logFile.WriteLine("""" &amp; objUser.distinguishedName &amp; """,""" &amp; objUser.mDBOverHardQuotaLimit &amp; """,""" &amp; objUser.mDBOverQuotaLimit &amp; """,""" &amp; objUser.mDBStorageQuota &amp; """")<br />
End If</p>
<p>rs.MoveNext<br />
Wend</p>
<p>Set logFile = Nothing<br />
Set oCommand1 = Nothing<br />
Set oConnection1 = Nothing<br />
Set rs = Nothing<br />
Set objUser = Nothing</p>
<p>msgBox("Done Searching")</code></dd>
</dl>
<p>The only thing that really needs editing is the LDAP name of the domain you&#8217;re running the script in. The line towards the bottom in the If statement is one long line, even though it may wrap on your screen.</p>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/check-the-storage-limits-on-all-mailboxes-not-using-the-default-storage-limits/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>use VBScript to control NTBackup</title>
		<link>http://www.thetazzone.com/use-vbscript-to-control-ntbackup/</link>
		<comments>http://www.thetazzone.com/use-vbscript-to-control-ntbackup/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 02:04:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.thetazzone.com/?p=359</guid>
		<description><![CDATA[ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM HERE
Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to [...]]]></description>
			<content:encoded><![CDATA[<p>ORIGINALLY POSTED BY TALEN FOR THETAZZONE/TAZFORUM <a href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7215">HERE</a></p>
<p>Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network</p>
<p><em><strong>Please refer to the original post as not all the script may be visible here.</strong></em></p>
<p>Speaking of backups, how many of you backup your workstations at home regularly? Most of us probably should, but the scheduler provided for NTBackup doesn&#8217;t work very well, and who can afford a high-end solution like Backup Exec? Microsoft has added a regular backup feature to OneCare Live, but it&#8217;s limited as to where you can target the backups. Fortunately, you can use VBScript to control NTBackup (and even add logging), and then use the Task Scheduler to run the script on a schedule.<br />
Here&#8217;s the script with comments that should explain most everything. If you have any other questions, PM me or start a new thread in the Scripting forum.</p>
<dl class="codebox">
<dt>Code: <a onclick="selectCode(this); return false;" href="http://tazforum.thetazzone.com/viewtopic.php?f=56&amp;t=7310#">Select all</a></dt>
<dd><code>Option Explicit</p>
<p>Dim objFSO<br />
Dim objShell<br />
Dim strOutlook<br />
Dim bksFile<br />
Dim bkfFile<br />
Dim strBackup<br />
Dim strLogFile<br />
Dim oldLogFile<br />
Dim objWrite<br />
Dim objFile<br />
Dim strMonth<br />
'###################################################################<br />
Set objFSO = CreateObject("Scripting.FileSystemObject")</code></dd>
</dl>


<!-- Begin TwitThis script (http://twitthis.com/) -->
<div style="text-align:left;">
<script type="text/javascript" src="http://s3.chuug.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
<!--
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://s3.chuug.com/chuug.twitthis.resources/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
//-->
</script>
</div>
<!-- /End -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetazzone.com/use-vbscript-to-control-ntbackup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
