<?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>Wayne Zimmerman&#039;s Blog &#187; Logoff</title>
	<atom:link href="http://www.waynezim.com/tag/logoff/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.waynezim.com</link>
	<description>My World of Tech, Life and Anything Else</description>
	<lastBuildDate>Fri, 10 Feb 2012 00:13:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Remove Temporary Files at Logoff</title>
		<link>http://www.waynezim.com/2009/04/remove-temporary-files-at-logoff/</link>
		<comments>http://www.waynezim.com/2009/04/remove-temporary-files-at-logoff/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 19:17:02 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[Logoff]]></category>
		<category><![CDATA[Temp]]></category>
		<category><![CDATA[Temp Files]]></category>
		<category><![CDATA[Temporary Files]]></category>
		<category><![CDATA[Temporary Internet Files]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[VBscript]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=55</guid>
		<description><![CDATA[Over time users tend to open a lot of items programs that write little files to be used just once to print a document or a small setting for a program. These items build up over time and cause your computer to run slower due to your antivirus solution scanning it, your hard drive taking [...]]]></description>
			<content:encoded><![CDATA[<p>Over time users tend to open a lot of items programs that write little files to be used just once to print a document or a small setting for a program. These items build up over time and cause your computer to run slower due to your antivirus solution scanning it, your hard drive taking longer to find a free space of disk to write your new file or has to spend more time gathering up fragments of your file from in between these temp files. The solution here is pretty simple, these files need to go, and probably the easiest solution is the remove them when the user logs off. This doesn&#8217;t require anymore time for the user and typically isn&#8217;t a problem since most computers are logged on and off once a day.
<p>This script will remove the most common temporary folder for the user as well as remove any of the temporary internet files that they have gathered while surfing the web. When we implemented this script we noticed that the antivirus scan time and how many files it scanned were significantly reduced providing a better and faster workstation for your users. This script should be placed in the Group Policy for users as one of their logoff script.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.waynezim.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=55&amp;download=cleantemp.vbs">cleantemp.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p552"><td class="code" id="p55code2"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Const</span> TEMPORARY_INTERNET_FILES = &amp;H20&amp;
<span style="color: #000080;">dim</span> intDepth
&nbsp;
<span style="color: #000080;">Set</span> objShell = CreateObject(<span style="color: #800000;">&quot;Shell.Application&quot;</span>)
<span style="color: #000080;">Set</span> objFSO = CreateObject(<span style="color: #800000;">&quot;Scripting.FileSystemObject&quot;</span>)
&nbsp;
<span style="color: #008000;">'Clean User Temporary Intenet Files
</span><span style="color: #000080;">Set</span> objNameSpace = objShell.Namespace(TEMPORARY_INTERNET_FILES)
<span style="color: #000080;">Set</span> objFolderItem = objNameSpace.Self
<span style="color: #000080;">set</span> objFolder=objFSO.GetFolder(objFolderItem.Path)
intDepth=0
RemoveFolder objFolder
&nbsp;
<span style="color: #008000;">'Clean User Temp Files
</span><span style="color: #000080;">Const</span> TemporaryFolder = 2
<span style="color: #000080;">Set</span> tempFolder = objFSO.GetSpecialFolder(TemporaryFolder)
RemoveFolder tempFolder
&nbsp;
&nbsp;
<span style="color: #000080;">sub</span> RemoveFolder(objFolder)
	<span style="color: #008000;">' Recursively remove files and folders
</span>	intDepth=intDepth+1
	<span style="color: #000080;">on</span> <span style="color: #000080;">error</span> <span style="color: #000080;">resume</span> <span style="color: #000080;">next</span>
	<span style="color: #000080;">for</span> <span style="color: #000080;">each</span> objFile <span style="color: #000080;">in</span> objFolder.Files
		objFile.Delete <span style="color: #000080;">true</span>
	<span style="color: #000080;">next</span>
	Err.Clear
	<span style="color: #000080;">on</span> <span style="color: #000080;">error</span> <span style="color: #000080;">goto</span> 0
	<span style="color: #000080;">for</span> <span style="color: #000080;">each</span> objSubfolder <span style="color: #000080;">in</span> objFolder.SubFolders
		RemoveFolder objSubFolder
	<span style="color: #000080;">next</span>
	intDepth=intDepth-1
	<span style="color: #000080;">if</span> intDepth&lt;&gt;0 <span style="color: #000080;">then</span><span style="color: #008000;">' Don't delete top-level folder
</span>		<span style="color: #000080;">on</span> <span style="color: #000080;">error</span> <span style="color: #000080;">resume</span> <span style="color: #000080;">next</span>
		objFolder.Delete <span style="color: #000080;">true</span> 
		err.Clear
		<span style="color: #000080;">on</span> <span style="color: #000080;">error</span> <span style="color: #000080;">goto</span> 0
	<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
<span style="color: #000080;">end</span> <span style="color: #000080;">sub</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/04/remove-temporary-files-at-logoff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote Shutdown / Logoff Script using WMI</title>
		<link>http://www.waynezim.com/2009/04/remote-shutdown-logoff-script-using-wmi/</link>
		<comments>http://www.waynezim.com/2009/04/remote-shutdown-logoff-script-using-wmi/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 13:21:23 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Force]]></category>
		<category><![CDATA[Logoff]]></category>
		<category><![CDATA[Restart]]></category>
		<category><![CDATA[Shutdown]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[VBscript]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=49</guid>
		<description><![CDATA[Have you ever been sitting at your desk working very hard trying to getting some business analytics report finished for your administrative team, only to be interrupted by the everyday user unable to log on the machine because someone else locked it. Then you have to get up and walk down there and manually login [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever been sitting at your desk working very hard trying to getting some business analytics report finished for your administrative team, only to be interrupted by the everyday user unable to log on the machine because someone else locked it. Then you have to get up and walk down there and manually login and unlock the workstation. Well this is now a thing of the past for you if you have enabled WMI and have a domain or common credentials on your network. This script will simply allow you to unlock a workstation with out getting up from your desk. Unfortunately, I didn&#8217;t write this script but I use it about every other day to unlock a workstation. It has a few good options to allow you to either Logoff / Reboot / Shutdown the workstation. This can also be helpful when the user has locked up the PC and can&#8217;t get it to restart, you can send a command from the workstation you are at for that one to restart. In way you end up using this script it will only save you time, I found it to be very reliable and super fast for resolving the locked computer situation. Also, please browse though the code as it is well commented and you can get a greater understanding of how it exactly works.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.waynezim.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=49&amp;download=remoteshutdown.vbs">remoteshutdown.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p494"><td class="code" id="p49code4"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'/'|| Remote Shutdown.vbs
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Created by Harvey Hendricks, MCSE, A+,
</span><span style="color: #008000;">'|| March 2001
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| email: hhendrks@aramco.com
</span><span style="color: #008000;">'|| hhend@swbell.net
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Based on techniques and ideas from:
</span><span style="color: #008000;">'|| SMS admin, SMS Installer, &amp; WMI forums -&gt; http://www.myITforum.com/forums
</span><span style="color: #008000;">'|| Win32 Scripting -&gt; http://cwashington.netreach.net/
</span><span style="color: #008000;">'|| Microsoft Windows Script Technologies -&gt; http://msdn.microsoft.com/scripting
</span><span style="color: #008000;">'|| Microsoft Online Library -&gt; http://msdn.microsoft.com/library/default.asp
</span><span style="color: #008000;">'|| Microsoft VBScript 5.5 documentation
</span><span style="color: #008000;">'|| and Microsoft WMI SDK
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color: #008000;">'|| SCRIPT LOGIC FLOW:
</span><span style="color: #008000;">'|| Collects computername from user, calls function to ping the computername
</span><span style="color: #008000;">'|| to determine if it is accessible, if not then display message and exit
</span><span style="color: #008000;">'|| otherwise continue.
</span><span style="color: #008000;">'|| Collects desired action to perform from the user, does error checking on
</span><span style="color: #008000;">'|| the input to determine if it is acceptable, if not then display message
</span><span style="color: #008000;">'|| and exit otherwise continue.
</span><span style="color: #008000;">'|| Set variables and output messages based on the action chosen. Calls
</span><span style="color: #008000;">'|| Win32Shutdown with the appropriate variable. Displays success message
</span><span style="color: #008000;">'|| and exits
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Uses WMI Win32Shutdown method from the Win32_OperatingSystem class
</span><span style="color: #008000;">'|| to perform different logoff / powerdown / reboot functions
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Testing found the following values to be effective on Win32Shutdown:
</span><span style="color: #008000;">'|| Action decimal binary
</span><span style="color: #008000;">'|| Logoff 0 0000
</span><span style="color: #008000;">'|| Force Logoff 4 0100
</span><span style="color: #008000;">'|| Reboot 2 0010
</span><span style="color: #008000;">'|| Force Reboot 6 0110
</span><span style="color: #008000;">'|| Powerdown 8 1000
</span><span style="color: #008000;">'|| Force Powerdown 12 1100
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Notice that the third bit from the right appears to be the &quot;FORCE&quot; bit.
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| A value of 1 will do a shutdown, ending at the &quot;It is safe to turn
</span><span style="color: #008000;">'|| off your computer&quot; screen. I have no use for this and did not test it.
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||NOTES: - tested under Windows 2000 Pro. with ACPI compliant systems -
</span><span style="color: #008000;">'|| SHOULD work under Windows NT4 without modification IF the
</span><span style="color: #008000;">'|| system has compatible versions of WSH / WMI / VBscripting
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||Logoff / Powerdown / Reboot:
</span><span style="color: #008000;">'|| Does not work if a password protected screen saver is active or
</span><span style="color: #008000;">'|| there is data to save. Either way the system waits for user input.
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||Force Logoff / Force Powerdown / Force Reboot:
</span><span style="color: #008000;">'|| Does not work if a password protected screen saver is active, will wait
</span><span style="color: #008000;">'|| for user input. Otherwise will close open applications without saving data.
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'\/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span>
&nbsp;
<span style="color: #008000;">'/\/\/\/\/\/\/\/\/\/\/\/\/\/\ start function /\/\/\/\/\/\/\/\/\/\/\/\/\/'\/\/\/\/\/\/\/\/\/\/\/\/\/\/\______________/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
</span><span style="color: #000080;">function</span> Ping(<span style="color: #000080;">byval</span> strName)
<span style="color: #000080;">dim</span> objFSO, objShell, objTempFile, objTS
<span style="color: #000080;">dim</span> sCommand, sReadLine
<span style="color: #000080;">dim</span> bReturn
&nbsp;
<span style="color: #000080;">set</span> objShell = WScript.CreateObject(<span style="color: #800000;">&quot;Wscript.Shell&quot;</span>)
<span style="color: #000080;">set</span> objFSO = CreateObject(<span style="color: #800000;">&quot;Scripting.FileSystemObject&quot;</span>)
&nbsp;
<span style="color: #008000;">'Set default return value
</span>bReturn = <span style="color: #000080;">false</span>
&nbsp;
<span style="color: #008000;">'Create command line to ping and save results to a temp file
</span>sCommand = <span style="color: #800000;">&quot;cmd /c ping.exe -n 3 -w 1000 &quot;</span> &amp; strName &amp; <span style="color: #800000;">&quot; &gt; temp.txt&quot;</span>
&nbsp;
<span style="color: #008000;">'Execute the command
</span>objShell.run sCommand, 0, <span style="color: #000080;">true</span>
&nbsp;
<span style="color: #008000;">'Get the temp file
</span><span style="color: #000080;">set</span> objTempFile = objFSO.GetFile(<span style="color: #800000;">&quot;temp.txt&quot;</span>)
<span style="color: #000080;">set</span> objTS = objTempFile.OpenAsTextStream(1)
&nbsp;
<span style="color: #008000;">'Loop through the temp file to see if &quot;reply from&quot; is found,
</span><span style="color: #008000;">'if it is then the ping was successful
</span><span style="color: #000080;">do</span> <span style="color: #000080;">while</span> objTs.AtEndOfStream &lt;&gt; <span style="color: #000080;">true</span>
sReadLine = objTs.ReadLine
<span style="color: #000080;">if</span> instr(lcase(sReadLine), <span style="color: #800000;">&quot;reply from&quot;</span>) &gt; 0 <span style="color: #000080;">then</span>
bReturn = <span style="color: #000080;">true</span>
<span style="color: #000080;">exit</span> <span style="color: #000080;">do</span>
<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
<span style="color: #000080;">loop</span>
&nbsp;
<span style="color: #008000;">'Close temp file and release objects
</span>objTS.<span style="color: #000080;">close</span>
objTempFile.delete
<span style="color: #000080;">set</span> objTS = <span style="color: #000080;">nothing</span>
<span style="color: #000080;">set</span> objTempFile = <span style="color: #000080;">nothing</span>
<span style="color: #000080;">set</span> objShell = <span style="color: #000080;">nothing</span>
<span style="color: #000080;">set</span> objFSO = <span style="color: #000080;">nothing</span>
&nbsp;
<span style="color: #008000;">'Return value
</span>Ping = bReturn
<span style="color: #000080;">end</span> <span style="color: #000080;">function</span>
<span style="color: #008000;">'/\/\/\/\/\/\/\/\/\/\/\/\/\/\ end function /\/\/\/\/\/\/\/\/\/\/\/\/\/'\/\/\/\/\/\/\/\/\/\/\/\/\/\/\______________/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
</span>
&nbsp;
&nbsp;
<span style="color: #008000;">'/\/\/\/\/\/\/\/\/\/\/\ Start Main body of script /\/\/\/\/\/\/\/\/\/\/\/'\/\/\/\/\/\/\/\/\/\/\/\_________________________/\/\/\/\/\/\/\/\/\/\/\/\/
</span><span style="color: #008000;">'Get computer name to operate on
</span>ComputerName=InputBox(<span style="color: #800000;">&quot;Enter the Machine name of the computer&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot;you wish to Shutdown / Reboot / Logoff&quot;</span>, _
<span style="color: #800000;">&quot;Remote Shutdown / Reboot / Logoff&quot;</span>, _
<span style="color: #800000;">&quot;ComputerName&quot;</span>)
&nbsp;
<span style="color: #008000;">'if Cancel selected - exit
</span><span style="color: #000080;">If</span> (ComputerName = <span style="color: #800000;">&quot;&quot;</span>) <span style="color: #000080;">Then</span> Wscript.Quit
&nbsp;
<span style="color: #008000;">'change the name to uppercase
</span>ComputerName=UCase(ComputerName)
&nbsp;
<span style="color: #008000;">'ping the computername to see if it is accessible
</span>bPingtest = ping(Computername)
&nbsp;
<span style="color: #000080;">If</span> bPingtest = <span style="color: #000080;">FALSE</span> <span style="color: #000080;">Then</span>
y = msgbox (<span style="color: #800000;">&quot;'&quot;</span> &amp; ComputerName &amp; <span style="color: #800000;">&quot;' is not accessible!&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot;It may be offline or turned off.&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot;Check the name for a typo.&quot;</span> &amp; vbCRLF, _
vbCritical, ComputerName &amp; <span style="color: #800000;">&quot; NOT RESPONDING&quot;</span>)
Wscript.Quit
<span style="color: #000080;">end</span> <span style="color: #000080;">IF</span>
&nbsp;
<span style="color: #008000;">'Get the action desired
</span>Action=InputBox( _
<span style="color: #800000;">&quot;Select Action to perform on &quot;</span> &amp; ComputerName &amp; vbCRLF &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 1 - Logoff&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 2 - Force Logoff ( NO SAVE )&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 3 - Powerdown&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 4 - Force Powerdown ( NO SAVE )&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 5 - Reboot&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 6 - Force Reboot ( NO SAVE )&quot;</span> &amp; vbCRLF &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot;NOTE:&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; Using Force will close windows&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; without saving changes!&quot;</span>, _
<span style="color: #800000;">&quot;Select action to perform on &quot;</span> &amp; ComputerName, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
<span style="color: #008000;">'if Cancel selected - exit
</span><span style="color: #000080;">If</span> (Action = <span style="color: #800000;">&quot;&quot;</span>) <span style="color: #000080;">Then</span> Wscript.Quit
&nbsp;
<span style="color: #008000;">'error check input
</span><span style="color: #000080;">If</span> (INSTR(<span style="color: #800000;">&quot;1234567&quot;</span>,Action)=0) <span style="color: #000080;">OR</span> (Len(Action)&gt;1) <span style="color: #000080;">then</span>
y = msgbox(<span style="color: #800000;">&quot;Unacceptable input passed -- '&quot;</span> &amp; Action &amp; <span style="color: #800000;">&quot;'&quot;</span>, _
vbOKOnly + vbCritical, <span style="color: #800000;">&quot;That was SOME bad input!&quot;</span>)
Wscript.Quit
<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
&nbsp;
<span style="color: #008000;">' set flag to disallow action unless proper input is achieved, 1 =&gt; go 0 =&gt; nogo
</span>flag = 0
&nbsp;
<span style="color: #008000;">'set variables according to computername and action
</span><span style="color: #000080;">Select</span> <span style="color: #000080;">Case</span> Action
<span style="color: #000080;">Case</span> 1 <span style="color: #008000;">'Logoff
</span>x = 0
strAction = <span style="color: #800000;">&quot;Logoff sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 2 <span style="color: #008000;">'Force Logoff
</span>x = 4
strAction = <span style="color: #800000;">&quot;Force Logoff sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 3 <span style="color: #008000;">'Powerdown
</span>x = 8
strAction = <span style="color: #800000;">&quot;Powerdown sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 4 <span style="color: #008000;">'Force Powerdown
</span>x = 12
strAction = <span style="color: #800000;">&quot;Force Powerdown sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 5 <span style="color: #008000;">'Reboot
</span>x = 2
strAction = <span style="color: #800000;">&quot;Reboot sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 6 <span style="color: #008000;">'Force Reboot
</span>x = 6
strAction = <span style="color: #800000;">&quot;Force Reboot sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 7 <span style="color: #008000;">'Test dialog boxes
</span>y = msgbox(<span style="color: #800000;">&quot;Test complete&quot;</span>, vbOKOnly + vbInformation, <span style="color: #800000;">&quot;Dialog Box Test Complete&quot;</span>)
flag = 0
<span style="color: #000080;">Case</span> <span style="color: #000080;">Else</span> <span style="color: #008000;">'Default -- should never happen
</span>y = msgbox(<span style="color: #800000;">&quot;Error occurred in passing parameters.&quot;</span> _
&amp; vbCRLF &amp; <span style="color: #800000;">&quot; Passed '&quot;</span> &amp; Action &amp; <span style="color: #800000;">&quot;'&quot;</span>, _
vbOKOnly + vbCritical, <span style="color: #800000;">&quot;PARAMETER ERROR&quot;</span>)
flag = 0
<span style="color: #000080;">End</span> <span style="color: #000080;">Select</span>
&nbsp;
<span style="color: #008000;">'check flag
</span><span style="color: #008000;">' if equal 1 (TRUE) then perform Win32Shutdown action on remote PC
</span><span style="color: #008000;">' and display a confirmation message
</span><span style="color: #008000;">' if not equal 1 (FALSE) then skip the action and script ends
</span><span style="color: #000080;">if</span> flag <span style="color: #000080;">then</span>
<span style="color: #000080;">Set</span> OpSysSet=GetObject(<span style="color: #800000;">&quot;winmgmts:{(Debug,RemoteShutdown)}//&quot;</span> _
&amp; ComputerName &amp; <span style="color: #800000;">&quot;/root/cimv2&quot;</span>).ExecQuery( _
<span style="color: #800000;">&quot;Select * from Win32_OperatingSystem where Primary=true&quot;</span>)
<span style="color: #000080;">for</span> <span style="color: #000080;">each</span> OpSys <span style="color: #000080;">in</span> OpSysSet
OpSys.Win32Shutdown(x)
y = msgbox(strAction,vbOKOnly + vbInformation,<span style="color: #800000;">&quot;Mission Accomplished&quot;</span>)
<span style="color: #000080;">next</span>
<span style="color: #000080;">end</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #008000;">'Release objects
</span><span style="color: #000080;">set</span> OpSys = <span style="color: #000080;">nothing</span>
<span style="color: #000080;">set</span> OpSysSet = <span style="color: #000080;">nothing</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/04/remote-shutdown-logoff-script-using-wmi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove Old Windows Updates Automatically using Logoff Script</title>
		<link>http://www.waynezim.com/2009/03/remove-old-windows-updates-automatically/</link>
		<comments>http://www.waynezim.com/2009/03/remove-old-windows-updates-automatically/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 02:54:08 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[Logoff]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[VBscript]]></category>
		<category><![CDATA[Windows Updates]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=3</guid>
		<description><![CDATA[This is a great script that helps you keep those patched boxes on your network running longer and faster. This script checks to see how old the Microsoft Windows Update Uninstall folders are and deletes them based on a parameter in the script. This reduces clutter on your PC and reduces one of the major [...]]]></description>
			<content:encoded><![CDATA[<p>This is a great script that helps you keep those patched boxes on your network running longer and faster. This script checks to see how old the Microsoft Windows Update Uninstall folders are and deletes them based on a parameter in the script. This reduces clutter on your PC and reduces one of the major disk hogs in a corporate environment. This script should be included in the Computers Group Policy so it has Administrative access to the PC so it can actually remove the files.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.waynezim.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=3&amp;download=cleanwu.vbs">cleanwu.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p36"><td class="code" id="p3code6"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Set</span> oShell = CreateObject(<span style="color: #800000;">&quot;Wscript.Shell&quot;</span>)
strWindows = oShell.ExpandEnvironmentStrings(<span style="color: #800000;">&quot;%WINDIR%&quot;</span>)
&nbsp;
<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span>
<span style="color: #000080;">Set</span> fsoFolder = CreateObject(<span style="color: #800000;">&quot;Scripting.FileSystemObject&quot;</span>)
&nbsp;
<span style="color: #000080;">Set</span> objFolder = fsoFolder.GetFolder(strWindows)
<span style="color: #000080;">Set</span> colSubfolders = objFolder.Subfolders
&nbsp;
<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> objSubfolder <span style="color: #000080;">in</span> colSubfolders
	<span style="color: #000080;">If</span> (DateDiff(<span style="color: #800000;">&quot;D&quot;</span>, objSubfolder.DateCreated, <span style="color: #000080;">Date</span>()) &gt; 90) <span style="color: #000080;">AND</span> ((Left(objSubfolder.Name,3)) = <span style="color: #800000;">&quot;$Nt&quot;</span>) <span style="color: #000080;">then</span>
		fsoFolder.DeleteFolder strWindows &amp; <span style="color: #800000;">&quot;\&quot;</span> &amp; objSubfolder.Name, <span style="color: #000080;">TRUE</span>
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">Next</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/03/remove-old-windows-updates-automatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

