<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5747639431463092648</id><updated>2012-01-02T05:51:15.551-08:00</updated><category term='shares'/><category term='scriptcontrol'/><category term='jscript'/><category term='active directory'/><category term='user accounts'/><category term='installation'/><category term='web'/><category term='apple'/><category term='registry'/><category term='textpad'/><category term='editorial'/><category term='adsi'/><category term='diagnostics'/><category term='functions'/><category term='ado'/><category term='sysinternals'/><category term='processes'/><category term='group policy'/><category term='ldap'/><category term='powershell'/><category term='thoughts'/><category term='shortcuts'/><category term='bat'/><category term='forms'/><category term='email'/><category term='windows'/><category term='trigonometry'/><category term='vbscript'/><category term='strings'/><category term='cmd'/><category term='adox'/><category term='uninstall'/><category term='database'/><category term='reporting'/><category term='asp'/><category term='xml'/><category term='math'/><category term='business'/><category term='select'/><category term='php'/><category term='arrays'/><category term='vmware'/><category term='security'/><category term='remote'/><category term='sorting'/><category term='formatting'/><category term='files'/><category term='COM'/><category term='lisp'/><category term='inventory'/><category term='monitoring'/><category term='mapping'/><category term='listbox'/><category term='networking'/><category term='desktop'/><category term='sql'/><category term='fso'/><category term='html'/><category term='twitter'/><category term='event logs'/><category term='kixtart'/><category term='dates'/><category term='search'/><category term='windows7'/><category term='wmi'/><category term='printers'/><category term='google'/><category term='scheduling'/><title type='text'>ScriptZilla</title><subtitle type='html'>Because you really have nothing better to do than this.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>92</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6807602082776331932</id><published>2011-10-20T08:43:00.000-07:00</published><updated>2011-10-20T08:43:56.302-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='ado'/><category scheme='http://www.blogger.com/atom/ns#' term='COM'/><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><category scheme='http://www.blogger.com/atom/ns#' term='reporting'/><category scheme='http://www.blogger.com/atom/ns#' term='inventory'/><title type='text'>Query Installed Apps a Different Way</title><content type='html'>For whatever reason, in some environments, a WMI query of Win32_Product is God-awful slow. &amp;nbsp;I've seen this on Windows 7 and Windows 7 SP1 clients, as well as on Windows Server 2008 and 2008 R2. &amp;nbsp;The symptom can be seen from WIM script, WBEM, and using WMIC from a command console with very similar results: &amp;nbsp;The query hangs for 20-25 seconds and then begins executing in spurts. &amp;nbsp;Other Win32 classes work fine, from what I've seen, it's just Win32_Product for some reason. &amp;nbsp;One workaround is to dump a registry output file, and scrub it to make a "clean" output file. &amp;nbsp;You can port this to PowerShell or KiXtart if you want (or whatever you prefer, I really don't care as long as you're happy and that makes me happy so we're all happy. yay!)&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;'****************************************************************&lt;br /&gt;' Filename..: installedApps.vbs&lt;br /&gt;' Author....: David M. Stein aka Scriptzilla aka dipshit&lt;br /&gt;' Date......: 10/20/2011&lt;br /&gt;' Purpose...: save query of installed applications to local file&lt;br /&gt;'****************************************************************&lt;br /&gt;&lt;br /&gt;Const strInputFile  = "c:\regoutput.txt"&lt;br /&gt;Const strOutputFile = "c:\installedApps.txt"&lt;br /&gt;&lt;br /&gt;Const ForReading = 1&lt;br /&gt;Const ForWriting = 2&lt;br /&gt;Const adVarChar = 200&lt;br /&gt;&lt;br /&gt;cmd = "reg query hklm\software\microsoft\windows\currentversion\uninstall /s &amp;gt;" &amp;amp; strInputFile&lt;br /&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;&lt;br /&gt;Set objShell = CreateObject("Wscript.Shell")&lt;br /&gt;Set objFSO = CreateObject("Scripting.FileSystemObject")&lt;br /&gt;&lt;br /&gt;wscript.echo "info: executing shell command to create temp file..."&lt;br /&gt;&lt;br /&gt;objShell.Run "cmd /c " &amp;amp; cmd, 7, True&lt;br /&gt;&lt;br /&gt;wscript.echo "info: getting temp file for input..."&lt;br /&gt;&lt;br /&gt;If objFSO.FileExists(strInputFile) Then&lt;br /&gt; wscript.echo "info: reading temp file..."&lt;br /&gt; Set objFile = objFSO.OpenTextFile(strInputFile, ForReading)&lt;br /&gt; Set objFile2 = objFSO.CreateTextFile(strOutputFile, True)&lt;br /&gt;&lt;br /&gt; Set rs = CreateObject("ADODB.RecordSet")&lt;br /&gt;&lt;br /&gt; rs.CursorLocation = adUseClient&lt;br /&gt; rs.Fields.Append "productname", adVarChar, 255&lt;br /&gt; rs.Open&lt;br /&gt;&lt;br /&gt; Do Until objFile.AtEndOfStream&lt;br /&gt;     strLine = objFile.Readline&lt;br /&gt;     If Left(strLine, 25) = "    DisplayName    REG_SZ" Then&lt;br /&gt;      strOutput = Trim(Mid(strLine, 30))&lt;br /&gt;   rs.AddNew&lt;br /&gt;   rs.Fields("productname").value = strOutput&lt;br /&gt;   rs.Update&lt;br /&gt;     End If&lt;br /&gt; Loop&lt;br /&gt; &lt;br /&gt; rs.Sort = "productname"&lt;br /&gt; &lt;br /&gt; Do Until rs.EOF&lt;br /&gt;     objFile2.WriteLine(rs.Fields("productname").value)&lt;br /&gt;  rs.MoveNext&lt;br /&gt; Loop&lt;br /&gt; rs.CLose&lt;br /&gt; Set rs = Nothing&lt;br /&gt; &lt;br /&gt; objFile.Close&lt;br /&gt; objFile2.Close&lt;br /&gt; wscript.echo "info: finished scrubbing input to new output file"&lt;br /&gt;Else&lt;br /&gt; wscript.echo "fail: temp file not found"&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set objFSO = Nothing&lt;br /&gt;Set objShell = Nothing&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;wscript.echo "info: processing complete!"&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6807602082776331932?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6807602082776331932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2011/10/query-installed-apps-different-way.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6807602082776331932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6807602082776331932'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2011/10/query-installed-apps-different-way.html' title='Query Installed Apps a Different Way'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5739296760204045155</id><published>2011-05-13T13:46:00.001-07:00</published><updated>2011-05-13T13:46:53.592-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='functions'/><title type='text'>Two Ways to Do String Matching in VBscript</title><content type='html'>&lt;p&gt;The ugly but easier way (using InStr function)&lt;/p&gt;  &lt;pre&gt;Const strValue = &amp;quot;Microsoft Windows 7 Enterprise Edition&amp;quot;&lt;br /&gt;If InStr(strValue, &amp;quot;Windows 7&amp;quot;) &amp;gt; 0 Or InStr(strValue, &amp;quot;Windows XP&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;    wscript.echo &amp;quot;match found&amp;quot;&lt;br /&gt;End If&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The fancier but more irritating way (using the REGEX object):&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;Function MatchString(strToSearch, strPattern)&lt;br /&gt;    Dim objRegEx, colMatches, matchFound&lt;br /&gt;    Set objRegEx = CreateObject(&amp;quot;VBScript.RegExp&amp;quot;)&lt;br /&gt;    objRegEx.Global = True&lt;br /&gt;    objRegEx.Pattern = strPattern&lt;br /&gt;    Set colMatches = objRegEx.Execute(strToSearch)&lt;br /&gt;    If colMatches.Count &amp;gt; 0 Then&lt;br /&gt;        matchFound = True&lt;br /&gt;    End If&lt;br /&gt;    Set objRegEx = Nothing&lt;br /&gt;    MatchString = matchFound&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;If MatchString(strValue, &amp;quot;Windows XP|Windows 7&amp;quot;) Then&lt;br /&gt;    wscript.echo &amp;quot;match found&amp;quot;&lt;br /&gt;End If&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5739296760204045155?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5739296760204045155/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2011/05/two-ways-to-do-string-matching-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5739296760204045155'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5739296760204045155'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2011/05/two-ways-to-do-string-matching-in.html' title='Two Ways to Do String Matching in VBscript'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-893453002992913863</id><published>2011-02-15T06:04:00.000-08:00</published><updated>2011-07-30T19:47:45.471-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bat'/><category scheme='http://www.blogger.com/atom/ns#' term='installation'/><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><title type='text'>Template CMD Script for App Installs</title><content type='html'>&lt;p&gt;This is obviously bare-bones and will need to be modified to suit specific implementations.&amp;#160; There are dozens of ways to execute a software installation, including setup.exe files, extracting ZIP and other archive files, registering DLLs with REGSVR32, and the ugly-ass, vice-grip + screwdriver + duct tape approach where you manually build folder trees, copy files, register DLLs, add and modify registry keys and make or replace shortcuts.&amp;#160; Oh, the torture.&lt;/p&gt;  &lt;p&gt;EDIT: Updated 7/30/2011 to include errorlevel 3010 (reboot pending)   &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;@echo off&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem ****************************************************************&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem&amp;#160; Filename..: setup.cmd&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem&amp;#160; Author....: David M. Stein&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem&amp;#160; Date......: &lt;span style="color: red" class="Apple-style-span"&gt;07/30/2011&lt;/span&gt;&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem&amp;#160; Purpose...: install apps in controlled sequence&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem ****************************************************************&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem Additional Notes:&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem &lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem ****************************************************************&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;title Installing Applications&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;CLS&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo Installing Applications...&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;SETLOCAL&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;set APPNAME=&lt;span style="color: red" class="Apple-style-span"&gt;MyApplicationSuite2011&lt;/span&gt;&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;set LOG=%TMP%\%APPNAME%_install.log&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;set MSI=/quiet /norestart&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% installing... %APPNAME%... &amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% source....... %~dps0 &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% target....... %COMPUTERNAME% &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% windir....... %WINDIR% &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% progfiles.... %PROGRAMFILES% &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% temp......... %TMP% &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo INSTALL LOG: %LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo ----------------------------------------------- &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo *** &lt;span style="color: red" class="Apple-style-span"&gt;APPLICATION NAME 1&lt;/span&gt; &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% info: checking if application is already installed... &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;if exist &lt;span style="color: red" class="Apple-style-span"&gt;&amp;quot;%ProgramFiles%\FolderName\filename.exe&amp;quot;&lt;/span&gt; (&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&lt;span style="white-space: pre" class="Apple-tab-span"&gt; &lt;/span&gt;echo %DATE% %TIME% info: ## application is already installed &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;) else (&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&lt;span style="white-space: pre" class="Apple-tab-span"&gt; &lt;/span&gt;echo %DATE% %TIME% info: ## installing application... &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&lt;span style="white-space: pre" class="Apple-tab-span"&gt; &lt;/span&gt;echo %DATE% %TIME% command = &lt;span style="color: red" class="Apple-style-span"&gt;msiexec /i &amp;quot;%~dps0Folder\filename.msi&amp;quot; TRANSFORMS=&amp;quot;%~dps0Folder\filename.MST&amp;quot;&lt;/span&gt; &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&lt;span style="color: red" class="Apple-style-span"&gt;&amp;#160;&amp;#160; msiexec /i &amp;quot;%~dps0Folder\filename.msi&amp;quot; TRANSFORMS=&amp;quot;%~dps0Folder\filename.MST&amp;quot;&lt;/span&gt; %MSI%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&amp;#160;&amp;#160; if %errorlevel%==0 (&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; echo %DATE% %TIME% info: installation SUCCESSFUL &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&amp;#160;&amp;#160; ) else (     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if %errorlevel%==3010 (      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; echo %DATE% %TIME% info: installation SUCCESSFUL [reboot pending] &amp;gt;&amp;gt;%LOG%      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ) else (      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; echo %DATE% %TIME% file: exit code is %errorlevel% &amp;gt;&amp;gt;%LOG%&lt;font size="2"&gt;       &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; rem Raise error to parent process!!&lt;/span&gt;        &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&lt;span style="white-space: pre" class="Apple-tab-span"&gt;&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; exit %errorlevel%          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; )&lt;/span&gt;&lt;/font&gt;      &lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;&amp;#160;&amp;#160; )&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;)&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem ------------------------------------------------&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem echo *** APPLICATION NAME 2 &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem ------------------------------------------------&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem repeat code above with modifications as needed&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem ------------------------------------------------&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% info: adjusting application folder permissions... &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; color: red; font-size: x-small" class="Apple-style-span"&gt;cacls &amp;quot;%ProgramFiles%\FolderName&amp;quot; /T /E /C /G Users:C&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo ----------------------------------------------- &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% info: applying attachmate file association fix... &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; color: red; font-size: x-small" class="Apple-style-span"&gt;REG DEL HKCR\.xxx /f&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; color: red; font-size: x-small" class="Apple-style-span"&gt;REG ADD HKCR\.xxx /ve /d &amp;quot;ApplicationClass.ProgName.1&amp;quot; /f&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo ----------------------------------------------- &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% info: adjusting registry permissions... &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; color: red; font-size: x-small" class="Apple-style-span"&gt;REGINI.exe %~dps0customregsettings.ini&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo ----------------------------------------------- &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;echo %DATE% %TIME% completed! result code: %errorlevel% &amp;gt;&amp;gt;%LOG%&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;ENDLOCAL&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;rem Raise error to parent process!!&lt;/span&gt;    &lt;br /&gt;&lt;span style="font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; font-size: x-small" class="Apple-style-span"&gt;exit %errorlevel%&lt;/span&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;div&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-893453002992913863?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/893453002992913863/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2011/02/template-cmd-script-for-app-installs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/893453002992913863'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/893453002992913863'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2011/02/template-cmd-script-for-app-installs.html' title='Template CMD Script for App Installs'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-1969256199528970506</id><published>2011-02-15T05:49:00.000-08:00</published><updated>2011-02-15T05:49:43.850-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='search'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>Querying Files Using Windows Search with VBScript</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'****************************************************************&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' Filename..: scanFiles.vbs&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' Author....: David M. Stein aka Skatterbrainz aka Scriptzilla aka goofy&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' Contact...: ds0934 (at) gmail (dot) com&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' Date......: 02/14/2011&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' Purpose...: generate file scan report using Windows Search queries&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'****************************************************************&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' COPYRIGHT (C) 2011 David M. Stein - All Rights Reserved.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' No portion of this software code may be reproduced, shared,&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' transmitted, by any means, electronic or otherwise, for any&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' purposes whatsoever, without the explicit prior written consent&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' of the author. &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'****************************************************************&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' DESCRIPTION&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' This script invokes the built-in Windows Desktop Search service&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' to query the local index for files that contain specific string&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' phrases. &amp;nbsp;The string phrases are defined in an external text&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' file which allows for customization of phrases as needed.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' The output is echoed to the display screen unless redirected&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' to a log file. &amp;nbsp;The associated .cmd file does just that. It is&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' used to execute this script, and redirect the output to a log&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' file which is saved to a central folder (network server share)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'****************************************************************&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Option Explicit&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Const verbose = False&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'----------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' comment: DO NOT CHANGE ANY CODE BELOW THIS POINT !!!&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' comment: ...or ye shall perish in the land of stupidity&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'----------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "info: script initialized " &amp;amp; Now&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Const ForReading = 1&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Const ForWriting = 2&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Dim objConnection, objRecordset, query, scriptPath, inputFile&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Dim objFSO, objFile, strLine, searchList, itemCount : itemCount = 0&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Dim filePath, phrase&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Set objFSO = CreateObject("Scripting.FileSystemObject")&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' comment: determine self-referential path location&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;scriptPath = Replace(wscript.ScriptFullName, "\" &amp;amp; wscript.ScriptName, "")&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;inputFile = "searchlist.txt"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' comment: determine input search list file location&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;filePath = scriptPath &amp;amp; "\" &amp;amp; inputFile&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;On Error Resume Next&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "info: searching for searchlist.txt input file..."&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;If objFSO.FileExists(filePath) Then&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;echo "info: reading search values..."&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Set objFile = objFSO.OpenTextFile(filePath, ForReading)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Do Until objFile.AtEndOfStream&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;strLine = objFile.Readline&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If Left(strLine,1) &amp;lt;&amp;gt; ";" Then&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;If searchList &amp;lt;&amp;gt; "" Then&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;searchList = searchList &amp;amp; vbTab &amp;amp; strLine&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Else&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;searchList = strLine&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;End If&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;itemCount = itemCount + 1&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;End If&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Loop&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;objFile.Close&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;End If&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "info: " &amp;amp; itemCount &amp;amp; " phrases were queued"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'----------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "info: initializing window search interface..."&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Set objConnection = CreateObject("ADODB.Connection")&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "info: opening windows search data connection..."&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;objConnection.Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;If err.Number &amp;lt;&amp;gt; 0 Then&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;echo "fail: connection-open failure [" &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;err.Number &amp;amp; ":" &amp;amp; err.Description &amp;amp; "]"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;wscript.quit(2)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;End If&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "info: beginning windows search scan process..."&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;For each phrase in Split(searchList, vbTab)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;wscript.echo "PHRASE: " &amp;amp; phrase&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;' comment: define search query expression to identify matching files&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;query = "SELECT System.FileName, System.ItemPathDisplay, " &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;"System.DateCreated, System.DateModified " &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;"FROM SYSTEMINDEX WHERE Contains(System.FileName, '" &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Chr(34) &amp;amp; phrase &amp;amp; Chr(34) &amp;amp; "')" &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;" OR Contains('" &amp;amp; Chr(34) &amp;amp; phrase &amp;amp; Chr(34) &amp;amp; "')"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;' comment: open connection to service and submit query request&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Set objRecordSet &amp;nbsp;= CreateObject("ADODB.Recordset")&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;objRecordSet.Open query, objConnection&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If err.Number &amp;lt;&amp;gt; 0 Then&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "fail: recordset-open failure [" &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;err.Number &amp;amp; ":" &amp;amp; err.Description &amp;amp; "]"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;objConnection.Close&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Set objConnection = Nothing&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;wscript&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;.quit(3)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;' comment: if results are not empty, iterate the dataset rows&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If Not (objRecordset.BOF and objRecordset.EOF) Then&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;objRecordSet.MoveFirst&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "info: iterating recordset results..."&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Do Until objRecordset.EOF&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;wscript.echo "MATCH: " &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;objRecordset.Fields.Item("System.ItemPathDisplay").value &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;vbTab &amp;amp; objRecordset.Fields.Item("System.DateCreated").value &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;vbTab &amp;amp; objRecordset.Fields.Item("System.DateModified").value&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;objRecordset.MoveNext&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Loop&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;wscript.echo&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Else&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "info: no matching records were found"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;objRecordset.Close&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Set objRecordset = Nothing&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' comment: close connection to service&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;objConnection.Close&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Set objConnection = Nothing&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;echo "info: processing completed " &amp;amp; Now&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'----------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;' function: verbose printing&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;'----------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;Sub Echo(s)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If verbose = True Then&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;wscript.echo s&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;End If&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;End Sub&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;EXAMPLE of searchlist.txt&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;; disable lines by inserting a semi-colon in front of them&lt;/div&gt;&lt;div&gt;This is a phrase to search for&lt;/div&gt;&lt;div&gt;this is another phrase&lt;/div&gt;&lt;div&gt;phrases are case insensitive&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-1969256199528970506?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/1969256199528970506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2011/02/querying-files-using-windows-search.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1969256199528970506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1969256199528970506'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2011/02/querying-files-using-windows-search.html' title='Querying Files Using Windows Search with VBScript'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-1328874646575340415</id><published>2011-01-26T11:48:00.001-08:00</published><updated>2011-02-28T12:45:06.945-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><title type='text'>Recursively Delete Files by Extension Name</title><content type='html'>&lt;pre&gt;Const strExtensionsToDelete = "wav,avi,mp3,aac,tmp,bak"&lt;br /&gt;Const testMode = True&lt;br /&gt;&lt;br /&gt;Sub RecursiveDeleteByExtension(ByVal strDirectory, strExtensionsToDelete)&lt;br /&gt;  Dim objFolder, objSubFolder, objFile&lt;br /&gt;  Dim strExt&lt;br /&gt;  Set objFolder = objFSO.GetFolder(strDirectory)&lt;br /&gt;  For Each objFile in objFolder.Files&lt;br /&gt;    For Each strExt in Split(Ucase(strExtensionsToDelete),",")&lt;br /&gt;      If Right(Ucase(objFile.Path), Len(strExt)+1) = "." &amp;amp; strExt Then&lt;br /&gt;        wscript.echo "Deleting:" &amp;amp; objFile.Path&lt;br /&gt;        If Not testMode = True Then&lt;br /&gt;          objFile.Delete&lt;br /&gt;        End If&lt;br /&gt;        'Exit For&lt;br /&gt;      End If&lt;br /&gt;    Next&lt;br /&gt;  Next &lt;br /&gt;  For Each objSubFolder in objFolder.SubFolders&lt;br /&gt;    RecursiveDeleteByExtension objSubFolder.Path, strExtensionsToDelete&lt;br /&gt;  Next&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Dim objFSO&lt;br /&gt;Set objFSO = CreateObject("Scripting.FileSystemObject")&lt;br /&gt;RecursiveDeleteByExtension "d:\downloads", strExtensionsToDelete&lt;br /&gt;wscript.echo "finished!"&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-1328874646575340415?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/1328874646575340415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2011/01/recursively-delete-files-by-extension.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1328874646575340415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1328874646575340415'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2011/01/recursively-delete-files-by-extension.html' title='Recursively Delete Files by Extension Name'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6273828658786650305</id><published>2011-01-26T11:46:00.000-08:00</published><updated>2011-01-26T11:46:16.413-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>Recursively Delete Old Files and Empty Folders</title><content type='html'>With a slight twist:  The recursion to delete empty folders ignores folders with a name that begins with a tilde "~".  You can modify the character or pattern to suit your demented whims.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;Const maxAge = 30&lt;br /&gt;Const testMode = True&lt;br /&gt;&lt;br /&gt;Sub RecursiveDeleteByAge(ByVal strDirectory, maxAge)&lt;br /&gt; Dim objFolder, objSubFolder, objFile&lt;br /&gt; Set objFolder = objFSO.GetFolder(strDirectory)&lt;br /&gt; For Each objFile in objFolder.Files&lt;br /&gt;  dlm = objFile.DateLastModified&lt;br /&gt;  If DateDiff("d", dlm, Now) &amp;gt; maxAge Then&lt;br /&gt;   wscript.echo "Deleting:" &amp;amp; objFile.Path&lt;br /&gt;   If Not testMode = True Then&lt;br /&gt;    objFile.Delete&lt;br /&gt;   End If&lt;br /&gt;   Exit For&lt;br /&gt;  End If&lt;br /&gt; Next &lt;br /&gt; For Each objSubFolder in objFolder.SubFolders&lt;br /&gt;  RecursiveDeleteByAge objSubFolder.Path, maxAge&lt;br /&gt; Next&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sub RecursiveDeleteEmptyFolders(ByVal strDirectory)&lt;br /&gt; Dim objFolder, objSubFolder&lt;br /&gt; Set objFolder = objFSO.GetFolder(strDirectory)&lt;br /&gt; &lt;br /&gt; If objFolder.Files.Count = 0 Then&lt;br /&gt;  If objFolder.SubFolders.Count = 0 Then&lt;br /&gt;   ' no sub-folders beneath this folder...&lt;br /&gt;   If Left(objFolder.Name,1) &amp;lt;&amp;gt; "~" Then&lt;br /&gt;    wscript.echo "deleting " &amp;amp; objFolder.Path&lt;br /&gt;    If Not testMode = True Then&lt;br /&gt;     objFolder.Delete&lt;br /&gt;    End If&lt;br /&gt;   End If&lt;br /&gt;  Else&lt;br /&gt;   For Each objSubFolder in objFolder.SubFolders&lt;br /&gt;    RecursiveDeleteEmptyFolders objSubFolder.Path&lt;br /&gt;   Next&lt;br /&gt;  End If&lt;br /&gt; Else&lt;br /&gt;  wscript.echo "folder is not empty"&lt;br /&gt;  For Each objSubFolder in objFolder.SubFolders&lt;br /&gt;   RecursiveDeleteEmptyFolders objSubFolder.Path&lt;br /&gt;  Next&lt;br /&gt; End If&lt;br /&gt; &lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Dim objFSO&lt;br /&gt;Set objFSO = CreateObject("Scripting.FileSystemObject")&lt;br /&gt;&lt;br /&gt;RecursiveDeleteByAge "d:\downloads", maxAge&lt;br /&gt;RecursiveDeleteEmptyFolders "d:\downloads"&lt;br /&gt;&lt;br /&gt;wscript.echo "finished!"&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6273828658786650305?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6273828658786650305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2011/01/recursively-delete-old-files-and-empty.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6273828658786650305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6273828658786650305'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2011/01/recursively-delete-old-files-and-empty.html' title='Recursively Delete Old Files and Empty Folders'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2146131300616218572</id><published>2010-12-12T04:42:00.001-08:00</published><updated>2010-12-12T04:42:14.816-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bat'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><title type='text'>Useful CMD Script Path Expansion Variables</title><content type='html'>&lt;pre&gt;&lt;br /&gt;@echo off&lt;br /&gt;rem http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true&lt;br /&gt;echo displaying various path alias values...&lt;br /&gt;echo %~nx0&lt;br /&gt;echo %comspec%&lt;br /&gt;echo %~d0&lt;br /&gt;echo %~dp0&lt;br /&gt;echo %~dps0&lt;br /&gt;echo %~dpp0&lt;br /&gt;echo %~f0&lt;br /&gt;echo --------------------------------&lt;br /&gt;echo %systemdrive%&lt;br /&gt;echo %systemroot%&lt;br /&gt;echo %windir%&lt;br /&gt;echo %programdata%&lt;br /&gt;echo %programfiles%&lt;br /&gt;echo %userprofile%&lt;br /&gt;echo %allusersprofile%&lt;br /&gt;echo %temp%&lt;br /&gt;echo %commonprogramfiles%&lt;br /&gt;echo %commonprogramfiles(x86)%&lt;br /&gt;echo %appdata%&lt;br /&gt;echo %localappdata%&lt;br /&gt;echo %public%&lt;br /&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2146131300616218572?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2146131300616218572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/12/useful-cmd-script-path-expansion.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2146131300616218572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2146131300616218572'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/12/useful-cmd-script-path-expansion.html' title='Useful CMD Script Path Expansion Variables'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4092545790348142813</id><published>2010-12-12T04:39:00.001-08:00</published><updated>2010-12-12T04:40:14.785-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='uninstall'/><category scheme='http://www.blogger.com/atom/ns#' term='installation'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><title type='text'>Uninstall: 3DS Max 2010</title><content type='html'>&lt;p&gt;CMD Script…&lt;/p&gt;  &lt;pre&gt;&lt;br /&gt;@echo off&lt;br /&gt;CLS&lt;br /&gt;SETLOCAL&lt;br /&gt;set APPNAME=3dsMax2010&lt;br /&gt;set LOG=%TMP%\%APPNAME%_uninstall.log&lt;br /&gt;set MSI=/quiet /norestart&lt;br /&gt;echo %DATE% %TIME% installing... %APPNAME%... &gt;%LOG%&lt;br /&gt;echo %DATE% %TIME% source....... %~dps0 &gt;&gt;%LOG%&lt;br /&gt;echo %DATE% %TIME% target....... %COMPUTERNAME% &gt;&gt;%LOG%&lt;br /&gt;echo %DATE% %TIME% windir....... %WINDIR% &gt;&gt;%LOG%&lt;br /&gt;echo %DATE% %TIME% progfiles.... %PROGRAMFILES% &gt;&gt;%LOG%&lt;br /&gt;echo %DATE% %TIME% temp......... %TMP% &gt;&gt;%LOG%&lt;br /&gt;echo ----------------------------------------------- &gt;&gt;%LOG%&lt;br /&gt;echo Checking if 3ds Max 2010 is installed &gt;&gt;%LOG%&lt;br /&gt;if exist "%programfiles%\Autodesk\3ds Max 2010" GoTo REMOVE&lt;br /&gt;goto NOTFOUND&lt;br /&gt;goto END&lt;br /&gt; &lt;br /&gt;:NOTFOUND&lt;br /&gt;echo %DATE% %TIME% 3DS Max 2010 was not detected on this computer&lt;br /&gt;goto END&lt;br /&gt; &lt;br /&gt;:REMOVE&lt;br /&gt;echo %DATE% %TIME% removing 3ds Max 2010 32-bit &gt;&gt;%TMP%\3dsmax2010uninst.log&lt;br /&gt;echo command = msiexec.exe /x {317AC0C7-FEBF-0409-87A3-4FC70D0ED900} %MSI% &gt;&gt;%LOG%&lt;br /&gt;msiexec.exe /x {317AC0C7-FEBF-0409-87A3-4FC70D0ED900} %MSI%&lt;br /&gt;rem ------------------------------------------------------&lt;br /&gt;echo %DATE% %TIME% removing 3ds Max 2010 32-bit Components &gt;&gt;%TMP%\3dsmax2010uninst.log&lt;br /&gt;echo command = msiexec.exe /x {60A08432-00DD-0409-AC2C-143C75460878} %MSI% &gt;&gt;%LOG%&lt;br /&gt;msiexec.exe /x {60A08432-00DD-0409-AC2C-143C75460878} %MSI%&lt;br /&gt;rem ------------------------------------------------------&lt;br /&gt;echo %DATE% %TIME% removing Backburner 2008.01 &gt;&gt;%TMP%\3dsmax2010uninst.log&lt;br /&gt;echo command = msiexec.exe /x {3D347E6D-5A03-4342-B5BA-6A771885F379} %MSI% &gt;&gt;%LOG%&lt;br /&gt;msiexec.exe /x {3D347E6D-5A03-4342-B5BA-6A771885F379} %MSI%&lt;br /&gt;rem ------------------------------------------------------&lt;br /&gt;echo %DATE% %TIME% removing Tutorials Files &gt;&gt;%TMP%\3dsmax2010uninst.log&lt;br /&gt;echo command = msiexec.exe /x {E551D82D-4D56-4AF7-A2C9-8897D7A0CB00} %MSI% &gt;&gt;%LOG%&lt;br /&gt;msiexec.exe /x {E551D82D-4D56-4AF7-A2C9-8897D7A0CB00} %MSI%&lt;br /&gt;rem ------------------------------------------------------&lt;br /&gt;echo %DATE% %TIME% removing FBX Plugin 2009.4 - 3ds Max 2010 &gt;&gt;%TMP%\3dsmax2010uninst.log&lt;br /&gt;c:&lt;br /&gt;cd "%programfiles%\Autodesk\"&lt;br /&gt;echo command = "FBX\FBXPlugins\2009.4\3ds Max 2010\Uninstall.exe" /S &gt;&gt;%LOG%&lt;br /&gt;"FBX\FBXPlugins\2009.4\3ds Max 2010\Uninstall.exe" /S&lt;br /&gt;goto CLEANUP&lt;br /&gt;goto END&lt;br /&gt; &lt;br /&gt;:CLEANUP&lt;br /&gt;echo %DATE% %TIME% cleaning up leftover folders and files &gt;&gt;%LOG%&lt;br /&gt;c:&lt;br /&gt;if exist "%programfiles%\Autodesk\3ds Max 2010" (&lt;br /&gt;   echo Removing 3ds Max 2010 sub-folder &gt;&gt;%LOG%&lt;br /&gt;   cd "%programfiles%\Autodesk"&lt;br /&gt;   rd "3ds Max 2010" /s /q&lt;br /&gt;)&lt;br /&gt;if exist "%programfiles%\Autodesk\FBX" (&lt;br /&gt;   echo Removing FBX sub-folder &gt;&gt;%LOG%&lt;br /&gt;   cd "%programfiles%\Autodesk"&lt;br /&gt;   rd "FBX" /s /q&lt;br /&gt;)&lt;br /&gt;rem ------------------------------------------------------&lt;br /&gt;echo %DATE% %TIME% exit code %errorlevel% &gt;&gt;%LOG%&lt;br /&gt;echo %DATE% %TIME% completed &gt;&gt;%LOG%&lt;br /&gt;goto END&lt;br /&gt; &lt;br /&gt;:END&lt;br /&gt;exit %errorlevel%&lt;br /&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4092545790348142813?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4092545790348142813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/12/uninstall-3ds-max-2010.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4092545790348142813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4092545790348142813'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/12/uninstall-3ds-max-2010.html' title='Uninstall: 3DS Max 2010'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7310058688679741367</id><published>2010-10-27T14:53:00.001-07:00</published><updated>2010-10-27T14:53:15.814-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='inventory'/><title type='text'>A WMI Search-Filter Thingy Script Thingy</title><content type='html'>I worked on this for a couple of hours. It could use a lot more work and embellishment (such as specifying the namespaces in the data file, etc.), but here goes. It reads a text file to scan the local computer for matching WMI class properties (currently only within the CIMv2 namespace). I hope it helps someone. Enjoy!   &lt;pre style="font-family: courier,verdana; color: blue; font-size: 9pt"&gt;'****************************************************************&lt;br /&gt;' Filename..: wmi_rule.vbs&lt;br /&gt;' Author....: Scriptzilla / skatterbrainz.blogspot.com&lt;br /&gt;' Date......: 10/27/2010&lt;br /&gt;' Purpose...: evaluate wmi class property value matches using data file&lt;br /&gt;'****************************************************************&lt;br /&gt; &lt;br /&gt;scriptPath = Replace(wscript.ScriptFullName, &amp;quot;\&amp;quot; &amp;amp; wscript.ScriptName, &amp;quot;&amp;quot;)&lt;br /&gt; &lt;br /&gt;ruleFile = scriptPath &amp;amp; &amp;quot;\wmi_rules.txt&amp;quot;&lt;br /&gt;Const ForReading = 1&lt;br /&gt;Const ForWriting = 2&lt;br /&gt;Set objFSO  = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;On Error Resume Next&lt;br /&gt;Set objFile = objFSO.OpenTextFile(ruleFile, ForReading)&lt;br /&gt;If err.Number = 0 Then&lt;br /&gt;    Do Until objFile.AtEndOfStream&lt;br /&gt;        strLine = Trim(objFile.Readline)&lt;br /&gt;        If strLine &amp;lt;&amp;gt; &amp;quot;&amp;quot; And Left(strLine,1) &amp;lt;&amp;gt; &amp;quot;'&amp;quot; And Left(strLine,1) &amp;lt;&amp;gt; &amp;quot;;&amp;quot; Then&lt;br /&gt;            arrRule = Split(strLine, &amp;quot;,&amp;quot;)&lt;br /&gt;            For each item in arrRule&lt;br /&gt;                arrPair = Split(item, &amp;quot;=&amp;quot;)&lt;br /&gt;                Select Case arrPair(0)&lt;br /&gt;                    Case &amp;quot;Class&amp;quot;: wmi_class = arrPair(1)&lt;br /&gt;                    Case &amp;quot;Property&amp;quot;: wmi_prop = arrPair(1)&lt;br /&gt;                    Case &amp;quot;Value&amp;quot;: wmi_val = arrPair(1)&lt;br /&gt;                    Case &amp;quot;MatchType&amp;quot;: wmi_match = arrPair(1)&lt;br /&gt;                End Select&lt;br /&gt;            Next&lt;br /&gt; &lt;br /&gt;            If WMIRule(wmi_class, wmi_prop, wmi_val, wmi_match) = True Then&lt;br /&gt;                wscript.echo &amp;quot;class....... &amp;quot; &amp;amp; wmi_class&lt;br /&gt;                wscript.echo &amp;quot;property.... &amp;quot; &amp;amp; wmi_prop&lt;br /&gt;                wscript.echo &amp;quot;value....... &amp;quot; &amp;amp; wmi_val&lt;br /&gt;                wscript.echo &amp;quot;matchtype... &amp;quot; &amp;amp; wmi_match&lt;br /&gt;                wscript.echo &amp;quot;result ----&amp;gt; TRUE&amp;quot;&lt;br /&gt;                wscript.echo&lt;br /&gt;            Else&lt;br /&gt;                wscript.echo &amp;quot;class....... &amp;quot; &amp;amp; wmi_class&lt;br /&gt;                wscript.echo &amp;quot;property.... &amp;quot; &amp;amp; wmi_prop&lt;br /&gt;                wscript.echo &amp;quot;value....... &amp;quot; &amp;amp; wmi_val&lt;br /&gt;                wscript.echo &amp;quot;matchtype... &amp;quot; &amp;amp; wmi_match&lt;br /&gt;                wscript.echo &amp;quot;result ----&amp;gt; FALSE&amp;quot;&lt;br /&gt;                wscript.echo&lt;br /&gt;            End If&lt;br /&gt;        End If&lt;br /&gt;    Loop&lt;br /&gt;    objFile.Close&lt;br /&gt;Else&lt;br /&gt;    wscript.echo &amp;quot;fail: unable to open rule file for input&amp;quot;&lt;br /&gt;End If&lt;br /&gt;Set objFSO = Nothing&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt; &lt;br /&gt;Function WMIRule(w_class, w_prop, w_val, w_match)&lt;br /&gt;    Dim objClass, objProp, strName, strValue, retval&lt;br /&gt;    Dim objWMIService, wmiQuery, colItems, objItem&lt;br /&gt;               &lt;br /&gt;    strComputer = &amp;quot;.&amp;quot;&lt;br /&gt;    Set objWMIService = objWMI(strComputer, &amp;quot;classes&amp;quot;)&lt;br /&gt;               &lt;br /&gt;    wmiQuery = &amp;quot;select * from &amp;quot; &amp;amp; w_class&lt;br /&gt;               &lt;br /&gt;    Set colItems = objWMI(strComputer, wmiQuery)&lt;br /&gt;               &lt;br /&gt;    For each objItem in colItems&lt;br /&gt;        For Each objProp In objItem.Properties_&lt;br /&gt;            strName = objProp.Name&lt;br /&gt;            If Ucase(strName) = Ucase(w_prop) Then&lt;br /&gt;                'wscript.echo vbTab &amp;amp; &amp;quot;property --&amp;gt; &amp;quot; &amp;amp; w_prop&lt;br /&gt;                If IsArray(objProp.Value) Then&lt;br /&gt;                    strValue = Join(objProp.Value, &amp;quot;;&amp;quot;)&lt;br /&gt;                Else&lt;br /&gt;                    strValue = Trim(objProp.Value)&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt; &lt;br /&gt;        If strValue &amp;lt;&amp;gt; &amp;quot;&amp;quot; And Not IsNull(strValue) Then&lt;br /&gt;            If w_match = &amp;quot;EQUAL&amp;quot; Then&lt;br /&gt;                If strValue = w_val Then&lt;br /&gt;                    retval = True&lt;br /&gt;                End If&lt;br /&gt;            Else&lt;br /&gt;                If InStr(strValue, w_val) &amp;gt; 0 Then&lt;br /&gt;                    retval = True&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;    WMIRule = retval&lt;br /&gt;End Function&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;Function objWMI(strComputer, strWQL)&lt;br /&gt;    'On Error Resume Next&lt;br /&gt;    Dim wmiNS, objWMIService, objSWbemLocator, objSWbemServices&lt;br /&gt;    Dim strUID, strPwd&lt;br /&gt;               &lt;br /&gt;    wmiNS  = &amp;quot;\root\cimv2&amp;quot;&lt;br /&gt;    strUID = &amp;quot;&amp;quot;&lt;br /&gt;    strPwd = &amp;quot;&amp;quot;&lt;br /&gt;               &lt;br /&gt;    Set objSWbemLocator = CreateObject(&amp;quot;WbemScripting.SWbemLocator&amp;quot;)&lt;br /&gt;               &lt;br /&gt;    On Error Resume Next&lt;br /&gt;               &lt;br /&gt;    Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, wmiNS, strUID, strPwd)&lt;br /&gt;               &lt;br /&gt;    Select Case Err.Number&lt;br /&gt;        Case -2147024891:&lt;br /&gt;            wscript.echo &amp;quot;error: access denied!&amp;quot;&lt;br /&gt;            Exit Function&lt;br /&gt;    End Select&lt;br /&gt;               &lt;br /&gt;    On Error GoTo 0&lt;br /&gt;               &lt;br /&gt;    Select Case UCase(strWQL)&lt;br /&gt;        Case &amp;quot;CLASSES&amp;quot;:&lt;br /&gt;            Set objWMI = objSWbemServices&lt;br /&gt;        Case Else:&lt;br /&gt;            Set objWMI = objSWbemServices.ExecQuery(strWQL)&lt;br /&gt;    End Select&lt;br /&gt;               &lt;br /&gt;    Set objSWbemServices = Nothing&lt;br /&gt;    Set objSWbemLocator = Nothing&lt;br /&gt;End Function&lt;/pre&gt;&lt;br /&gt;And here is the data &amp;quot;rules&amp;quot; file that spells out the class properties to search... &lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: courier,verdana; color: blue; font-size: 9pt"&gt;'------------------------------------------------------------------------------&lt;br /&gt;' wmi_rules.txt&lt;br /&gt;'------------------------------------------------------------------------------&lt;br /&gt;' each row denotes a rule to be tested within root\cimv2 namespace (for now)&lt;br /&gt;' each row contains the WMI: class, property, value, and matchtype&lt;br /&gt;' class = win32 class name&lt;br /&gt;' property = the name of a given class property&lt;br /&gt;' value = the value you wish to test for&lt;br /&gt;' matchtype = EQUAL or LIKE&lt;br /&gt;'------------------------------------------------------------------------------&lt;br /&gt;Class=win32_ComputerSystem,Property=Model,Value=dc7900,MatchType=LIKE&lt;br /&gt;Class=win32_OperatingSystem,Property=Caption,Value=Microsoft Windows 7 Enterprise,MatchType=LIKE&lt;br /&gt;Class=win32_OperatingSystem,Property=OSArchitecture,Value=64-bit,MatchType=EQUAL&lt;br /&gt;Class=win32_Service,Property=Name,Value=VMAuthdService,MatchType=EQUAL&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7310058688679741367?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7310058688679741367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/10/wmi-search-filter-thingy-script-thingy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7310058688679741367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7310058688679741367'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/10/wmi-search-filter-thingy-script-thingy.html' title='A WMI Search-Filter Thingy Script Thingy'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5268079660960146563</id><published>2010-10-08T13:57:00.001-07:00</published><updated>2010-10-08T13:57:40.016-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='fso'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>Making Folder Trees</title><content type='html'>&lt;p&gt;I was asked to provide a script to help someone else with creating a folder tree during a software installation.&amp;#160; I explained that it’s “one line of code” when using a .BAT/.CMD script with “mkdir x:\folder\folder\folder”, but I got the hand in the face, followed by “we need it to be VBscript, not DOS”.&amp;#160; I said “whatever” and cranked out the following hamburger pile. I hope it’s of use to someone else…&lt;/p&gt;  &lt;pre style="color: blue"&gt;rootPath = &amp;quot;c:\program files&amp;quot;&lt;br /&gt;folderPath = &amp;quot;vendorname\appname\folder123&amp;quot;&lt;br /&gt;fpath = rootPath &amp;amp; &amp;quot;\&amp;quot; &amp;amp; folderPath&lt;br /&gt; &lt;br /&gt;Set fso = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt; &lt;br /&gt;If fso.FolderExists(rootPath) Then&lt;br /&gt;    tmp = rootPath&lt;br /&gt;    For each s in Split(folderPath, &amp;quot;\&amp;quot;)&lt;br /&gt;        tmp = tmp &amp;amp; &amp;quot;\&amp;quot; &amp;amp; s&lt;br /&gt;        If fso.FolderExists(tmp) Then&lt;br /&gt;            wscript.echo &amp;quot;exists: &amp;quot; &amp;amp; tmp&lt;br /&gt;        Else&lt;br /&gt;            wscript.echo &amp;quot;creating: &amp;quot; &amp;amp; tmp&lt;br /&gt;            fso.CreateFolder(tmp)&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;Else&lt;br /&gt;    wscript.echo &amp;quot;fail: root path not found = &amp;quot; &amp;amp; rootPath&lt;br /&gt;End If&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5268079660960146563?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5268079660960146563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/10/making-folder-trees.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5268079660960146563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5268079660960146563'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/10/making-folder-trees.html' title='Making Folder Trees'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2001682703843547608</id><published>2010-09-08T16:28:00.001-07:00</published><updated>2010-09-08T16:28:58.013-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='functions'/><title type='text'>Stupid-Simple, Yet Useful VBScript Functions</title><content type='html'>&lt;p&gt;Ok, technically some of these are not functions, they're subs (or subroutines), but who cares.&amp;#160; I don't know who invented them, but I've been using these for years and years.&amp;#160; I hope they're helpful to you as well…&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Sub &lt;strong&gt;Echo&lt;/strong&gt;(category, caption)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; wscript.echo Now &amp;amp; vbTab category &amp;amp; vbTab &amp;amp; caption      &lt;br /&gt;End Sub&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Examples…&lt;/p&gt;  &lt;p&gt;&lt;font color="#8064a2"&gt;Echo &amp;quot;info&amp;quot;, &amp;quot;searching for wmi repository scope on remote computer…&amp;quot;     &lt;br /&gt;…      &lt;br /&gt;Echo &amp;quot;fail&amp;quot;, &amp;quot;unable to connect to remote computer&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Function &lt;strong&gt;ScriptPath&lt;/strong&gt;()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ScriptPath = Replace(wscript.ScriptFullName, &amp;quot;\&amp;quot; &amp;amp; wscript.ScriptName, &amp;quot;&amp;quot;)      &lt;br /&gt;End Function&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Function &lt;strong&gt;IsWeekend&lt;/strong&gt;(strDate)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; If Weekday(strDate)=1 Or Weekday(strDate)=2 Then      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IsWeekend = True      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End If      &lt;br /&gt;End Function&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;Function &lt;strong&gt;LeapYear&lt;/strong&gt;(yr)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim d1, d2      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; d1 = FormatDateTime(&amp;quot;1/1/&amp;quot; &amp;amp; yr)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; d2 = DateAdd(&amp;quot;yyyy&amp;quot;, 1, d1)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; If DateDiff(&amp;quot;d&amp;quot;, d1, d2) = 366 Then      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LeapYear = True      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End If      &lt;br /&gt;End Function&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#8064a2"&gt;For i = 2004 to 2012     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; If LeapYear(i) Then      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; wscript.echo i &amp;amp; vbTab &amp;amp; &amp;quot;is a leap year&amp;quot;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Else      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; wscript.echo i &amp;amp; vbTab &amp;amp; &amp;quot;is not a leap year&amp;quot;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End If      &lt;br /&gt;Next&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2001682703843547608?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2001682703843547608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/09/stupid-simple-yet-useful-vbscript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2001682703843547608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2001682703843547608'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/09/stupid-simple-yet-useful-vbscript.html' title='Stupid-Simple, Yet Useful VBScript Functions'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6158605801723286936</id><published>2010-09-08T15:26:00.001-07:00</published><updated>2010-09-08T15:26:44.655-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='bat'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>Script Tip: Determine the Script File Path</title><content type='html'>&lt;p&gt;With BAT/CMD scripts you can simply prefix any path references with &lt;font color="#ff0000"&gt;%~dps0&lt;/font&gt; to get to things in the same location (folder/UNC) where the script itself resides.&amp;#160; So if you run..&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;start /wait &lt;font color="#ff0000"&gt;%~dps0&lt;/font&gt;setup.exe /silent /norestart&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;It runs setup.exe from the same folder location. (that is not a typo, there should be NO space between the zero and the rest of the file path)&lt;/p&gt;  &lt;p&gt;It's just as easy with KiXtart using the &lt;font color="#ff0000"&gt;@scriptdir&lt;/font&gt; macro, but with VBscript it's not that simple.&amp;#160; But it's not difficult either…&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;scriptPath = Replace(Wscript.&lt;font color="#9b00d3"&gt;ScriptFullName&lt;/font&gt;, &amp;quot;\&amp;quot; &amp;amp; Wscript.&lt;font color="#9b00d3"&gt;ScriptName&lt;/font&gt;, &amp;quot;&amp;quot;)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;An example of running setup.exe in the same folder with VBscript might be…&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;filePath = scriptPath &amp;amp; &amp;quot;\setup.exe&amp;quot;      &lt;br /&gt;result = objShell.Run(filePath &amp;amp; &amp;quot; /silent /norestart&amp;quot;, 7, True)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;However, be careful to wrap paths in double-quotes if they contain spaces…&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;filePath = Chr(34) &amp;amp; scriptPath &amp;amp; &amp;quot;\setup.exe&amp;quot; &amp;amp; Chr(34)      &lt;br /&gt;result = objShell.Run(filePath &amp;amp; &amp;quot; /silent /norestart&amp;quot;, 7, True)&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6158605801723286936?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6158605801723286936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/09/script-tip-determine-script-file-path.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6158605801723286936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6158605801723286936'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/09/script-tip-determine-script-file-path.html' title='Script Tip: Determine the Script File Path'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-374025063737554380</id><published>2010-08-09T13:43:00.001-07:00</published><updated>2010-08-09T13:43:05.511-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='diagnostics'/><category scheme='http://www.blogger.com/atom/ns#' term='processes'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='reporting'/><title type='text'>Comparing Processes: Before/After Launching an Application</title><content type='html'>I needed to capture a delta between running processes on my Windows 7 computer before and after launching a particular application.&amp;#160; I could have used some freeware and shareware apps for this, but I wanted something stupid simple (as far as output), not something I had to sift through and tinker with settings, etc.&amp;#160; I hope you find it useful. Beware of word-wrapping when copying this mess.  &lt;pre style="color: blue; font-size: 9pt"&gt;'****************************************************************&lt;br /&gt;' Filename..: taskdump.vbs&lt;br /&gt;' Author....: David M. Stein&lt;br /&gt;' Date......: 07/27/2010&lt;br /&gt;' Purpose...: display user contexts of running processes on remote computer&lt;br /&gt;' Notes.....: run as admin (re: remote computer)&lt;br /&gt;'****************************************************************&lt;br /&gt;Option Explicit&lt;br /&gt;&lt;br /&gt;Const ForReading = 1&lt;br /&gt;Const ForWriting = 2&lt;br /&gt;Const offset = 78 ' start point on each row of dump file&lt;br /&gt;Const offlen = 50 ' end point on each row of dump file&lt;br /&gt;&lt;br /&gt;Dim objFile, strLine, uid, ulist&lt;br /&gt;Dim objArgs, objFSO, objShell, mode&lt;br /&gt;Dim strComputer, temp, outf, retval&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' comment: check if computer name was provided to script&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Set objArgs = WScript.Arguments&lt;br /&gt;If objArgs.Count = 0 Then&lt;br /&gt;	strComputer = Trim(InputBox(&amp;quot;Computer Name&amp;quot;, &amp;quot;Computer Name&amp;quot;))&lt;br /&gt;	mode = 2&lt;br /&gt;Else&lt;br /&gt;	strComputer = Trim(objArgs(0))&lt;br /&gt;	mode = 1&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;If strComputer = &amp;quot;&amp;quot; Then&lt;br /&gt;	ShowUsage()&lt;br /&gt;	wscript.Quit(1)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;wscript.echo &amp;quot;info: computer is &amp;quot; &amp;amp; strComputer&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' comment: continue on&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Set objShell = CreateObject(&amp;quot;Wscript.Shell&amp;quot;)&lt;br /&gt;Set objFSO = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' example dump...&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' Image Name	     PID Session Name        Session#    Mem Usage User Name		              CPU Time&lt;br /&gt;' ========================= ======== ================ =========== ============ ================================================== ============&lt;br /&gt;' System Idle Process              0	            0         28 K N/A			     0:43:57&lt;br /&gt;' System	           4	            0        240 K NT AUTHORITY\SYSTEM		     0:00:13&lt;br /&gt;' smss.exe	       548	            0        388 K NT AUTHORITY\SYSTEM&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' comment: define output (dump) file path and name&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;temp = objShell.ExpandEnvironmentStrings(&amp;quot;%temp%&amp;quot;)&lt;br /&gt;outf = temp &amp;amp; &amp;quot;\&amp;quot; &amp;amp; strComputer &amp;amp; &amp;quot;.tsk&amp;quot;&lt;br /&gt;ulist = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' comment: run tasklist to produce dump file&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;retval = objShell.Run(&amp;quot;cmd /c tasklist /s &amp;quot; &amp;amp; strComputer &amp;amp; &amp;quot; /v &amp;gt;&amp;quot; &amp;amp; outf, 7, True)&lt;br /&gt;wscript.echo &amp;quot;info: exit code was &amp;quot; &amp;amp; retval&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' comment: if dump file found, open and parse it&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;If objFSO.FileExists(outf) Then&lt;br /&gt;	wscript.echo &amp;quot;info: reading dump file...&amp;quot;&lt;br /&gt;	On Error Resume Next&lt;br /&gt;	Set objFile = objFSO.OpenTextFile(outf, ForReading)&lt;br /&gt;	If err.Number = 0 Then&lt;br /&gt;		Do Until objFile.AtEndOfStream&lt;br /&gt;			strLine = Trim(objFile.Readline)&lt;br /&gt;			If strLine &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;				uid = Trim(Mid(strLine, offset, offlen))&lt;br /&gt;				' ignore user &amp;quot;N/A&amp;quot;&lt;br /&gt;				If uid &amp;lt;&amp;gt; &amp;quot;N/A&amp;quot; And Left(uid, 3) &amp;lt;&amp;gt; &amp;quot;===&amp;quot; And Left(uid, 4) &amp;lt;&amp;gt; &amp;quot;User&amp;quot; Then&lt;br /&gt;					If ulist = &amp;quot;&amp;quot; Then&lt;br /&gt;						ulist = Ucase(uid)&lt;br /&gt;					Else&lt;br /&gt;						' only collect unique names&lt;br /&gt;						If InStr(ulist, Ucase(uid)) &amp;lt; 1 Then&lt;br /&gt;							ulist = ulist &amp;amp; vbTab &amp;amp; uid&lt;br /&gt;						End If&lt;br /&gt;					End If&lt;br /&gt;				End If&lt;br /&gt;			End If&lt;br /&gt;		Loop&lt;br /&gt;		objFile.Close&lt;br /&gt;		' display results&lt;br /&gt;		If mode = 1 Then&lt;br /&gt;			wscript.echo Replace(ulist, vbTab, vbCRLF)&lt;br /&gt;		Else&lt;br /&gt;			MsgBox Replace(ulist, vbTab, vbCRLF), 64, &amp;quot;User Processes on &amp;quot; &amp;amp; Ucase(strComputer)&lt;br /&gt;		End If&lt;br /&gt;	Else&lt;br /&gt;		wscript.echo &amp;quot;fail: error (&amp;quot; &amp;amp; err.Number &amp;amp; &amp;quot;) = &amp;quot; &amp;amp; err.Description&lt;br /&gt;	End If&lt;br /&gt;Else&lt;br /&gt;	wscript.echo &amp;quot;fail: dump file not found&amp;quot;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Sub ShowUsage()&lt;br /&gt;	wscript.echo&lt;br /&gt;	wscript.echo &amp;quot;usage: taskdump.vbs computername&amp;quot;&lt;br /&gt;	wscript.echo&lt;br /&gt;End Sub&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-374025063737554380?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/374025063737554380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/08/comparing-processes-beforeafter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/374025063737554380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/374025063737554380'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/08/comparing-processes-beforeafter.html' title='Comparing Processes: Before/After Launching an Application'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-9096047307555112878</id><published>2010-07-29T19:20:00.001-07:00</published><updated>2010-07-29T19:20:06.605-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><category scheme='http://www.blogger.com/atom/ns#' term='sysinternals'/><title type='text'>Script to Auto-Update Your Sysinternals Tools</title><content type='html'>&lt;p&gt;&lt;a href="http://twitter.com/faulkner132" target="_blank"&gt;Jason Faulkner&lt;/a&gt; posted a very cool Batch script to freshen your library of Sysinternals tools over at SysAdminGeek.com.&amp;#160; It queries the live.sysinternals.com\tools repository and downloads matching tools in your library.&amp;#160; If you haven't already checked it out, you should (&lt;a href="http://sysadmingeek.com/articles/batch-script-to-auto-update-sysinternals-tools/" target="_blank"&gt;click here&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;Here's a version I've done in VBScript.&amp;#160; You can tweak it for your needs and even schedule it to run periodically to keep your tools up to date.&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;Const livetools = &amp;quot;\\live.sysinternals.com\tools&amp;quot;&lt;br /&gt;Const localtools = &amp;quot;c:\sysinternals&amp;quot;&lt;br /&gt;&lt;br /&gt;Set objFSO = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;wscript.echo &amp;quot;info: connecting to live.sysinternal.com...&amp;quot;&lt;br /&gt;Set objLiveFolder = objFSO.GetFolder(livetools)&lt;br /&gt;If err.Number &amp;lt;&amp;gt; 0 Then&lt;br /&gt;	wscript.echo &amp;quot;fail: unable to connect&amp;quot;&lt;br /&gt;	wscript.quit(1)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;If objFSO.FolderExists(localTools) = False Then&lt;br /&gt;	wscript.echo &amp;quot;fail: local folder not found&amp;quot;&lt;br /&gt;	wscript.quit(2)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;For each objFile in objLiveFolder.Files&lt;br /&gt;	fileName = objFile.Name&lt;br /&gt;	If objFSO.FileExists(localtools &amp;amp; &amp;quot;\&amp;quot; &amp;amp; fileName) Then&lt;br /&gt;		wscript.echo &amp;quot;info: updating file &amp;quot; &amp;amp; fileName &amp;amp; &amp;quot;...&amp;quot;&lt;br /&gt;		sourceFile = liveTools &amp;amp; &amp;quot;\&amp;quot; &amp;amp; fileName&lt;br /&gt;		targetFile = localTools &amp;amp; &amp;quot;\&amp;quot; &amp;amp; fileName&lt;br /&gt;		objFSO.CopyFile sourceFile, targetFile, True&lt;br /&gt;	End If&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;Set objFolder = Nothing&lt;br /&gt;Set objFSO = Nothing&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If I had more time I'd do this in KiXtart and Powershell, but I'll leave that to someone else.&amp;#160; Enjoy!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-9096047307555112878?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/9096047307555112878/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/07/script-to-auto-update-your-sysinternals.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/9096047307555112878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/9096047307555112878'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/07/script-to-auto-update-your-sysinternals.html' title='Script to Auto-Update Your Sysinternals Tools'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2847609219180157649</id><published>2010-07-20T19:18:00.001-07:00</published><updated>2010-07-20T19:18:39.314-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='installation'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><title type='text'>MS Security Essentials vNext Silent Install</title><content type='html'>&lt;p&gt;The new Microsoft Security Essentials is &lt;a href="https://connect.microsoft.com/securityessentials" target="_blank"&gt;out in beta&lt;/a&gt;, and here's how to install it silently using a VBscript.&amp;#160; You still need to tweak it for UAC unless you adapt the command string for use within something else like ConfigMgr.&amp;#160; Enjoy…&lt;/p&gt;  &lt;pre style="color: blue"&gt;const x86 = &amp;quot;mseinstall_en_us_x86.exe&amp;quot;&lt;br /&gt;const x64 = &amp;quot;mseinstall_en_us_amd64.exe&amp;quot;&lt;br /&gt;&lt;br /&gt;Function ScriptPath()&lt;br /&gt;    ScriptPath = Replace(wscript.ScriptFullName, &amp;quot;\&amp;quot; &amp;amp; wscript.ScriptName, &amp;quot;&amp;quot;)&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Set fso = createobject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;If fso.FolderExists(&amp;quot;c:\Program Files (x86)&amp;quot;) Then&lt;br /&gt;    cmd = x64&lt;br /&gt;Else&lt;br /&gt;    cmd = x86&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;cmdpath = ScriptPath() &amp;amp; &amp;quot;\&amp;quot; &amp;amp; cmd&lt;br /&gt;&lt;br /&gt;If fso.FileExists(cmdpath) Then&lt;br /&gt;    Set objShell = CreateObject(&amp;quot;Wscript.Shell&amp;quot;)&lt;br /&gt;    objShell.Run cmdpath &amp;amp; &amp;quot; /s /runwgacheck /o&amp;quot;, 1, True&lt;br /&gt;    Set objShell = Nothing&lt;br /&gt;Else&lt;br /&gt;    wscript.echo cmdpath &amp;amp; &amp;quot; not found&amp;quot;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set fso = Nothing&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2847609219180157649?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2847609219180157649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/07/ms-security-essentials-vnext-silent.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2847609219180157649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2847609219180157649'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/07/ms-security-essentials-vnext-silent.html' title='MS Security Essentials vNext Silent Install'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2984226322673011330</id><published>2010-06-10T16:19:00.001-07:00</published><updated>2010-06-10T16:19:02.745-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='diagnostics'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='monitoring'/><category scheme='http://www.blogger.com/atom/ns#' term='reporting'/><category scheme='http://www.blogger.com/atom/ns#' term='scheduling'/><category scheme='http://www.blogger.com/atom/ns#' term='inventory'/><title type='text'>Automating Domain Controller Diagnostics, Version 2.0, Part 2 of 2</title><content type='html'>&lt;p&gt;This is the follow-up script to part 1 (see &amp;quot;Automating Domain Controller Diagnostics, Version 2.0&amp;quot;).&amp;#160; This script runs on the member server which has the &amp;quot;Logs$&amp;quot; share, using a scheduled task.&amp;#160; Make sure the scheduled task runs AFTER the individual scheduled tasks on each domain controller are all completed.&amp;#160; I strongly suggest you stagger the individual scheduled tasks a little to avoid impacting all domain controllers at the same time, so the task that runs this script should be run a few minutes or an hour AFTER the last of those is completed.&lt;/p&gt;  &lt;p&gt;Configure the scheduled task to run this script as the local SYSTEM account.&lt;/p&gt;  &lt;p&gt;As always: This script is provided as-is without any warranties, implied or explicit.&amp;#160; Use at YOUR OWN RISK.&amp;#160; Edit and test in a safe environment before using in a production environment.&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;'**************************************************************&lt;br /&gt;' Filename: dc_diagnostics_report.vbs&lt;br /&gt;' Author:   David Stein&lt;br /&gt;' Date:     11/20/07&lt;br /&gt;' Purpose:  Open and Parse report files to produce final report&lt;br /&gt;'**************************************************************&lt;br /&gt;Const collectionServer = &amp;quot;\\memberserver&amp;quot;&lt;br /&gt;Const DebugMode  = True&lt;br /&gt;Const SendAlerts = True&lt;br /&gt;Const mailServer = &amp;quot;mailserver.mydomain.local&amp;quot;&lt;br /&gt;Const alertList  = &amp;quot;Server Admins &amp;lt;it_server_admins@MYDOMAIN.LOCAL&amp;gt;&amp;quot;&lt;br /&gt;Const alertFrom  = &amp;quot;IT REPORTS &amp;lt;donotreply @MYDOMAIN.LOCAL&amp;gt;&amp;quot;&lt;br /&gt;Const ForReading = 1&lt;br /&gt;Const ForWriting = 2&lt;br /&gt;Const Verbosity  = False&lt;br /&gt;Const threshold  = 1&lt;br /&gt;Const scriptVer  = &amp;quot;11.20.07&amp;quot;&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' declare variables&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Dim fso, filename, filedate, totalcount, s&lt;br /&gt;Dim dcdiag_status, dcdiag_list, collectionFolder&lt;br /&gt;Dim netdiag_status, netdiag_list&lt;br /&gt;Dim repadmin_status, repadmin_list&lt;br /&gt;Dim errorsFound, dcdiag_errors, netdiag_errors, repadmin_errors&lt;br /&gt;Dim dclist, ndlist, rplist, strServer&lt;br /&gt;Dim listd, listn, listr, shortdate, currenttime&lt;br /&gt;&lt;br /&gt;shortdate   = FormatDateTime(Now,vbShortDate)&lt;br /&gt;currentTime = FormatDateTime(Now,vbLongTime)&lt;br /&gt;collectionFolder = collectionServer &amp;amp; &amp;quot;\logs$&amp;quot;&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' initialize list and counter variables&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;dclist = &amp;quot;&amp;quot;&lt;br /&gt;ndlist = &amp;quot;&amp;quot;&lt;br /&gt;rplist = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;totalcount      = 0&lt;br /&gt;errorsFound     = 0&lt;br /&gt;dcdiag_errors   = 0&lt;br /&gt;netdiag_errors  = 0&lt;br /&gt;repadmin_errors = 0&lt;br /&gt;&lt;br /&gt;dcdiag_list   = &amp;quot;&amp;quot;&lt;br /&gt;netdiag_list  = &amp;quot;&amp;quot;&lt;br /&gt;repadmin_list = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' diagnostics printer&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub DebugPrint(s)&lt;br /&gt;    If DebugMode Then&lt;br /&gt;        wscript.echo s&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' main process&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub Main()&lt;br /&gt;    Set fso = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;&lt;br /&gt;    If fso.FolderExists(collectionFolder) Then&lt;br /&gt;        dcdiag_status   = CountReportFiles(&amp;quot;dcdiag&amp;quot;)&lt;br /&gt;        netdiag_status  = CountReportFiles(&amp;quot;netdiag&amp;quot;)&lt;br /&gt;        repadmin_status = CountReportFiles(&amp;quot;repadmin&amp;quot;)&lt;br /&gt;&lt;br /&gt;        totalcount = (dcdiag_status + netdiag_status + repadmin_status)&lt;br /&gt;&lt;br /&gt;        debugprint &amp;quot;info: &amp;quot; &amp;amp; dcdiag_status &amp;amp; &amp;quot; dcdiag report files&amp;quot;&lt;br /&gt;&lt;br /&gt;        For each s in Split(dcdiag_list,&amp;quot;,&amp;quot;)&lt;br /&gt;            If Trim(s) &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;                debugprint &amp;quot;  &amp;quot; &amp;amp; Trim(s)&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;&lt;br /&gt;        debugprint &amp;quot;info: &amp;quot; &amp;amp; netdiag_status &amp;amp; &amp;quot; netdiag report files&amp;quot;&lt;br /&gt;&lt;br /&gt;        For each s in Split(netdiag_list,&amp;quot;,&amp;quot;)&lt;br /&gt;            If Trim(s) &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;                debugprint &amp;quot;  &amp;quot; &amp;amp; Trim(s)&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;&lt;br /&gt;        debugprint &amp;quot;info: &amp;quot; &amp;amp; repadmin_status &amp;amp; &amp;quot; repadmin report files&amp;quot;&lt;br /&gt;&lt;br /&gt;        For each s in Split(repadmin_list,&amp;quot;,&amp;quot;)&lt;br /&gt;            If Trim(s) &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;                debugprint &amp;quot;  &amp;quot; &amp;amp; Trim(s)&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;&lt;br /&gt;        debugprint &amp;quot;info: &amp;quot; &amp;amp; totalcount &amp;amp; &amp;quot; total report files&amp;quot;&lt;br /&gt;&lt;br /&gt;        listd = IterateReportFiles(&amp;quot;dcdiag&amp;quot;)&lt;br /&gt;        listn = IterateReportFiles(&amp;quot;netdiag&amp;quot;)&lt;br /&gt;        listr = IterateReportFiles(&amp;quot;repadmin&amp;quot;)&lt;br /&gt;&lt;br /&gt;        debugprint &amp;quot;-------------------------------------------&amp;quot; &amp;amp; _&lt;br /&gt;            vbCRLF &amp;amp; &amp;quot;detail results...&amp;quot; &amp;amp; _&lt;br /&gt;            vbCRLF &amp;amp; &amp;quot;-------------------------------------------&amp;quot;&lt;br /&gt;        debugprint listd &amp;amp; _&lt;br /&gt;            vbCRLF &amp;amp; &amp;quot;-------------------------------------------&amp;quot;&lt;br /&gt;        debugprint listn &amp;amp; _&lt;br /&gt;            vbCRLF &amp;amp; &amp;quot;-------------------------------------------&amp;quot;&lt;br /&gt;        debugprint listr &amp;amp; _&lt;br /&gt;            vbCRLF &amp;amp; &amp;quot;-------------------------------------------&amp;quot;&lt;br /&gt;        If SendAlerts Then&lt;br /&gt;            Dim msgBody, msgSub&lt;br /&gt;            If errorsFound &amp;gt; 0 Then&lt;br /&gt;                msgSub = &amp;quot;Domain Controller Status Alert&amp;quot;&lt;br /&gt;            Else&lt;br /&gt;                msgSub = &amp;quot;Domain Controller Status Report&amp;quot;&lt;br /&gt;            End If&lt;br /&gt;            msgBody = msgSub &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;----------------------------------&amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;Errors/Warnings: &amp;quot; &amp;amp; errorsFound &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;Processed: &amp;quot; &amp;amp; shortdate &amp;amp; &amp;quot; at &amp;quot; &amp;amp; currentTime &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;----------------------------------&amp;quot; &amp;amp; vbCRLF&lt;br /&gt;&lt;br /&gt;            For each s in Split(dcdiag_list,&amp;quot;,&amp;quot;)&lt;br /&gt;                If Trim(s) &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;                    msgBody = msgBody &amp;amp; Trim(s) &amp;amp; vbCRLF&lt;br /&gt;                End If&lt;br /&gt;            Next&lt;br /&gt;            msgBody = msgBody &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;----------------------------------&amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;Details Follow...&amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;----------------------------------&amp;quot;&lt;br /&gt;            msgBody = msgBody &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;DCDIAG Results: &amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; listd &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; vbCRLF &amp;amp; &amp;quot;NETDIAG Results: &amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; listn &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; vbCRLF &amp;amp; &amp;quot;REPADMIN Results: &amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; listr &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;----------------------------------&amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;Note: log report files are collected at&amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;the following UNC location and may be&amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;accessed there for diagnostics review...&amp;quot; &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; collectionFolder &amp;amp; _&lt;br /&gt;                vbCRLF &amp;amp; &amp;quot;script: dc_diagnostics_report.vbs, version: &amp;quot; &amp;amp; scriptVer&lt;br /&gt;&lt;br /&gt;            SendMail alertList, alertFrom, msgSub, msgBody, &amp;quot;TEXT&amp;quot;&lt;br /&gt;        End If&lt;br /&gt;    Else&lt;br /&gt;        ' folder not found&lt;br /&gt;    End If&lt;br /&gt;    Set fso = Nothing&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' description:&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Function ServerFileName(sFilename)&lt;br /&gt;    Dim tmp, retval&lt;br /&gt;    tmp = Split(sFilename, &amp;quot;_&amp;quot;)&lt;br /&gt;    On Error Resume Next&lt;br /&gt;    retval = tmp(0)&lt;br /&gt;    If err.Number &amp;lt;&amp;gt; 0 Then&lt;br /&gt;        retval = Left(sFilename,9)&lt;br /&gt;    End If&lt;br /&gt;    ServerFileName = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' count, separate and process log files&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Function CountReportFiles(reportClass)&lt;br /&gt;    Dim fld, f, filename, filedate, counter, retval, age&lt;br /&gt;    counter = 0&lt;br /&gt;    retval = &amp;quot;Server&amp;quot; &amp;amp; vbTab &amp;amp; &amp;quot;Reported&amp;quot; &amp;amp; vbCRLF&lt;br /&gt;    Set fld = fso.GetFolder(collectionFolder)&lt;br /&gt;    For each f in fld.Files&lt;br /&gt;        filename = f.Name&lt;br /&gt;        filedate = f.DateLastModified&lt;br /&gt;        If InStr(1, filename, reportClass) &amp;gt; 0 Then&lt;br /&gt;            age = DateDiff(&amp;quot;d&amp;quot;, filedate, shortdate)&lt;br /&gt;            If Abs(age) &amp;gt; threshold Then&lt;br /&gt;                retval = retval &amp;amp; ServerFileName(filename) &amp;amp; vbTab &amp;amp; filedate &amp;amp; &amp;quot; **,&amp;quot;&lt;br /&gt;            Else&lt;br /&gt;                retval = retval &amp;amp; ServerFileName(filename) &amp;amp; vbTab &amp;amp; filedate &amp;amp; &amp;quot;,&amp;quot;&lt;br /&gt;            End If&lt;br /&gt;            counter = counter + 1&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;    Set fld = Nothing&lt;br /&gt;    Select Case reportClass&lt;br /&gt;        Case &amp;quot;dcdiag&amp;quot;:&lt;br /&gt;            dcdiag_list = retval&lt;br /&gt;        Case &amp;quot;netdiag&amp;quot;:&lt;br /&gt;            netdiag_list = retval&lt;br /&gt;        Case &amp;quot;repadmin&amp;quot;:&lt;br /&gt;            repadmin_list = retval&lt;br /&gt;    End Select&lt;br /&gt;    CountReportFiles = counter&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' loop through log files&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Function IterateReportFiles(rType)&lt;br /&gt;    Dim fld, f, filename, filepath, retval&lt;br /&gt;    retval = &amp;quot;&amp;quot;&lt;br /&gt;    Set fld = fso.GetFolder(collectionFolder)&lt;br /&gt;    For each f in fld.Files&lt;br /&gt;        filename = f.Name&lt;br /&gt;        filepath = collectionFolder &amp;amp; &amp;quot;\&amp;quot; &amp;amp; filename&lt;br /&gt;        If InStr(1, filename, rType) &amp;gt; 0 Then&lt;br /&gt;            retval = retval &amp;amp; AnalyzeReportFile(filepath, rType, ServerFileName(filename))&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;    Set fld = Nothing&lt;br /&gt;    IterateReportFiles = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' description:&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Function CompareFileDates(d1, d2)&lt;br /&gt;    Dim retval&lt;br /&gt;    retval = DateDiff(&amp;quot;d&amp;quot;, d1, d2)&lt;br /&gt;    CompareFileDates = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' open, parse and return result from log file&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Function AnalyzeReportFile(filespec, reportClass, strServer)&lt;br /&gt;    Dim theFile, retval, ln&lt;br /&gt;    retval = &amp;quot;&amp;quot;&lt;br /&gt;    Set theFile = fso.OpenTextFile(filespec, ForReading, False)&lt;br /&gt;&lt;br /&gt;    Do While theFile.AtEndOfStream &amp;lt;&amp;gt; True&lt;br /&gt;        ln = Trim(theFile.ReadLine)&lt;br /&gt;&lt;br /&gt;        Select Case reportClass&lt;br /&gt;            '----------------------------------------------&lt;br /&gt;            ' DCDIAG analysis&lt;br /&gt;            '----------------------------------------------&lt;br /&gt;&lt;br /&gt;            Case &amp;quot;dcdiag&amp;quot;:&lt;br /&gt;                If InStr(1,ln,&amp;quot;Failed&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;                    retval = retval &amp;amp; strServer &amp;amp; &amp;quot; ... ERROR: &amp;quot; &amp;amp; ln &amp;amp; _&lt;br /&gt;                        vbCRLF &amp;amp; &amp;quot;....log: &amp;quot; &amp;amp; filespec &amp;amp; vbCRLF&lt;br /&gt;                    dcdiag_errors = dcdiag_errors + 1&lt;br /&gt;                    dclist = dclist &amp;amp; strServer &amp;amp; &amp;quot;,&amp;quot;&lt;br /&gt;                    errorsFound = errorsFound + 1&lt;br /&gt;                ElseIf InStr(1,ln,&amp;quot;Warning&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;                    retval = retval &amp;amp; strServer &amp;amp; &amp;quot; ... WARNING: &amp;quot; &amp;amp; ln &amp;amp; _&lt;br /&gt;                        vbCRLF &amp;amp; &amp;quot;....log: &amp;quot; &amp;amp; filespec &amp;amp; vbCRLF&lt;br /&gt;                    dcdiag_errors = dcdiag_errors + 1&lt;br /&gt;                    dclist = dclist &amp;amp; strServer &amp;amp; &amp;quot;,&amp;quot;&lt;br /&gt;                    errorsFound = errorsFound + 1&lt;br /&gt;                End If&lt;br /&gt;&lt;br /&gt;            '----------------------------------------------&lt;br /&gt;            ' NETDIAG analysis&lt;br /&gt;            '----------------------------------------------&lt;br /&gt;&lt;br /&gt;            Case &amp;quot;netdiag&amp;quot;:&lt;br /&gt;                Select Case Left(ln,36)&lt;br /&gt;                    Case &amp;quot;REPLICATION-RECEIVED LATENCY WARNING&amp;quot;:&lt;br /&gt;                        retval = retval &amp;amp; strServer &amp;amp; &amp;quot; ... WARNING: &amp;quot; &amp;amp; ln &amp;amp; _&lt;br /&gt;                            vbCRLF &amp;amp; &amp;quot;....log: &amp;quot; &amp;amp; filespec &amp;amp; vbCRLF&lt;br /&gt;                        errorsFound = errorsFound + 1&lt;br /&gt;                        netdiag_errors = netdiag_errors + 1&lt;br /&gt;                        ndlist = ndlist &amp;amp; strServer &amp;amp; &amp;quot;,&amp;quot;&lt;br /&gt;                End Select&lt;br /&gt;&lt;br /&gt;                Select Case Left(ln,25)&lt;br /&gt;                    Case &amp;quot;.........................&amp;quot;:&lt;br /&gt;                        If InStr(1,ln,&amp;quot;fail&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;                            netdiag_errors = netdiag_errors + 1&lt;br /&gt;                            errorsFound = errorsFound + 1&lt;br /&gt;                            ndlist = ndlist &amp;amp; strServer &amp;amp; &amp;quot;,&amp;quot;&lt;br /&gt;                            retval = retval &amp;amp; strServer &amp;amp; &amp;quot; ... ERROR: &amp;quot; &amp;amp; Mid(ln,27) &amp;amp; _&lt;br /&gt;                                vbCRLF &amp;amp; &amp;quot;....log: &amp;quot; &amp;amp; filespec &amp;amp; vbCRLF&lt;br /&gt;                        ElseIf InStr(1,ln,&amp;quot;FATAL&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;                            netdiag_errors = netdiag_errors + 1&lt;br /&gt;                            errorsFound = errorsFound + 1&lt;br /&gt;                            ndlist = ndlist &amp;amp; strServer &amp;amp; &amp;quot;,&amp;quot;&lt;br /&gt;                            retval = retval &amp;amp; strServer &amp;amp; &amp;quot; ... FATAL: &amp;quot; &amp;amp; Mid(ln,27) &amp;amp; _&lt;br /&gt;                                vbCRLF &amp;amp; &amp;quot;....log: &amp;quot; &amp;amp; filespec &amp;amp; vbCRLF&lt;br /&gt;                        End If&lt;br /&gt;                End Select&lt;br /&gt;&lt;br /&gt;            '----------------------------------------------&lt;br /&gt;            ' REPADMIN analysis&lt;br /&gt;            '----------------------------------------------&lt;br /&gt;&lt;br /&gt;            Case &amp;quot;repadmin&amp;quot;:&lt;br /&gt;                Select Case Left(ln,14)&lt;br /&gt;                    Case &amp;quot;Last attempt @&amp;quot;:&lt;br /&gt;                        If InStr(1,ln,&amp;quot;fail&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;                            errorsFound = errorsFound + 1&lt;br /&gt;                            repadmin_errors = repadmin_errors + 1&lt;br /&gt;                            rplist = rplist &amp;amp; strServer &amp;amp; &amp;quot;,&amp;quot;&lt;br /&gt;                            retval = retval &amp;amp; strServer &amp;amp; &amp;quot; ... ERROR: &amp;quot; &amp;amp; Mid(ln,16) &amp;amp; _&lt;br /&gt;                                vbCRLF &amp;amp; &amp;quot;....log: &amp;quot; &amp;amp; filespec &amp;amp; vbCRLF&lt;br /&gt;                        End If&lt;br /&gt;                End Select&lt;br /&gt;        End Select&lt;br /&gt;    Loop&lt;br /&gt;    If retval = &amp;quot;&amp;quot; Then&lt;br /&gt;        retval = strServer &amp;amp; &amp;quot; ... OK&amp;quot; &amp;amp; vbCRLF&lt;br /&gt;    End If&lt;br /&gt;    theFile.Close&lt;br /&gt;    Set theFile = Nothing&lt;br /&gt;    AnalyzeReportFile = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' send email&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub SendMail(sTo, sFrom, sSubject, sBody, sFormat)&lt;br /&gt;    Dim objMessage&lt;br /&gt;    Set objMessage = CreateObject(&amp;quot;CDO.Message&amp;quot;)&lt;br /&gt;    objMessage.Subject = sSubject&lt;br /&gt;    objMessage.Sender  = sFrom&lt;br /&gt;    objMessage.To = sTo&lt;br /&gt;    If sFormat = &amp;quot;TEXT&amp;quot; Then&lt;br /&gt;        objMessage.TextBody = sBody&lt;br /&gt;    Else&lt;br /&gt;        objMessage.HTMLBody = sBody&lt;br /&gt;    End If&lt;br /&gt;    objMessage.Configuration.Fields.Item _&lt;br /&gt;    (&amp;quot;http://schemas.microsoft.com/cdo/configuration/sendusing&amp;quot;) = 2&lt;br /&gt;    objMessage.Configuration.Fields.Item _&lt;br /&gt;    (&amp;quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&amp;quot;) = mailServer&lt;br /&gt;    objMessage.Configuration.Fields.Item _&lt;br /&gt;    (&amp;quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&amp;quot;) = 25&lt;br /&gt;    objMessage.Configuration.Fields.Update&lt;br /&gt;    objMessage.Send&lt;br /&gt;    Set objMessage = Nothing&lt;br /&gt;    debugprint &amp;quot;info: (sendmail) message sent to &amp;quot; &amp;amp; sTo&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Main()&lt;br /&gt;&lt;br /&gt;Wscript.Quit&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2984226322673011330?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2984226322673011330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/06/automating-domain-controller_10.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2984226322673011330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2984226322673011330'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/06/automating-domain-controller_10.html' title='Automating Domain Controller Diagnostics, Version 2.0, Part 2 of 2'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6387956468589303587</id><published>2010-06-10T15:15:00.001-07:00</published><updated>2010-06-10T15:17:34.597-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='diagnostics'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='reporting'/><category scheme='http://www.blogger.com/atom/ns#' term='scheduling'/><title type='text'>Automating Domain Controller Diagnostics, Version 2.0</title><content type='html'>&lt;p&gt;I posted a portion of this some time ago, but this week I received the fourth inquiry about the full version, so I guess it’s time to post it.&amp;#160; Here goes…&lt;/p&gt;  &lt;p&gt;Create a shared folder on each domain controller named &amp;quot;Data$&amp;quot; and assign permissions to only the &amp;quot;Domain Admins&amp;quot; security group.&amp;#160; Remove all others from the permissions set.&lt;/p&gt;  &lt;p&gt;Install the Support Tools and latest versions of DCDIAG.exe, NETDIAG.exe, and REPADMIN.exe on each domain controller.&amp;#160; Make SURE they are the same versions on all of them.&lt;/p&gt;  &lt;p&gt;Create a share named &amp;quot;Scripts$&amp;quot; on a central domain &lt;em&gt;member&lt;/em&gt; server.&amp;#160; Assign permissions to allow &amp;quot;Domain Controllers&amp;quot; security group to have Read permissions.&amp;#160; Assign &amp;quot;Domain Admins&amp;quot; to have full control permissions.&lt;/p&gt;  &lt;p&gt;Create a share named &amp;quot;Logs$&amp;quot; on a central domain &lt;em&gt;member &lt;/em&gt;server (can be the same &lt;em&gt;member&lt;/em&gt; server as the one above).&amp;#160; Assign permissions to allow &amp;quot;Domain Controllers&amp;quot; security group to have Change permissions (read/write/modify/delete).&amp;#160; Assign &amp;quot;Domain Admins&amp;quot; group full control.&lt;/p&gt;  &lt;p&gt;Put the script below into the &amp;quot;Scripts$&amp;quot; share.&lt;/p&gt;  &lt;p&gt;On each domain controller, create a scheduled task to run the script from the &amp;quot;Scripts$&amp;quot; UNC path at a chosen interval (daily, weekly, monthly, quarterly, whatever) using the local &amp;quot;SYSTEM&amp;quot; account.&amp;#160; The &amp;quot;SYSTEM&amp;quot; account operates in the context of the computer (the domain controller on which it is executed) and therefore becomes a member of the &amp;quot;Domain Controllers&amp;quot; group when it attempts to access remote resources (across the LAN/WAN).&lt;/p&gt;  &lt;p&gt;When the scheduled task executes the script, it should dump the output files into the local &amp;quot;Data$ share.&amp;#160; Another script will be posted soon which crawls through the collected files to produce a summary report of how your domain controllers are doing (with respect to the diagnostics reports for each).&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;Option Explicit&lt;br /&gt;'**************************************************************&lt;br /&gt;' Filename: dc_diagnostics.vbs&lt;br /&gt;' Author:   David Stein&lt;br /&gt;' Date:     11/19/07&lt;br /&gt;' Purpose:  Run and Report Diagnostics on Domain Controllers&lt;br /&gt;&lt;br /&gt;'**************************************************************&lt;br /&gt;' copyright: free for derivative use without any warranties&lt;br /&gt;' provided, explicit or implicit, provided that the above info&lt;br /&gt;' with author name is included (provide attribution)&lt;br /&gt;&lt;br /&gt;'**************************************************************&lt;br /&gt;Const DebugMode = True&lt;br /&gt;Const collectionFolder = &amp;quot;\\memberserver\logs$\&amp;quot;&lt;br /&gt;Const alertList    = &amp;quot;EMAIL_ADDRESS@mydomain.local&amp;quot;&lt;br /&gt;Const alertFrom    = &amp;quot;IT REPORTS &amp;lt;donotreply@MYDOMAIN.LOCAL&amp;gt;&amp;quot;&lt;br /&gt;Const mailServer   = &amp;quot;mail.mydomain.local&amp;quot;&lt;br /&gt;Const localShare   = &amp;quot;Data$&amp;quot;&lt;br /&gt;&lt;br /&gt;Const bRunDCDIAG   = True&lt;br /&gt;Const bRunNETDIAG  = True&lt;br /&gt;Const bRunREPADMIN = True&lt;br /&gt;Const DeleteTempFiles = False&lt;br /&gt;Const SendAlerts   = True&lt;br /&gt;Const SendOnErrorsOnly = True&lt;br /&gt;&lt;br /&gt;Const bVerbose = False&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' declare variables&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Dim objShell, objFSO, strServerName, strServerData&lt;br /&gt;Dim strMonthNum, strDayNum, strYear&lt;br /&gt;Dim datestamp, dcDiagReport, netDiagReport, repAdminReport&lt;br /&gt;Dim statlog, errorCount&lt;br /&gt;errorCount = 0&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' diagnostics status display&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub DebugPrint(code, strval)&lt;br /&gt;    If DebugMode Then&lt;br /&gt;        wscript.echo Now &amp;amp; vbTab &amp;amp; code &amp;amp; vbTab &amp;amp; strval&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' run DCDIAG report&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub RunDCDiag()&lt;br /&gt;    Dim cmdstr&lt;br /&gt;    cmdstr = &amp;quot;%comspec% /c dcdiag &amp;gt;&amp;quot; &amp;amp; dcDiagReport&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;&amp;quot; &amp;amp; cmdstr&lt;br /&gt;    objShell.Run cmdstr, 1, True&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;dcdiag process completed.&amp;quot;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' run NETDIAG report&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub RunNetDiag()&lt;br /&gt;    Dim cmdstr&lt;br /&gt;    cmdstr = &amp;quot;%comspec% /c netdiag &amp;gt;&amp;quot; &amp;amp; netDiagReport&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;&amp;quot; &amp;amp; cmdstr&lt;br /&gt;    objShell.Run cmdstr, 1, True&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;netdiag process completed.&amp;quot;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' run REPADMIN /SHOWREPS report&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub RunRepAdmin()&lt;br /&gt;    Dim cmdstr&lt;br /&gt;    cmdstr = &amp;quot;%comspec% /c repadmin /showreps &amp;gt;&amp;quot; &amp;amp; repAdminReport&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;&amp;quot; &amp;amp; cmdstr&lt;br /&gt;    objShell.Run cmdstr, 1, True&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;repadmin process completed.&amp;quot;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' upload report files to remote collection point&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub CollectReports()&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;uploading reports to remote collection point...&amp;quot;&lt;br /&gt;    &lt;br /&gt;    If bRunDCDIAG Then&lt;br /&gt;        If objFSO.FileExists(dcDiagReport) Then&lt;br /&gt;            DebugPrint &amp;quot;info&amp;quot;, &amp;quot;uploading dcdiag report to collection point...&amp;quot;&lt;br /&gt;            'debugprint &amp;quot;*** &amp;quot; &amp;amp; dcDiagReport&lt;br /&gt;            objFSO.CopyFile dcDiagReport, collectionFolder, True&lt;br /&gt;            If DeleteTempFiles = True Then&lt;br /&gt;                DebugPrint &amp;quot;info&amp;quot;, &amp;quot;deleting local dcdiag report file...&amp;quot;&lt;br /&gt;                objFSO.DeleteFile dcDiagReport&lt;br /&gt;            End If&lt;br /&gt;            DebugPrint &amp;quot;info&amp;quot;, &amp;quot;dcdiag report uploaded successfully.&amp;quot;&lt;br /&gt;            DebugPrint &amp;quot;info&amp;quot;, &amp;quot;collection-point: &amp;quot; &amp;amp; collectionFolder&lt;br /&gt;            statlog = statlog &amp;amp; vbCRLF &amp;amp; &amp;quot;dcdiag report uploaded successfully.&amp;quot;&lt;br /&gt;        Else&lt;br /&gt;            statlog = statlog &amp;amp; vbCRLF &amp;amp; &amp;quot;error: dcdiag report failure!&amp;quot;&lt;br /&gt;            DebugPrint &amp;quot;error&amp;quot;, &amp;quot;dcdiag report file not found.&amp;quot;&lt;br /&gt;            errorCount = errorCount + 1&lt;br /&gt;        End If&lt;br /&gt;    End If&lt;br /&gt;&lt;br /&gt;    If bRunNETDIAG Then&lt;br /&gt;        If objFSO.FileExists(netDiagReport) Then&lt;br /&gt;            DebugPrint &amp;quot;info&amp;quot;, &amp;quot;uploading netdiag report to collection point...&amp;quot;&lt;br /&gt;            objFSO.CopyFile netDiagReport, collectionFolder, True&lt;br /&gt;            If DeleteTempFiles = True Then&lt;br /&gt;                DebugPrint &amp;quot;info&amp;quot;, &amp;quot;deleting local netdiag report file...&amp;quot;&lt;br /&gt;                objFSO.DeleteFile netDiagReport&lt;br /&gt;            End If&lt;br /&gt;            DebugPrint &amp;quot;info&amp;quot;, &amp;quot;netdiag report uploaded successfully.&amp;quot;&lt;br /&gt;            DebugPrint &amp;quot;info&amp;quot;, &amp;quot;collection-point: &amp;quot; &amp;amp; collectionFolder&lt;br /&gt;            statlog = statlog &amp;amp; vbCRLF &amp;amp; &amp;quot;netdiag report uploaded successfully.&amp;quot;&lt;br /&gt;        Else&lt;br /&gt;            statlog = statlog &amp;amp; vbCRLF &amp;amp; &amp;quot;error: netdiag report failure!&amp;quot;&lt;br /&gt;            DebugPrint &amp;quot;error&amp;quot;, &amp;quot;netdiag report file not found.&amp;quot;&lt;br /&gt;            errorCount = errorCount + 1&lt;br /&gt;        End If&lt;br /&gt;    End If&lt;br /&gt;&lt;br /&gt;    If bRunREPADMIN Then&lt;br /&gt;        If objFSO.FileExists(repAdminReport) Then&lt;br /&gt;            DebugPrint &amp;quot;info&amp;quot;, &amp;quot;uploading repadmin report to collection point...&amp;quot;&lt;br /&gt;            objFSO.CopyFile repAdminReport, collectionFolder, True&lt;br /&gt;            If DeleteTempFiles = True Then&lt;br /&gt;                DebugPrint &amp;quot;info&amp;quot;, &amp;quot;deleting local repadmin report file...&amp;quot;&lt;br /&gt;                objFSO.DeleteFile repAdminReport&lt;br /&gt;            End If&lt;br /&gt;            DebugPrint &amp;quot;info&amp;quot;, &amp;quot;repadmin report uploaded successfully.&amp;quot;&lt;br /&gt;            DebugPrint &amp;quot;info&amp;quot;, &amp;quot;collection-point: &amp;quot; &amp;amp; collectionFolder&lt;br /&gt;            statlog = statlog &amp;amp; vbCRLF &amp;amp; &amp;quot;repadmin report uploaded successfully.&amp;quot;&lt;br /&gt;        Else&lt;br /&gt;            statlog = statlog &amp;amp; vbCRLF &amp;amp; &amp;quot;error: repadmin report failure!&amp;quot;&lt;br /&gt;            DebugPrint &amp;quot;error&amp;quot;, &amp;quot;repadmin report file not found.&amp;quot;&lt;br /&gt;            errorCount = errorCount + 1&lt;br /&gt;        End If&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' send email&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub SendMail(sTo, sFrom, sSubject, sBody, sFormat)&lt;br /&gt;    Dim objMessage&lt;br /&gt;    Set objMessage = CreateObject(&amp;quot;CDO.Message&amp;quot;)&lt;br /&gt;    objMessage.Subject = sSubject&lt;br /&gt;    objMessage.Sender = sFrom&lt;br /&gt;    objMessage.To = sTo&lt;br /&gt;    If sFormat = &amp;quot;TEXT&amp;quot; Then&lt;br /&gt;        objMessage.TextBody = sBody&lt;br /&gt;    Else&lt;br /&gt;        objMessage.HTMLBody = sBody&lt;br /&gt;    End If&lt;br /&gt;    objMessage.Configuration.Fields.Item _&lt;br /&gt;    (&amp;quot;http://schemas.microsoft.com/cdo/configuration/sendusing&amp;quot;) = 2&lt;br /&gt;    objMessage.Configuration.Fields.Item _&lt;br /&gt;    (&amp;quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&amp;quot;) = mailServer&lt;br /&gt;    objMessage.Configuration.Fields.Item _&lt;br /&gt;    (&amp;quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&amp;quot;) = 25&lt;br /&gt;    objMessage.Configuration.Fields.Update&lt;br /&gt;    objMessage.Send&lt;br /&gt;    Set objMessage = Nothing&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;(sendmail) message sent to &amp;quot; &amp;amp; sTo&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' function: return padded string using parameters&lt;br /&gt;'      arg: strval (string - value being padded)&lt;br /&gt;'      arg: intLen (integer - string length to meet)&lt;br /&gt;'      arg: sChar  (string - value to append or prefix to string)&lt;br /&gt;'      arg: sSide  (string - side of string to pad, &amp;quot;L&amp;quot; or &amp;quot;R&amp;quot;)&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Function PadString(strval, intLen, sChar, sSide)&lt;br /&gt;    Dim retval&lt;br /&gt;    retval = Trim(strval)&lt;br /&gt;    Do While Len(retval) &amp;lt; intLen&lt;br /&gt;        If Ucase(sSide) = &amp;quot;L&amp;quot; Then&lt;br /&gt;            retval = sChar &amp;amp; retval&lt;br /&gt;        Else&lt;br /&gt;            retval = retval &amp;amp; sChar&lt;br /&gt;        End If&lt;br /&gt;    Loop&lt;br /&gt;    PadString = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;' main subroutine&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub Main()&lt;br /&gt;    Dim msgSub, msgBody&lt;br /&gt;    Set objShell = Wscript.CreateObject(&amp;quot;Wscript.Shell&amp;quot;)&lt;br /&gt;    Set objFSO = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;&lt;br /&gt;    strServerName = objShell.ExpandEnvironmentStrings(&amp;quot;%computername%&amp;quot;)&lt;br /&gt;    strServerData = &amp;quot;\\&amp;quot; &amp;amp; strServerName &amp;amp; &amp;quot;\&amp;quot; &amp;amp; localShare &amp;amp; &amp;quot;\&amp;quot;&lt;br /&gt;&lt;br /&gt;    statlog = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;    strMonthNum = DatePart(&amp;quot;m&amp;quot;, Now)&lt;br /&gt;    If Len(strMonthNum) = 1 Then&lt;br /&gt;        strMonthNum = &amp;quot;0&amp;quot; &amp;amp; strMonthNum&lt;br /&gt;    End If&lt;br /&gt;&lt;br /&gt;    strDayNum   = DatePart(&amp;quot;d&amp;quot;, Now)&lt;br /&gt;    If Len(strDayNum) = 1 Then&lt;br /&gt;        strDayNum = &amp;quot;0&amp;quot; &amp;amp; strDayNum&lt;br /&gt;    End If&lt;br /&gt;&lt;br /&gt;    strYear     = DatePart(&amp;quot;yyyy&amp;quot;, Now)&lt;br /&gt;    datestamp   = strMonthNum &amp;amp; strDayNum &amp;amp; Right(strYear,2)&lt;br /&gt;&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;datestamp = &amp;quot; &amp;amp; datestamp&lt;br /&gt;    DebugPrint &amp;quot;info&amp;quot;, &amp;quot;servername = &amp;quot; &amp;amp; strServerName&lt;br /&gt;&lt;br /&gt;    If bRunDCDIAG Then&lt;br /&gt;        dcDiagReport   = strServerData &amp;amp; strServerName &amp;amp; &amp;quot;_dcdiag.txt&amp;quot;&lt;br /&gt;        RunDCDiag()&lt;br /&gt;    End If&lt;br /&gt;&lt;br /&gt;    If bRunNETDIAG Then&lt;br /&gt;        netDiagReport  = strServerData &amp;amp; strServerName &amp;amp; &amp;quot;_netdiag.txt&amp;quot;&lt;br /&gt;        RunNetDiag()&lt;br /&gt;    End If&lt;br /&gt;&lt;br /&gt;    If bRunREPADMIN Then&lt;br /&gt;        repAdminReport = strServerData &amp;amp; strServerName &amp;amp; &amp;quot;_repadmin.txt&amp;quot;&lt;br /&gt;        RunRepAdmin()&lt;br /&gt;    End If&lt;br /&gt;&lt;br /&gt;    CollectReports()&lt;br /&gt;&lt;br /&gt;    If SendAlerts = True Then&lt;br /&gt;        If SendOnErrorsOnly = True Then&lt;br /&gt;            ' send alert only when errors occur...&lt;br /&gt;&lt;br /&gt;            If errorCount &amp;gt; 0 Then&lt;br /&gt;                msgSub = &amp;quot;DC Status Check: ERROR - &amp;quot; &amp;amp; strServerName&lt;br /&gt;                msgBody = &amp;quot;DC Status Check: ERROR - &amp;quot; &amp;amp; strServerName &amp;amp; vbCRLF &amp;amp; _&lt;br /&gt;                    &amp;quot;------------------------------&amp;quot; &amp;amp; vbCRLF &amp;amp; _&lt;br /&gt;                    &amp;quot;One or more diagnostic reports could not&amp;quot; &amp;amp; vbCRLF &amp;amp; _&lt;br /&gt;                    &amp;quot;be generated or collected from &amp;quot; &amp;amp; strServerName &amp;amp; vbCRLF &amp;amp; _&lt;br /&gt;                    &amp;quot;------------------------------&amp;quot;&lt;br /&gt;                SendMail alertList, alertFrom, msgSub, msgBody, &amp;quot;TEXT&amp;quot;&lt;br /&gt;            End If&lt;br /&gt;        Else&lt;br /&gt;          ' send alert for any status, not just errors...&lt;br /&gt;&lt;br /&gt;            msgsub = &amp;quot;DC Status Check: SUCCESS - &amp;quot; &amp;amp; strServerName&lt;br /&gt;            If bVerbose Then&lt;br /&gt;                msgbody = strServerName &amp;amp; &amp;quot; Diagnostics Process Report&amp;quot; &amp;amp; vbCRLF &amp;amp; _&lt;br /&gt;                    &amp;quot;----------------------------&amp;quot; &amp;amp; vbCRLF &amp;amp; _&lt;br /&gt;                    &amp;quot;Diagnostics reports have been processed on this &amp;quot; &amp;amp; _&lt;br /&gt;                    &amp;quot;domain controller with the following results. &amp;quot; &amp;amp; _&lt;br /&gt;                    &amp;quot;Reports have been uploaded to the central collection &amp;quot; &amp;amp; _&lt;br /&gt;                    &amp;quot;point for further processing.&amp;quot; &amp;amp; vbCRLF &amp;amp; _&lt;br /&gt;                    &amp;quot;----------------------------&amp;quot; &amp;amp; vbCRLF &amp;amp; statlog&lt;br /&gt;            Else&lt;br /&gt;                msgbody = strServerName &amp;amp; &amp;quot; Diagnostics Process Report&amp;quot; &amp;amp; vbCRLF &amp;amp; _&lt;br /&gt;                    &amp;quot;----------------------------&amp;quot; &amp;amp; vbCRLF &amp;amp; _&lt;br /&gt;                    &amp;quot;Diagnostics reports were uploaded successfully.&amp;quot;&lt;br /&gt;            End If&lt;br /&gt;            SendMail alertList, alertFrom, msgSub, msgBody, &amp;quot;TEXT&amp;quot;&lt;br /&gt;        End If&lt;br /&gt;    End If&lt;br /&gt;&lt;br /&gt;    Set objFSO = Nothing&lt;br /&gt;    Set objShell = Nothing&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'--------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Call Main()&lt;br /&gt;&lt;br /&gt;wscript.Quit&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6387956468589303587?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6387956468589303587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/06/automating-domain-controller.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6387956468589303587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6387956468589303587'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/06/automating-domain-controller.html' title='Automating Domain Controller Diagnostics, Version 2.0'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7848427019911846621</id><published>2010-05-29T14:16:00.001-07:00</published><updated>2010-05-29T14:16:54.350-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thoughts'/><title type='text'>All Dried Up?</title><content type='html'>&lt;p&gt;I haven’t forgotten about this blog.&amp;#160; But I have been struggling to rationalize its existence in the face of so many great scripting blogs out there.&amp;#160; I thought a unique and possibly helpful niche would be inter-language scripting.&amp;#160; Hence the scripts which leverage two or more languages to accomplish a single task or goal.&amp;#160; But it doesn’t seem this is of much use to anyone.&amp;#160; Indeed, after looking at it several times, it looks more like an oddity or some exercise in cleverness, rather than something of geniune use to anyone.&amp;#160; If you can think of something that might help focus this I’m all ears.&amp;#160; Otherwise, I’m just going to let this blog ferment for a while on its own.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7848427019911846621?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7848427019911846621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/05/all-dried-up.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7848427019911846621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7848427019911846621'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/05/all-dried-up.html' title='All Dried Up?'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5088057768538555424</id><published>2010-04-05T13:51:00.001-07:00</published><updated>2010-04-05T13:52:04.066-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='formatting'/><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='scriptcontrol'/><title type='text'>Converting “YYYYMMDDHHMMSS” Dates</title><content type='html'>&lt;p&gt;Sometimes you end up dealing with date values which are in the form of “YYYYMMDDHHMMSS:00000-GMT” (where “GMT” is a multiple of hours * 60 deviation from Greenwich Mean Time).&amp;#160; Formatting those into usable date values can be done several ways.&amp;#160; This is just one way.&amp;#160; And I threw in a somewhat not-so-obvious KiXtart version of this function for the hell of it.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;VBScript version&lt;/strong&gt;&lt;/p&gt;  &lt;pre style="color: blue"&gt;Function mDate(strDate, format)&lt;br /&gt;    Dim tmp, retval&lt;br /&gt;    On Error Resume Next&lt;br /&gt;    Select Case Lcase(format)&lt;br /&gt;        Case &amp;quot;short&amp;quot;:&lt;br /&gt;            tmp = Mid(strDate, 5, 2) &amp;amp; &amp;quot;/&amp;quot; &amp;amp; _&lt;br /&gt;                Mid(strDate, 7, 2) &amp;amp; &amp;quot;/&amp;quot; &amp;amp; _&lt;br /&gt;                Left(strDate,4)&lt;br /&gt;            retval = FormatDateTime(tmp, vbShortDate)&lt;br /&gt;        Case &amp;quot;datetime&amp;quot;:&lt;br /&gt;            tmp = Mid(strDate, 5, 2) &amp;amp; &amp;quot;/&amp;quot; &amp;amp; _&lt;br /&gt;                Mid(strDate, 7, 2) &amp;amp; &amp;quot;/&amp;quot; &amp;amp; _&lt;br /&gt;                Left(strDate,4) &amp;amp; &amp;quot; &amp;quot; &amp;amp; _&lt;br /&gt;                Mid(strDate, 9, 2) &amp;amp; &amp;quot;:&amp;quot; &amp;amp; _&lt;br /&gt;                Mid(strDate, 11, 2) &amp;amp; &amp;quot;:&amp;quot; &amp;amp; _&lt;br /&gt;                Mid(strDate, 13, 2)&lt;br /&gt;            retval = FormatDateTime(tmp, vbShortDate) &amp;amp; &amp;quot; &amp;quot; &amp;amp; _&lt;br /&gt;            FormatDateTime(tmp, vbLongTime)&lt;br /&gt;        Case &amp;quot;long&amp;quot;:&lt;br /&gt;            tmp = Mid(strDate, 5, 2) &amp;amp; &amp;quot;/&amp;quot; &amp;amp; _&lt;br /&gt;                Mid(strDate, 7, 2) &amp;amp; &amp;quot;/&amp;quot; &amp;amp; _&lt;br /&gt;                Left(strDate,4) &amp;amp; &amp;quot; &amp;quot; &amp;amp; _&lt;br /&gt;                Mid(strDate, 9, 2) &amp;amp; &amp;quot;:&amp;quot; &amp;amp; _&lt;br /&gt;                Mid(strDate, 11, 2) &amp;amp; &amp;quot;:&amp;quot; &amp;amp; _&lt;br /&gt;                Mid(strDate, 13, 2)&lt;br /&gt;            retval = FormatDateTime(tmp, vbLongDate)&lt;br /&gt;    End Select&lt;br /&gt;    mDate = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;wscript.echo mDate(&amp;quot;20100305132705.00000-520&amp;quot;, &amp;quot;short&amp;quot;)&lt;br /&gt;wscript.echo mDate(&amp;quot;20100305132705.00000-520&amp;quot;, &amp;quot;long&amp;quot;)&lt;br /&gt;wscript.echo mDate(&amp;quot;20100305132705.00000-520&amp;quot;, &amp;quot;datetime&amp;quot;)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;KiXtart Version&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: green"&gt;Function FormatDateTime($v, $f)&lt;br /&gt;    Dim $sc, $result&lt;br /&gt;    $sc = CreateObject(&amp;quot;ScriptControl&amp;quot;)&lt;br /&gt;    $sc.Language = &amp;quot;vbscript&amp;quot;&lt;br /&gt;    $result = $sc.Eval('FormatDateTime(&amp;quot;'+$v+'&amp;quot;,'+$f+')')&lt;br /&gt;    $sc = 0&lt;br /&gt;    $FormatDateTime = $result&lt;br /&gt;EndFunction&lt;br /&gt;&lt;br /&gt;Function mDate($strDate, $format)&lt;br /&gt;    Dim $tmp, $retval&lt;br /&gt;    Select&lt;br /&gt;        Case $format = &amp;quot;short&amp;quot;&lt;br /&gt;            $tmp = Substr($strDate, 5, 2) + &amp;quot;/&amp;quot; +&lt;br /&gt;                Substr($strDate, 7, 2) + &amp;quot;/&amp;quot; +&lt;br /&gt;                Left($strDate,4)&lt;br /&gt;                $retval = $tmp&lt;br /&gt;        Case Lcase($format) = &amp;quot;datetime&amp;quot;&lt;br /&gt;            $tmp = Substr($strDate, 5, 2) + &amp;quot;/&amp;quot; +&lt;br /&gt;                Substr($strDate, 7, 2) + &amp;quot;/&amp;quot; +&lt;br /&gt;                Left($strDate,4) + &amp;quot; &amp;quot; +&lt;br /&gt;                Substr($strDate, 9, 2) + &amp;quot;:&amp;quot; +&lt;br /&gt;                Substr($strDate, 11, 2) + &amp;quot;:&amp;quot; +&lt;br /&gt;                Substr($strDate, 13, 2)&lt;br /&gt;            $retval = $tmp&lt;br /&gt;        Case Lcase($format) = &amp;quot;long&amp;quot;&lt;br /&gt;            $tmp = Substr($strDate, 5, 2) + &amp;quot;/&amp;quot; +&lt;br /&gt;                Substr($strDate, 7, 2) + &amp;quot;/&amp;quot; +&lt;br /&gt;                Left($strDate,4)&lt;br /&gt;                $tmp = FormatDateTime($tmp, &amp;quot;vbLongDate&amp;quot;)&lt;br /&gt;            $retval = $tmp&lt;br /&gt;    EndSelect&lt;br /&gt;    $mDate = $retval&lt;br /&gt;EndFunction&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;? mDate(&amp;quot;20100305132705.00000-520&amp;quot;, &amp;quot;short&amp;quot;)&lt;br /&gt;? mDate(&amp;quot;20100305132705.00000-520&amp;quot;, &amp;quot;long&amp;quot;)&lt;br /&gt;? mDate(&amp;quot;20100305132705.00000-520&amp;quot;, &amp;quot;datetime&amp;quot;)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Yes, the KiXtart version is somewhat “cheating” but who cares.&amp;#160; It works, and it saves me a little bit of coding.&amp;#160; The performance overhead delta is near-zero, unless you’re running on 1990’s hardware.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5088057768538555424?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5088057768538555424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/04/converting-yyyymmddhhmmss-dates.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5088057768538555424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5088057768538555424'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/04/converting-yyyymmddhhmmss-dates.html' title='Converting “YYYYMMDDHHMMSS” Dates'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6224920326021980242</id><published>2010-03-30T18:42:00.001-07:00</published><updated>2010-03-30T18:42:49.144-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='thoughts'/><category scheme='http://www.blogger.com/atom/ns#' term='editorial'/><title type='text'>A Portable LISP Interpreter?</title><content type='html'>&lt;p&gt;The very first programming language I touched was GW-BASIC, then COBOL, then QBASIC, then FORTRAN, then LISP and PASCAL and C++ and Java, and on to newer things like Visual Basic, ASP, PHP and Javascript, XSLT and so on.&amp;#160; In that chronological order, actually.&amp;#160; But of all those, the one that grabs my attention when I hear its name spoken is LISP.&amp;#160; I spent almost 15 years focusing my programming time on AutoLISP, Visual LISP and dabbling quite a lot with Franz, XLISP and CLOS, but kept going back to Visual LISP (or “VLISP”) because of it’s strong association with graphical environments (AutoCAD).&amp;#160; The combination that Vital LISP brought to the table from the work of Basis Software, later acquired by Autodesk, opened up a whole new world for joining the flexibility and power of AutoLISP with the COM fabric exposed by Windows.&lt;/p&gt;  &lt;p&gt;I always loved the way AutoCAD and the VLISP engine provided the substrate for running scripts within AutoCAD much like how Java apps run on the JRE or how PowerShell runs on .NET CLR.&amp;#160; But actually, it dawned on me that a more ideal solution is what you get with KiXtart.&amp;#160; The engine is self-contained and extremely lean and responsive.&amp;#160; Robust and Streamlined, would be two words I would use to describe it.&amp;#160; &lt;/p&gt;  &lt;p&gt;Unlike WSH or PowerShell, you don’t have to install anything in order to start executing KiXtart scripts.&amp;#160; You just need access to the Kix32.exe runtime and it just “goes”.&amp;#160; The runtime can be across the network and you can even invoke a local script using a UNC path to the runtime.&amp;#160; It’s ridiculously easy to sit a computer “A”, and run a script sitting on computer “B” using the Kix32.exe on computer “C”, and it works fine.&amp;#160; Ruud van Velsen indeed deserves accolades for not only making this work so well, but for maintaining the vision and direction that keeps it alive today.&amp;#160; Indeed, the KiXtart community is as strong as ever and the online presence is simply amazing.&lt;/p&gt;  &lt;p&gt;Why couldn’t there by a similar approach to a LISP runtime?&amp;#160; Is there such a thing?&amp;#160; Every LISP runtime I’ve seen requires labor to set up and there’s the added issues of which dialect is used (XLISP, Franz, Common, NewLISP, etc.).&amp;#160; A stripped-down core library would be fantastic.&amp;#160; Something like AutoLISP but without the AutoCAD-specific functions.&amp;#160; Replace those with added file system, registry, environment, process and WMI interfaces, and the rest tied to COM or even .NET, and, well, geez.&amp;#160; I’d be happy.&amp;#160; I wish I had time to build such a beast.&amp;#160; If anyone has a project going on this, I’d be more than happy to help you test it out and provide feedback.&amp;#160; I’m sure this is a tall order though.&amp;#160; &lt;/p&gt;  &lt;p&gt;Just a thought.&amp;#160; Ok, I’m going to bed now.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6224920326021980242?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6224920326021980242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/portable-lisp-interpreter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6224920326021980242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6224920326021980242'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/portable-lisp-interpreter.html' title='A Portable LISP Interpreter?'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-659157386938530937</id><published>2010-03-30T18:27:00.001-07:00</published><updated>2010-03-30T18:27:01.294-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='arrays'/><title type='text'>Splitting the Splitter</title><content type='html'>&lt;p&gt;Here’s a cute little oafish trick that has helped me out more than a few times.&amp;#160; You run an inline Split/Array operation to mimic what the LISP &lt;strong&gt;cdr&lt;/strong&gt; and &lt;strong&gt;cadr&lt;/strong&gt;, etc. functions do, which is to pick out a logical subordinate within a string construct which represents a paired list (logically speaking).&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;&lt;p&gt;myString = &lt;font color="#408080"&gt;“1=Apple,2=Banana,3=Cherry,4=Grapes”&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;item2 = &lt;font color="#ff00ff"&gt;Split&lt;/font&gt;(&lt;font color="#ff00ff"&gt;Split&lt;/font&gt;(myString, &lt;font color="#408080"&gt;“,”&lt;/font&gt;)(&lt;font color="#ff0000"&gt;1&lt;/font&gt;), &lt;font color="#408080"&gt;“=”&lt;/font&gt;)(&lt;font color="#ff0000"&gt;1&lt;/font&gt;)&lt;/p&gt;&lt;/pre&gt;&lt;br /&gt;This will return &lt;font color="#408080"&gt;“Banana”&lt;/font&gt;.&amp;#160; You can continue nesting (or un-nesting, if you will) obviously, but without error checking this can become quite dangerous.&amp;#160; But it is nice to see a use for something like this.&amp;#160; Now, if only there were a simple, easy way to mimic &lt;strong&gt;mapcar&lt;/strong&gt; and &lt;strong&gt;apply&lt;/strong&gt; as well.  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-659157386938530937?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/659157386938530937/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/splitting-splitter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/659157386938530937'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/659157386938530937'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/splitting-splitter.html' title='Splitting the Splitter'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5936523918866898584</id><published>2010-03-18T13:10:00.001-07:00</published><updated>2010-03-18T13:10:46.774-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='scheduling'/><category scheme='http://www.blogger.com/atom/ns#' term='inventory'/><title type='text'>Query Scheduled Tasks The Hard Way</title><content type='html'>Because the CIM/WMI model is still an unfinished work in progress, I’ve once again had to resort to making some ugly crap code to work around a giant hole in the model. In this case it’s the lack of a model counterpart to the Scheduled Tasks collection.&amp;#160; This is NOT the same as the Win32_ScheduledJobs or the AT command output.&amp;#160; I’m talking about SCHTASKS.exe and the Windows Scheduled Tasks utility.&amp;#160; Anyhow, the klunky workaround here is to ride the SCHTASKS command like a whipping boy and make it dump a text file, then turn around and do a crude (but effective) string parsing and crank it out in XML form.&amp;#160; Enjoy.   &lt;pre style="color: blue; font-size: 9pt"&gt;'****************************************************************&lt;br /&gt;' Filename..: xml_scheduled_tasks.vbs&lt;br /&gt;' Author....: David M. Stein&lt;br /&gt;' Date......: 03/18/2010&lt;br /&gt;' Purpose...: query Scheduled Tasks (not WMI/Jobs/AT) --&amp;gt; XML out&lt;br /&gt;'****************************************************************&lt;br /&gt;&lt;br /&gt;Const tempfile = &amp;quot;c:\temp\schtasks.txt&amp;quot;&lt;br /&gt;Const computer = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;Const ForReading = 1&lt;br /&gt;Const ForWriting = 2&lt;br /&gt;&lt;br /&gt;Set objShell = CreateObject(&amp;quot;Wscript.Shell&amp;quot;)&lt;br /&gt;Set objFSO = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;&lt;br /&gt;If computer &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;    cmdstr = &amp;quot;cmd /c schtasks /query /s \\&amp;quot; &amp;amp; computer &amp;amp; &amp;quot; /v /fo list &amp;gt;&amp;quot; &amp;amp; tempfile&lt;br /&gt;Else&lt;br /&gt;    cmdstr = &amp;quot;cmd /c schtasks /query /v /fo list &amp;gt;&amp;quot; &amp;amp; tempfile&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;retval = objShell.Run(cmdstr, 1, True)&lt;br /&gt;&lt;br /&gt;If objFSO.FileExists(tempfile) Then&lt;br /&gt;    Dim linecount, objFSO, objFile, ln, strLine&lt;br /&gt;&lt;br /&gt;    linecount = 0 &lt;br /&gt;    wscript.echo &amp;quot;&lt;jobs&gt;&amp;quot;&lt;br /&gt; &lt;br /&gt;    Set objFile = objFSO.OpenTextFile(tempfile, ForReading)&lt;br /&gt;    Do Until objFile.AtEndOfStream&lt;br /&gt;        strLine = Trim(objFile.Readline)&lt;br /&gt;     &lt;br /&gt;        If Left(strLine, 9) = &amp;quot;HostName:&amp;quot; Then&lt;br /&gt;            hostname = Mid(strLine, 39)&lt;br /&gt;            wscript.echo vbTab &amp;amp; &amp;quot;&lt;job&gt;&amp;quot;&lt;br /&gt;     &lt;br /&gt;        ElseIf Left(strLine, 9) = &amp;quot;TaskName:&amp;quot; Then&lt;br /&gt;            wscript.echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&lt;name&gt;&amp;quot; &amp;amp; Mid(strLine, 39) &amp;amp; &amp;quot;&lt;/name&gt;&amp;quot;&lt;br /&gt;            wscript.echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&lt;host&gt;&amp;quot; &amp;amp; hostname &amp;amp; &amp;quot;&lt;/host&gt;&amp;quot;&lt;br /&gt;     &lt;br /&gt;        ElseIf Left(strLine, 15) = &amp;quot;Scheduled Type:&amp;quot; Then&lt;br /&gt;            wscript.echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&lt;period&gt;&amp;quot; &amp;amp; Mid(strLine, 39) &amp;amp; &amp;quot;&lt;/period&gt;&amp;quot;&lt;br /&gt;     &lt;br /&gt;        ElseIf Left(strLine, 9) = &amp;quot;Schedule:&amp;quot; Then&lt;br /&gt;            wscript.echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&lt;schedule&gt;&amp;quot; &amp;amp; Mid(strLine, 39) &amp;amp; &amp;quot;&lt;/schedule&gt;&amp;quot;&lt;br /&gt;        &lt;br /&gt;        ElseIf Left(strLine, 12) = &amp;quot;Task To Run:&amp;quot; Then&lt;br /&gt;            wscript.echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&lt;task&gt;&amp;quot; &amp;amp; Mid(strLine, 39) &amp;amp; &amp;quot;&lt;/task&gt;&amp;quot;&lt;br /&gt;        &lt;br /&gt;        ElseIf Left(strLine, 8) = &amp;quot;Comment:&amp;quot; Then&lt;br /&gt;            wscript.echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&lt;comment&gt;&amp;quot; &amp;amp; Mid(strLine, 39) &amp;amp; &amp;quot;&lt;/comment&gt;&amp;quot;&lt;br /&gt;        &lt;br /&gt;        ElseIf Left(strLine, 12) = &amp;quot;Run As User:&amp;quot; Then&lt;br /&gt;            wscript.echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&lt;runas&gt;&amp;quot; &amp;amp; Mid(strLine, 39) &amp;amp; &amp;quot;&lt;/runas&gt;&amp;quot;&lt;br /&gt;        &lt;br /&gt;        ElseIf Left(strLine, 11) = &amp;quot;Start Time:&amp;quot; Then&lt;br /&gt;            wscript.echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&lt;timestart&gt;&amp;quot; &amp;amp; Mid(strLine, 39) &amp;amp; &amp;quot;&lt;/timestart&gt;&amp;quot;&lt;br /&gt;        &lt;br /&gt;        ElseIf Left(strLine, 11) = &amp;quot;Start Date:&amp;quot; Then&lt;br /&gt;            wscript.echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&lt;datestart&gt;&amp;quot; &amp;amp; Mid(strLine, 39) &amp;amp; &amp;quot;&lt;/datestart&gt;&amp;quot;&lt;br /&gt;        &lt;br /&gt;        ElseIf Left(strLine, 17) = &amp;quot;Power Management:&amp;quot; Then&lt;br /&gt;            wscript.echo vbTab &amp;amp; &amp;quot;&lt;/job&gt;&amp;quot;&lt;br /&gt;      &lt;br /&gt;        End If&lt;br /&gt;        linecount = linecount + 1&lt;br /&gt;     &lt;br /&gt;    Loop&lt;br /&gt;    objFile.Close&lt;br /&gt;    Set objFSO = Nothing&lt;br /&gt; &lt;br /&gt;    wscript.echo &amp;quot;&lt;/jobs&gt;&amp;quot;&lt;br /&gt; &lt;br /&gt;Else&lt;br /&gt;    wscript.echo &amp;quot;fail: file not found&amp;quot;&lt;br /&gt;End If&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5936523918866898584?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5936523918866898584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/query-scheduled-tasks-hard-way.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5936523918866898584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5936523918866898584'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/query-scheduled-tasks-hard-way.html' title='Query Scheduled Tasks The Hard Way'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6506870264603077005</id><published>2010-03-04T19:18:00.001-08:00</published><updated>2010-03-04T19:20:59.141-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='shortcuts'/><category scheme='http://www.blogger.com/atom/ns#' term='inventory'/><title type='text'>VBScript: Enumerate Start Menu Shortcuts into XML</title><content type='html'>Here's a little script to dump a list of all shortcuts and their internal properties, which exist under the “All Users” profile, in Start Menu\Programs, as well as all sub-folders below that.&amp;#160; The output is basic raw XML.&amp;#160; Not much to it, but I had to crank this out for a special project I worked on a few weeks ago and thought I’d post it here.   &lt;pre style="font-family: courier new; color: blue; font-site: 9pt"&gt;'****************************************************************&lt;br /&gt;' Filename..: enum_allusers_shortcuts.vbs&lt;br /&gt;' Author....: skatterbrainz&lt;br /&gt;' Date......: 02/03/2010&lt;br /&gt;' Purpose...: enumerate shortcuts under all-users start menu (xml)&lt;br /&gt;'****************************************************************&lt;br /&gt;Dim objShell, allUsers, allStart, objFSO, oFolder, s&lt;br /&gt;&lt;br /&gt;Set objShell = CreateObject(&amp;quot;Wscript.Shell&amp;quot;)&lt;br /&gt;Set objFSO = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;&lt;br /&gt;allUsers = objShell.ExpandEnvironmentStrings(&amp;quot;%AllUsersProfile%&amp;quot;)&lt;br /&gt;allStart = allUsers &amp;amp; &amp;quot;\Start Menu\Programs&amp;quot;&lt;br /&gt;&lt;br /&gt;Set oFolder = objFSO.GetFolder(allStart)&lt;br /&gt;&lt;br /&gt;wscript.echo &amp;quot;&amp;lt;shortcuts&amp;gt;&lt;shortcuts&gt;&amp;quot;&lt;br /&gt;For each s in oFolder.SubFolders&lt;br /&gt; ListShortcuts objFSO.GetFolder(allStart &amp;amp; &amp;quot;\&amp;quot; &amp;amp; s.Name)&lt;br /&gt;Next&lt;br /&gt;wscript.echo &amp;quot;&amp;lt;/shortcuts&amp;gt;&lt;/shortcuts&gt;&amp;quot;&lt;br /&gt;&lt;br /&gt;Sub ListShortcuts(objFolder)&lt;br /&gt; Dim objFile, filename&lt;br /&gt; For each objFile in objFolder.Files&lt;br /&gt;  filename = objFile.Name&lt;br /&gt;  If Right(Lcase(filename),4) = &amp;quot;.lnk&amp;quot; Then&lt;br /&gt;   filepath = objFolder.Path &amp;amp; &amp;quot;\&amp;quot; &amp;amp; filename&lt;br /&gt;   wscript.echo vbTab &amp;amp; &amp;quot;&amp;lt;shortcut&amp;gt;&lt;shortcut  ??? &amp; filename ? name=""&gt;&amp;quot;&lt;br /&gt;   ShortcutProps filepath&lt;br /&gt;   wscript.echo vbTab &amp;amp; &amp;quot;&amp;lt;/shortcut&amp;gt;&lt;/shortcut&gt;&amp;quot;&lt;br /&gt;  End If&lt;br /&gt; Next&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Sub ShortcutProps(scName)&lt;br /&gt; Dim objShortcut&lt;br /&gt; If objFSO.FileExists(scName) Then&lt;br /&gt;  Set objShortcut = objShell.CreateShortcut(scName)&lt;br /&gt;  WScript.Echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&amp;lt;fullname&amp;gt;&lt;fullname&gt;&amp;quot; &amp;amp; objShortcut.FullName &amp;amp; &amp;quot;&amp;lt;/fullname&amp;gt;&lt;/fullname&gt;&amp;quot;&lt;br /&gt;  WScript.Echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&amp;lt;arguments&amp;gt;&lt;arguments&gt;&amp;quot; &amp;amp; objShortcut.Arguments &amp;amp; &amp;quot;&amp;lt;/arguments&amp;gt;&lt;/arguments&gt;&amp;quot;&lt;br /&gt;  WScript.Echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&amp;lt;workingpath&amp;gt;&lt;working&gt;&amp;quot; &amp;amp; objShortcut.WorkingDirectory &amp;amp; &amp;quot;&amp;lt;/workingpath&amp;gt;&lt;/working&gt;&amp;quot;&lt;br /&gt;  WScript.Echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&amp;lt;target&amp;gt;&lt;target&gt;&amp;quot; &amp;amp; objShortcut.TargetPath &amp;amp; &amp;quot;&amp;lt;/target&amp;gt;&lt;/target&gt;&amp;quot;&lt;br /&gt;  WScript.Echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&amp;lt;icon&amp;gt;&lt;icon&gt;&amp;quot; &amp;amp; objShortcut.IconLocation &amp;amp; &amp;quot;&amp;lt;/icon&amp;gt;&lt;/icon&gt;&amp;quot;&lt;br /&gt;  WScript.Echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&amp;lt;hotkey&amp;gt;&lt;hotkey&gt;&amp;quot; &amp;amp; objShortcut.Hotkey &amp;amp; &amp;quot;&amp;lt;/hotkey&amp;gt;&lt;/hotkey&gt;&amp;quot;&lt;br /&gt;  WScript.Echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&amp;lt;windowstyle&amp;gt;&lt;windowstyle&gt;&amp;quot; &amp;amp; objShortcut.WindowStyle &amp;amp; &amp;quot;&amp;lt;/windowstyle&amp;gt;&lt;/windowstyle&gt;&amp;quot;&lt;br /&gt;  WScript.Echo vbTab &amp;amp; vbTab &amp;amp; &amp;quot;&amp;lt;comment&amp;gt;&lt;description&gt;&amp;quot; &amp;amp; objShortcut.Description &amp;amp; &amp;quot;&amp;lt;/comment&amp;gt;&lt;/description&gt;&amp;quot;&lt;br /&gt;  Set objShortcut = Nothing&lt;br /&gt; Else&lt;br /&gt;  wscript.echo &amp;quot;unable to find shortcut&amp;quot;&lt;br /&gt; End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Set oFolder  = Nothing&lt;br /&gt;Set objFSO   = Nothing&lt;br /&gt;Set objShell = Nothing&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6506870264603077005?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6506870264603077005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/vbscript-enumerate-start-menu-shortcuts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6506870264603077005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6506870264603077005'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/vbscript-enumerate-start-menu-shortcuts.html' title='VBScript: Enumerate Start Menu Shortcuts into XML'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7612472509126932728</id><published>2010-03-02T17:28:00.001-08:00</published><updated>2010-03-02T17:28:07.252-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='formatting'/><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='COM'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='arrays'/><category scheme='http://www.blogger.com/atom/ns#' term='scriptcontrol'/><title type='text'>Now vs Now: VBScript and KiXtart</title><content type='html'>&lt;p&gt;Date values are a very common aspect to script writing and most any programming situation in general.&amp;#160; How dates are stored, presented and manipulated varies widely from one programming language to another.&lt;/p&gt;  &lt;p&gt;Let’s look at the “Now” function included with Windows Scripting Host’s VBScript.&amp;#160; This function returns the current date and time in “mM/dD/YYYY hH:MM:SS XM” format.&lt;/p&gt;  &lt;p&gt;In case you’re wondering what the hell “mM” and “hH” imply: they imply zero-trim numbers.&amp;#160; In other words 8:01:42 AM is not stored as 08:01:42 AM. The leading zero is omitted.&amp;#160; Same for month (“mM”), and day (“dD”) as well.&lt;/p&gt;  &lt;p&gt;But &lt;a href="http://www.kixtart.org" target="_blank"&gt;KiXtart&lt;/a&gt;, one of my all-time favorite scripting languages, handles date values quite differently.&amp;#160; At first it may seem almost identical, but as you pick things apart you start to see the deltas.&lt;/p&gt;  &lt;pre style="font-family: courier new; color: blue; font-size: 9pt"&gt;(kixtart)&lt;br /&gt;? @date+&amp;quot; &amp;quot;+@time&lt;br /&gt;&amp;gt;&amp;gt; 2010/03/02 08:20:01&lt;br /&gt;&lt;br /&gt;(vbscript)&lt;br /&gt;Wscript.echo Now&lt;br /&gt;&amp;gt;&amp;gt; 3/2/2010 8:20:01 AM&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: courier new; color: blue; font-size: 9pt"&gt;&lt;font color="#333333" size="2" face="Verdana"&gt;When you compare the output of each result above, not only are the order of YYYY/MM/DD flipped from M/D/YYYY, but the zero-trim is not used with KiXtart.  Is this “bad” or “wrong”?  No.  Just different.  There are times when this is actually a very handy benefit to have as the default.  But also notice that the time stamp is formatted differently.  And the AM/PM suffix is not shown.&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: courier new; color: blue; font-size: 9pt"&gt;&lt;font color="#333333" size="2" face="Verdana"&gt;So, how can we make KiXtart do it the way VBScript does it?  This is assuming you need to make it do that, of course, which you may not.  But this is for demonstration purposes, so cut me some slack - if you will.&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: courier new; color: blue; font-size: 9pt"&gt;&lt;font color="#333333" size="2" face="Verdana"&gt;Below are two examples for producing a VBScript formatted “Now” result.  The first one uses a rudimentary date-&amp;gt;string parsing technique.  The second does a cop-out and simply knocks on the door of the ScriptControl COM interface to make VBScript do the work and hand back a result.  The performance overhead is about the same at this scalar load level.  If you start piling in a lot more, the results can shift the balance of performance in either direction, depending upon the nature of what your doing (math, string, date, or object management tasks).&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: courier new; color: blue; font-size: 9pt"&gt;------------------------------------------------&lt;br /&gt;Break ON&lt;br /&gt;&lt;br /&gt;Function Now1()&lt;br /&gt;    $today = &amp;quot;&amp;quot;+@monthno+&amp;quot;/&amp;quot;+@mdayno+&amp;quot;/&amp;quot;+@year&lt;br /&gt;    $arrTime = Split(@time, &amp;quot;:&amp;quot;)&lt;br /&gt;    $hour = $arrTime[0]&lt;br /&gt;    $min  = $arrTime[1]&lt;br /&gt;    $sec  = $arrTime[2]&lt;br /&gt;    If Int($hour) &amp;lt; 12&lt;br /&gt;        $sfx = &amp;quot;AM&amp;quot;&lt;br /&gt;    Else&lt;br /&gt;        $sfx = &amp;quot;PM&amp;quot;&lt;br /&gt;    EndIf&lt;br /&gt;    $Now1 = $today+&amp;quot; &amp;quot;+Int($hour)+&amp;quot;:&amp;quot;+$min+&amp;quot;:&amp;quot;+$sec+&amp;quot; &amp;quot;+$sfx&lt;br /&gt;EndFunction&lt;br /&gt;&lt;br /&gt;Function Now2()&lt;br /&gt;    Dim $sc, $result&lt;br /&gt;    $sc = CreateObject(&amp;quot;ScriptControl&amp;quot;)&lt;br /&gt;    $sc.Language = &amp;quot;vbscript&amp;quot;&lt;br /&gt;    $result = $sc.Eval('Now()')&lt;br /&gt;    $sc = 0&lt;br /&gt;    $Now2 = $result&lt;br /&gt;EndFunction&lt;br /&gt;&lt;br /&gt;? &amp;quot;Kix: &amp;quot;+Now1()&lt;br /&gt;? &amp;quot;VBs: &amp;quot;+Now2()&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The results should be identical.&amp;#160; Could I/you refactor the Now1() function to nest statements and further compact the code?&amp;#160; Sure.&amp;#160; Does it buy any performance gains? Not really.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Consider this variation…&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family: courier new; color: blue; font-size: 9pt"&gt;Function Now1()&lt;br /&gt;    $today = &amp;quot;&amp;quot;+@monthno+&amp;quot;/&amp;quot;+@mdayno+&amp;quot;/&amp;quot;+@year&lt;br /&gt;    $arrTime = Split(@time, &amp;quot;:&amp;quot;)&lt;br /&gt;    If Int($arrTime[0]) &amp;lt; 12&lt;br /&gt;        $Now1 = $today+&amp;quot; &amp;quot;+Int($arrTime[0])+&amp;quot;:&amp;quot;+$arrTime[1]+&amp;quot;:&amp;quot;+&lt;br /&gt;            $arrTime[2]+&amp;quot; AM”&lt;br /&gt;    Else&lt;br /&gt;        $Now1 = $today+&amp;quot; &amp;quot;+Int($arrTime[0])+&amp;quot;:&amp;quot;+$arrTime[1]+&amp;quot;:&amp;quot;+&lt;br /&gt;            $arrTime[2]+&amp;quot; PM”&lt;br /&gt;    EndIf&lt;br /&gt;EndFunction&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;More compact for sure.&amp;#160; But there’s a hidden, even if trivial price: The repeated use of an array index request.&amp;#160; There are other ways to compact/refactor this of course, but for such few lines of code the pay-offs are difficult to justify beyond elegant coding form (aesthetics).&amp;#160; Oh well, blah blah blah.&amp;#160; What do I know anyway.&amp;#160; I just finished a huge “breakfast-for-dinner” and was then told my car repairs would cost way too much, so I’m blabbering to let off steam.&amp;#160; I hope you enjoyed this.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7612472509126932728?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7612472509126932728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/now-vs-now-vbscript-and-kixtart.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7612472509126932728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7612472509126932728'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/03/now-vs-now-vbscript-and-kixtart.html' title='Now vs Now: VBScript and KiXtart'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2354282365260377277</id><published>2010-02-28T06:06:00.001-08:00</published><updated>2010-02-28T06:07:16.390-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='diagnostics'/><category scheme='http://www.blogger.com/atom/ns#' term='COM'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='monitoring'/><category scheme='http://www.blogger.com/atom/ns#' term='reporting'/><title type='text'>Automate DCDiag on your Domain Controllers</title><content type='html'>&lt;p&gt;I’ve been doing this for (literally) years.&amp;#160; About 7 years to be exact.&amp;#160; You can do this with NETDIAG, REPADMIN and several other “diagnostic” utilities that work from the command line.&lt;/p&gt;  &lt;p&gt;The idea is to wrap the diagnostic operation inside a script so that you can capture the output in a text file, then turn around and open the text file to parse it for what you want.&amp;#160; Then you can do almost anything with that information:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Generate a summary report file &lt;/li&gt;    &lt;li&gt;Send the results into a database table &lt;/li&gt;    &lt;li&gt;Send the results as an e-mail report &lt;/li&gt;    &lt;li&gt;and on and on and on… &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;There are several ways to set this up as well.&amp;#160; For this example I’m using a VBScript file, a domain user (aka “service” or “proxy”) account, and the Windows Task Scheduler on a Windows Server 2008 domain controller.&amp;#160; This works just fine on Windows Server 2003 and Windows Server 2008 R2 as well.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Script&lt;/strong&gt;:&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt; font-face: courier new"&gt;Const logFileName = &amp;quot;x:\logs\dcdiag.log&amp;quot;&lt;br /&gt;Const ForReading = 1&lt;br /&gt;Const ForWriting = 2&lt;br /&gt;&lt;br /&gt;Dim objShell, objFSO, computer, domain, cmdstr&lt;br /&gt;Dim objFile, testLabel, passed, failed&lt;br /&gt;&lt;br /&gt;Set objShell = CreateObject(&amp;quot;Wscript.Shell&amp;quot;)&lt;br /&gt;Set objFSO   = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;&lt;br /&gt;computer = Ucase(objShell.ExpandEnvironmentStrings(&amp;quot;%computername%&amp;quot;))&lt;br /&gt;domain   = Ucase(objShell.ExpandEnvironmentStrings(&amp;quot;%userdnsdomain%&amp;quot;))&lt;br /&gt;&lt;br /&gt;cmdstr = &amp;quot;cmd /c dcdiag /v &amp;gt;&amp;quot; &amp;amp; logFileName&lt;br /&gt;&lt;br /&gt;objShell.Run cmdstr, 1, True&lt;br /&gt;&lt;br /&gt;If objFSO.FileExists(logFileName) Then&lt;br /&gt;    passed = 0&lt;br /&gt;    failed = 0&lt;br /&gt;	&lt;br /&gt;    Set objFile = objFSO.OpenTextFile(logFileName, ForReading)&lt;br /&gt;&lt;br /&gt;    Do Until objFile.AtEndOfStream&lt;br /&gt;        strLine = objFile.Readline&lt;br /&gt;    &lt;br /&gt;        testLabel = Mid(strLine, 36)&lt;br /&gt;&lt;br /&gt;        If InStr(1, testLabel, computer &amp;amp; &amp;quot; passed test&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;            wscript.echo testLabel&lt;br /&gt;            passed = passed + 1&lt;br /&gt;        ElseIf InStr(1, testLabel, computer &amp;amp; &amp;quot; failed test&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;            wscript.echo testLabel&lt;br /&gt;            failed = failed + 1&lt;br /&gt;        ElseIf InStr(1, testLabel, domain &amp;amp; &amp;quot; passed test&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;            wscript.echo testLabel&lt;br /&gt;            passed = passed + 1&lt;br /&gt;        ElseIf InStr(1, testLabel, domain &amp;amp; &amp;quot; failed test&amp;quot;) &amp;gt; 0 Then&lt;br /&gt;            wscript.echo testLabel&lt;br /&gt;            failed = failed + 1&lt;br /&gt;        Else&lt;br /&gt;            '&lt;br /&gt;        End If&lt;br /&gt;    Loop&lt;br /&gt;    objFile.Close&lt;br /&gt;    Set objFSO = Nothing&lt;br /&gt;&lt;br /&gt;    wscript.echo &amp;quot;Passed &amp;quot; &amp;amp; passed &amp;amp; &amp;quot; tests&amp;quot;&lt;br /&gt;    wscript.echo &amp;quot;Failed &amp;quot; &amp;amp; failed &amp;amp; &amp;quot; tests&amp;quot;	&lt;br /&gt;Else&lt;br /&gt;    wscript.echo &amp;quot;fail: log file not found&amp;quot;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set objFSO = Nothing&lt;br /&gt;Set objShell = Nothing&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;The Explanation&lt;/strong&gt;:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The top section defines the path and filename for the output file we’re going to capture and analyze.&amp;#160; Next we define some variables.&amp;#160; Then we instantiate the Shell and FileSystemObject object interfaces.&amp;#160; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;We use the Shell object to fetch the name of the computer and the domain name. We need those to help sift through the output file and find the matching lines we want to look at.&amp;#160; The Shell object is also used to run the DCDIAG command via the “Run” method.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;After running the shell command, we then check if the output file exists.&amp;#160; If it does, we open it and read through it line-by-line looking for matching strings.&amp;#160; Within each matching string we look for “passed” or “failed” and count them up as well as echo them to the command prompt.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;At the end we mop up and then display the tally for passed and failed tests.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;u&gt;Important Note&lt;/u&gt;: This is only ONE form of doing this.&amp;#160; There is no limit to what you CAN do.&amp;#160; For example, instead of echoing the testLabel contents, we could concatenate them into a report text block and send it via CDOsys (e-mail) or stuff it into a database via ADO or XML or generate an XML or HTML report, or even stuff it directly into a &lt;a href="http://www.microsoft.com" target="_blank"&gt;Microsoft&lt;/a&gt; Word or Excel document.&amp;#160; The possibilities are endless.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If anyone is interested in variations on this just post a comment and I’ll see what I can do.&amp;#160; I hope this helps someone out there?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2354282365260377277?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2354282365260377277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/02/automate-dcdiag-on-your-domain.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2354282365260377277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2354282365260377277'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/02/automate-dcdiag-on-your-domain.html' title='Automate DCDiag on your Domain Controllers'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-356080459076149576</id><published>2010-02-18T15:35:00.001-08:00</published><updated>2010-02-18T15:35:12.875-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>SQL Case Statements for Sum Operations</title><content type='html'>&lt;pre&gt;SELECT DISTINCT TOP (100) PERCENT&lt;br /&gt;      room_type, COUNT(room_id) AS rooms, SUM(room_area) AS sqft,&lt;br /&gt;      CASE&lt;br /&gt;                WHEN room_type = 1 THEN 'Office'&lt;br /&gt;                WHEN room_type = 2 THEN 'Storage'&lt;br /&gt;                WHEN room_type = 3 THEN 'Equipment'&lt;br /&gt;                WHEN room_type = 4 THEN 'Computer'&lt;br /&gt;                WHEN room_type = 5 THEN 'Medical'&lt;br /&gt;                WHEN room_type = 6 THEN 'Public'&lt;br /&gt;                ELSE 'Unknown'&lt;br /&gt;        END AS TypeName&lt;br /&gt;FROM dbo.tbl_rooms&lt;br /&gt;GROUP BY room_type&lt;br /&gt;ORDER BY room_type&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Returns something like the following:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;strong&gt;room_type rooms     sqft&lt;/strong&gt;&lt;br /&gt;Office      210    6,540&lt;br /&gt;Storage      54      983&lt;br /&gt;Equipment    86    1,002&lt;br /&gt;Computer      3      852&lt;br /&gt;Medical     640   39,553&lt;br /&gt;Public        6   10,401&lt;br /&gt;Unknown       0        0&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-356080459076149576?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/356080459076149576/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2010/02/sql-case-statements-for-sum-operations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/356080459076149576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/356080459076149576'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2010/02/sql-case-statements-for-sum-operations.html' title='SQL Case Statements for Sum Operations'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4306837901846603795</id><published>2009-12-31T06:57:00.001-08:00</published><updated>2009-12-31T06:57:08.399-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='ado'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>VBScript ADO with XML and CSV Data Files</title><content type='html'>&lt;p&gt;I was poking around to find a way to read CSV, TXT (various delimiters) through VBScript for use in scripted data migrations, as well as to render the data in ASP, and found some interesting things.&amp;#160; I have to give credit to [&lt;a href="http://www.mombu.com/microsoft/scripting-wsh/t-query-xml-file-with-ado-in-wsh-131431.html" target="_blank"&gt;http://www.mombu.com/microsoft/scripting-wsh/t-query-xml-file-with-ado-in-wsh-131431.html&lt;/a&gt;] for the XML example.&amp;#160; I only modified it slightly to fit in with how I tend to code ADO processes.&amp;#160; I also would like to applaud the efforts of &lt;a href="http://www.connectionstrings.com" target="_blank"&gt;Connection Strings.com&lt;/a&gt; for their fantastic reference site for connection information for almost anything that can possibly store information.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Reading XML Data&lt;/strong&gt;&lt;/p&gt;  &lt;pre style="color: blue"&gt;Const dsn = &amp;quot;Provider=MSDAOSP;Data Source=MSXML2.DSOControl;&amp;quot;&lt;br /&gt;Const adChapter = 136&lt;br /&gt;&lt;br /&gt;Dim conn, rs&lt;br /&gt;Dim iLevel : iLevel = 0&lt;br /&gt;&lt;br /&gt;Set conn = CreateObject( &amp;quot;ADODB.Connection&amp;quot; )&lt;br /&gt;Set rs = CreateObject( &amp;quot;ADODB.Recordset&amp;quot; )&lt;br /&gt;&lt;br /&gt;conn.Open dsn&lt;br /&gt;&lt;br /&gt;rs.Open CreateObject( &amp;quot;WScript.Shell&amp;quot; ).CurrentDirectory + _&lt;br /&gt;    &amp;quot;\test.xml&amp;quot;, conn&lt;br /&gt;&lt;br /&gt;WalkHier iLevel, rs&lt;br /&gt;&lt;br /&gt;rs.Close&lt;br /&gt;conn.Close&lt;br /&gt;&lt;br /&gt;Sub WalkHier(ByVal iLevel, ByVal rs)&lt;br /&gt;    iLevel = iLevel + 1&lt;br /&gt;    Dim PriorLevel : PriorLevel = iLevel&lt;br /&gt;    Dim i, adoChildRS&lt;br /&gt;    While Not rs.EOF&lt;br /&gt;        For i = 0 To rs.Fields.Count - 1&lt;br /&gt;            If rs.Fields(i).Name &amp;lt;&amp;gt; &amp;quot;$Text&amp;quot; Then&lt;br /&gt;                If rs.Fields(i).Type = adChapter Then&lt;br /&gt;                    Set adoChildRS = rs.Fields(i).Value&lt;br /&gt;                    WalkHier iLevel, adoChildRS&lt;br /&gt;                Else&lt;br /&gt;                    wscript.echo iLevel &amp;amp; &amp;quot;: rs.Fields(&amp;quot; &amp;amp; i &amp;amp; &amp;quot;) = &amp;quot; &amp;amp; _&lt;br /&gt;                        rs.Fields(i).Name &amp;amp; &amp;quot; = &amp;quot; &amp;amp; rs.Fields(i).Value&lt;br /&gt;                End If&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        rs.MoveNext&lt;br /&gt;    Wend&lt;br /&gt;    iLevel = PriorLevel&lt;br /&gt;End Sub&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Reading CSV Data&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue"&gt;dsn = &amp;quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source='s:\scripts\';Extended Properties=&amp;quot;&amp;quot;text;HDR=Yes;FMT=Delimited(,);&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;query = &amp;quot;SELECT * FROM test.csv&amp;quot;&lt;br /&gt;&lt;br /&gt;Set conn = CreateObject(&amp;quot;ADODB.Connection&amp;quot;)&lt;br /&gt;Set cmd  = CreateObject(&amp;quot;ADODB.Command&amp;quot;)&lt;br /&gt;Set rs   = CreateObject(&amp;quot;ADODB.Recordset&amp;quot;)&lt;br /&gt;&lt;br /&gt;conn.Open dsn&lt;br /&gt;&lt;br /&gt;rs.CursorLocation = adUseClient&lt;br /&gt;rs.CursorType = adOpenStatic&lt;br /&gt;rs.LockType = adLockReadOnly&lt;br /&gt;&lt;br /&gt;Set cmd.ActiveConnection = conn&lt;br /&gt;&lt;br /&gt;cmd.CommandType = adCmdText&lt;br /&gt;cmd.CommandText = query&lt;br /&gt;rs.Open cmd&lt;br /&gt;&lt;br /&gt;If Not(rs.BOF And rs.EOF) Then&lt;br /&gt;    Do Until rs.EOF&lt;br /&gt;        For i = 0 to rs.Fields.Count - 1&lt;br /&gt;            wscript.echo rs(i).name &amp;amp; &amp;quot; = &amp;quot; &amp;amp; rs(i).value&lt;br /&gt;        Next&lt;br /&gt;        rs.MoveNext&lt;br /&gt;    Loop&lt;br /&gt;Else&lt;br /&gt;    wscript.echo &amp;quot;error: no records found&amp;quot;&lt;br /&gt;End If&lt;br /&gt;rs.Close&lt;br /&gt;conn.Close&lt;br /&gt;Set rs = Nothing&lt;br /&gt;Set cmd = Nothing&lt;br /&gt;Set conn = Nothing&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4306837901846603795?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4306837901846603795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/12/vbscript-ado-with-xml-and-csv-data.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4306837901846603795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4306837901846603795'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/12/vbscript-ado-with-xml-and-csv-data.html' title='VBScript ADO with XML and CSV Data Files'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7763057494963890082</id><published>2009-12-25T07:14:00.001-08:00</published><updated>2009-12-25T07:14:35.360-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><title type='text'>Convert INI to XML with KiXtart</title><content type='html'>&lt;p&gt;Sometimes you may want/need to read a standard INI data file and output it to an XML format.&amp;#160; There are several ways to do this, but here is just one.&amp;#160; You’ll need KiXtart 4.61 in order to use the Replace() function. Enjoy (and Merry Christmas!)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.kixtart.org" target="_blank"&gt;&lt;strong&gt;KiXtart&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; Code&lt;/strong&gt;&lt;/p&gt;  &lt;pre style="color: blue"&gt;Break ON&lt;br /&gt;; requires KiXtart 4.61 or later!!!&lt;br /&gt;If @kix &amp;lt;= &amp;quot;4.60&amp;quot;&lt;br /&gt;    ? &amp;quot;this script requires 4.61 or later!&amp;quot;&lt;br /&gt;    Exit&lt;br /&gt;EndIf&lt;br /&gt;&lt;br /&gt;$strFileName = &amp;quot;s:\scripts\test.ini&amp;quot;&lt;br /&gt;&lt;br /&gt;$quote = Chr(34)&lt;br /&gt;$tab = Chr(9)&lt;br /&gt;&lt;br /&gt;Dim $linecount, $fHandle, $strLine, $outer, $keyset, $subkeyformat&lt;br /&gt;Dim $name, $value&lt;br /&gt;&lt;br /&gt;$subkeyFormat = 1&lt;br /&gt;$fHandle = FreeFileHandle()&lt;br /&gt;$outer = &amp;quot;&amp;quot;&lt;br /&gt;&lt;br /&gt;If Open($fHandle, $strFileName) = 0&lt;br /&gt;    $strLine = ReadLine($fHandle)&lt;br /&gt;    While @error = 0&lt;br /&gt;        Select&lt;br /&gt;            Case Left($strLine,1) = &amp;quot;[&amp;quot;&lt;br /&gt;                $outer = Replace(Replace($strLine, &amp;quot;]&amp;quot;, &amp;quot;&amp;quot;), &amp;quot;[&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;                ? &amp;quot;&amp;lt;$outer&amp;gt;&amp;quot;&lt;br /&gt;            Case InStr($strLine, &amp;quot;=&amp;quot;) &amp;lt;&amp;gt; 0&lt;br /&gt;                $keyset = Split($strLine, &amp;quot;=&amp;quot;)&lt;br /&gt;                $name  = $keyset[0]&lt;br /&gt;                $value = $keyset[1]&lt;br /&gt;                If $subkeyFormat == 1&lt;br /&gt;                    ? &amp;quot;$tab&lt;item value="$quote$value$quote/" name="$quote$name$quote"&gt;&amp;quot;&lt;br /&gt;                Else&lt;br /&gt;                    ? &amp;quot;$tab&amp;lt;$name&amp;gt;$value&amp;lt;/$NAME&amp;gt;&amp;quot;&lt;br /&gt;                EndIf&lt;br /&gt;            Case 1&lt;br /&gt;                If $outer &amp;lt;&amp;gt; &amp;quot;&amp;quot;&lt;br /&gt;                    ? &amp;quot;&amp;lt;/$OUTER&amp;gt;&amp;quot;&lt;br /&gt;                    $outer = &amp;quot;&amp;quot;&lt;br /&gt;                EndIf&lt;br /&gt;        EndSelect&lt;br /&gt;        $strLine = ReadLine($fHandle)&lt;br /&gt;    Loop&lt;br /&gt;    $=Close($fHandle)&lt;br /&gt;EndIf&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7763057494963890082?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7763057494963890082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/12/convert-ini-to-xml-with-kixtart.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7763057494963890082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7763057494963890082'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/12/convert-ini-to-xml-with-kixtart.html' title='Convert INI to XML with KiXtart'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-1444053149798888875</id><published>2009-12-25T06:29:00.001-08:00</published><updated>2009-12-25T06:29:29.876-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='COM'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Scraping Web Pages with VBScript and KiXtart</title><content type='html'>&lt;p&gt;Here’s a quick example of how to scrape HREF and IMG strings from a web page using VBScript and &lt;a href="http://www.kixtart.org" target="_blank"&gt;KiXtart&lt;/a&gt; with the InternetExplorer.Application COM object.&amp;#160; Thanks to Paul Sadowski for the basis of the VBScript example (with only very slight modifications).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;VBScript Code&lt;/strong&gt;&lt;/p&gt;  &lt;pre style="color: blue"&gt;url = &amp;quot;http://www.textpad.com&amp;quot;&lt;br /&gt;&lt;br /&gt;Set ie = CreateObject(&amp;quot;InternetExplorer.Application&amp;quot;)&lt;br /&gt;ie.Navigate url&lt;br /&gt;&lt;br /&gt;Wscript.Echo &amp;quot;DOCUMENT HYPERLINKS&amp;quot; &amp;amp; vbCRLF&lt;br /&gt;Do Until ie.ReadyState = 4&lt;br /&gt;    Wscript.Sleep 2&lt;br /&gt;Loop&lt;br /&gt;For each link in ie.Document.Links&lt;br /&gt;    Wscript.Echo link, link.InnerText&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;Wscript.Echo &amp;quot;------------------------------------&amp;quot;&lt;br /&gt;Wscript.Echo &amp;quot;DOCUMENT IMAGE TAGS&amp;quot; &amp;amp; vbCRLF&lt;br /&gt;&lt;br /&gt;For each img in ie.Document.Images&lt;br /&gt;    Wscript.Echo img.Src&lt;br /&gt;Next&lt;br /&gt;  &lt;br /&gt;ie.Quit&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;KiXtart Code&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue"&gt;break ON&lt;br /&gt;&lt;br /&gt;$url = &amp;quot;http://www.textpad.com&amp;quot;&lt;br /&gt;&lt;br /&gt;$ie = CreateObject(&amp;quot;InternetExplorer.Application&amp;quot;)&lt;br /&gt;$ie.Navigate($url)&lt;br /&gt;? &amp;quot;DOCUMENT HYPERLINKS&amp;quot;&lt;br /&gt;&lt;br /&gt;While $ie.ReadyState &amp;lt;&amp;gt; 4&lt;br /&gt;    Sleep 2&lt;br /&gt;Loop&lt;br /&gt;&lt;br /&gt;For each $link in $ie.Document.Links&lt;br /&gt;    ? $link+&amp;quot;=&amp;quot;+$link.InnerText&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;? &amp;quot;DOCUMENT IMAGE TAGS&amp;quot;&lt;br /&gt;&lt;br /&gt;For each $pix in $ie.Document.Images&lt;br /&gt;    ? $pix.Src&lt;br /&gt;Next&lt;br /&gt;  &lt;br /&gt;$ie.Quit()&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-1444053149798888875?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/1444053149798888875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/12/scraping-web-pages-with-vbscript-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1444053149798888875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1444053149798888875'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/12/scraping-web-pages-with-vbscript-and.html' title='Scraping Web Pages with VBScript and KiXtart'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5988940709964044436</id><published>2009-12-25T05:55:00.001-08:00</published><updated>2009-12-25T05:55:55.377-08:00</updated><title type='text'>Merry Christmas!</title><content type='html'>&lt;p&gt;I would like to wish everyone who visits my blog a very Merry Christmas!&amp;#160; Thank you for taking the time to read my drivel and post feedback on occassion.&amp;#160; I hope you have a really nice Christmas weekend and may you enjoy time with your family, and friends.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5988940709964044436?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5988940709964044436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/12/merry-christmas.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5988940709964044436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5988940709964044436'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/12/merry-christmas.html' title='Merry Christmas!'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-752029502348249740</id><published>2009-11-28T06:45:00.001-08:00</published><updated>2009-11-28T06:45:46.057-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><title type='text'>SQL Script Exports</title><content type='html'>&lt;p&gt;Until the day comes when &lt;a href="http://www.microsoft.com" target="_blank"&gt;Microsoft&lt;/a&gt; SQL Server SSMS provides the same info export features that PHPMyAdmin provides, we’re stuck with the right-click “Script-To…” feature (unless you buy a third-party utility, or write your own SMO or ADOX/ADO scripts, etc.), I tripped and fell over a rather simple feature that I didn’t know existed.&amp;#160; You can export multiple table schemas in one operation by simply clicking on the “Tables” object in the Object Explorer panel, then right-click and choose “Script-To: CREATE” and save to the clipboard/file/query window.&amp;#160; It works the same as individual exports, only that this does all of the Tables at once.&amp;#160; You can do the same by clicking on the “Views” object as well.&lt;/p&gt;  &lt;p&gt;If you already knew this, just chuckle, shrug and blow it off and move on.&amp;#160; No harm done.&amp;#160; I wasn’t aware of this, so I figured at least one other person might not know this as well.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-752029502348249740?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/752029502348249740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/11/sql-script-exports.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/752029502348249740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/752029502348249740'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/11/sql-script-exports.html' title='SQL Script Exports'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4318748538464696987</id><published>2009-11-19T19:07:00.001-08:00</published><updated>2009-11-19T19:07:00.177-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='COM'/><category scheme='http://www.blogger.com/atom/ns#' term='fso'/><title type='text'>KiXtart: Using FSO File.ReadAll()</title><content type='html'>&lt;p&gt;Another example of making use of one scripting language or API from another.&amp;#160; In this case, I’m calling on the FileSystemObject API to invoke the ReadAll() function on a file from a &lt;a href="http://www.kixtart.org" target="_blank"&gt;KiXtart&lt;/a&gt; script.&amp;#160; Just to show that there are all sorts of things you can do like this…&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;function ReadFile($filepath)&lt;br /&gt;    $fso = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;    if exist($filepath)&lt;br /&gt;        $file = $fso.OpenTextFile($filepath)&lt;br /&gt;        $text = $file.ReadAll()&lt;br /&gt;        $file.Close()&lt;br /&gt;        $file = 0&lt;br /&gt;    else&lt;br /&gt;        ? &amp;quot;error: file not found&amp;quot;&lt;br /&gt;    endif&lt;br /&gt;    $readfile = $text&lt;br /&gt;endfunction&lt;br /&gt;&lt;br /&gt;&lt;font color="#408080"&gt;; example...&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;? readfile(&amp;quot;c:\myfile.txt&amp;quot;)&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4318748538464696987?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4318748538464696987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/11/kixtart-using-fso-filereadall.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4318748538464696987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4318748538464696987'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/11/kixtart-using-fso-filereadall.html' title='KiXtart: Using FSO File.ReadAll()'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-9150264433163926339</id><published>2009-11-14T21:30:00.001-08:00</published><updated>2009-11-14T21:30:03.983-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><title type='text'>Restarting a Remote Service (VBScript vs PowerShell)</title><content type='html'>&lt;p&gt;This kind of goes along with my rants about PowerShell examples being pretty much reformatted VBScript WMI code examples, but regardless, PowerShell does provide a more abbreviated code environment.&amp;#160; The PowerShell code example was derived from a &lt;a href="http://pshscripts.blogspot.com/2009/10/restart-dnsps1.html" target="_blank"&gt;posting by Thomas Lee on the PowerShell blog on restarting a DNS service on a remote computer&lt;/a&gt;.&amp;#160; I had a VBScript example which does the same with the Spooler service, so I simply adapted Thomas’ code to support and apples-to-apples comparison.&amp;#160; As you can see, they are very similar.&amp;#160; In fact, the &lt;a href="http://www.kixtart.org" target="_blank"&gt;KiXtart&lt;/a&gt; version looks almost identical to both as well.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;VBScript Example&lt;/strong&gt;&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;strComputer = &amp;quot;server1&amp;quot; &lt;br /&gt;wscript.echo &amp;quot;Restarting Spooler Service on: &amp;quot;,strComputer&lt;br /&gt;&lt;br /&gt;Set wmi = GetObject(&amp;quot;winmgmts:\\&amp;quot; &amp;amp; strComputer &amp;amp; &amp;quot;\root\CIMV2&amp;quot;) &lt;br /&gt;Set ret = wmi.ExecMethod(&amp;quot;Win32_Service.Name='Spooler'&amp;quot;, &amp;quot;StopService&amp;quot;)&lt;br /&gt;If ret.ReturnValue = 0 Then&lt;br /&gt;    wscript.echo &amp;quot;Spooler Service stopped&amp;quot;&lt;br /&gt;Else&lt;br /&gt;    wscript.echo &amp;quot;Spooler Service not stopped&amp;quot;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set ret = wmi.ExecMethod(&amp;quot;Win32_Service.Name='Spooler '&amp;quot;, &amp;quot;StartService&amp;quot;)&lt;br /&gt;If ret.ReturnValue = 0 Then&lt;br /&gt;    wscript.echo &amp;quot;Spooler Service started&amp;quot;&lt;br /&gt;Else&lt;br /&gt;    wscript.echo &amp;quot;Spooler Service not started&amp;quot;&lt;br /&gt;End If&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;PowerShell Example&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue; font-size: 9pt"&gt;$strComputer = &amp;quot;server1&amp;quot; &lt;br /&gt;&amp;quot;Restarting Spooler Service on: $strComputer&amp;quot; &lt;br /&gt;  &lt;br /&gt;# get the service object&lt;br /&gt;$svc = gwmi Win32_Service -computer $strComputer | where {$_.name -eq &amp;quot;Spooler&amp;quot;} &lt;br /&gt;  &lt;br /&gt;# stop the service&lt;br /&gt;$ret = $svc.StopService() &lt;br /&gt;if ($ret.ReturnValue -eq 0) {&amp;quot;Spooler Service stopped&amp;quot;} &lt;br /&gt;else {&amp;quot;Spooler Service not stopped&amp;quot;} &lt;br /&gt;  &lt;br /&gt;# start the service&lt;br /&gt;$ret = $svc.StartService() &lt;br /&gt;if ($ret.ReturnValue -eq 0) {&amp;quot;Spooler Service started&amp;quot;} &lt;br /&gt;else {&amp;quot;Spooler Service not started&amp;quot;}&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-9150264433163926339?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/9150264433163926339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/11/restarting-remote-service-vbscript-vs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/9150264433163926339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/9150264433163926339'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/11/restarting-remote-service-vbscript-vs.html' title='Restarting a Remote Service (VBScript vs PowerShell)'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-565330808226018630</id><published>2009-11-01T05:43:00.001-08:00</published><updated>2009-11-01T05:43:02.313-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='vmware'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='inventory'/><title type='text'>Am I a VMWare Guest Machine or Not?</title><content type='html'>&lt;strong&gt;VBScript Version&lt;/strong&gt;   &lt;pre style="color: blue; font-size: 9pt"&gt;Function IsVmWareClient()&lt;br /&gt;    Dim objWMIService, colBIOS, objBIOS, retval&lt;br /&gt;    Set objWMIService = GetObject(&amp;quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&amp;quot;)&lt;br /&gt;    Set colBIOS = objWMIService.ExecQuery(&amp;quot;Select SerialNumber from Win32_BIOS&amp;quot;)&lt;br /&gt;    For each objBIOS in colBIOS&lt;br /&gt;        If Left(objBIOS.SerialNumber, 6) = &amp;quot;VMware&amp;quot; Then&lt;br /&gt;            retval = True&lt;br /&gt;            Exit For&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;    IsVmWareClient = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;font color="#008080"&gt;' test&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;If IsVmWareClient() Then&lt;br /&gt;    wscript.echo &amp;quot;yes - this is a vmware guest machine&amp;quot;&lt;br /&gt;Else&lt;br /&gt;    wscript.echo &amp;quot;not a vmware guest machine&amp;quot;&lt;br /&gt;End If&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;KiXtart Version&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue; font-size: 9pt"&gt;Function IsVmWareClient()&lt;br /&gt;    Dim $wmiService, $colBIOS, $objBIOS, $retval&lt;br /&gt;    $wmiService = GetObject(&amp;quot;winmgmts:\\.\root\CIMV2&amp;quot;)&lt;br /&gt;    $colBIOS = $wmiService.ExecQuery(&amp;quot;select SerialNumber from Win32_BIOS&amp;quot;) &lt;br /&gt;    For Each $objBIOS in $colBIOS&lt;br /&gt;        If Left($objBIOS.SerialNumber, 6) = &amp;quot;VMware&amp;quot;&lt;br /&gt;            $retval = 1&lt;br /&gt;        EndIf&lt;br /&gt;    Next&lt;br /&gt;    $IsVmWareClient = $retval&lt;br /&gt;EndFunction&lt;br /&gt;&lt;br /&gt;&lt;font color="#008080"&gt;; test&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;If IsVmWareClient()&lt;br /&gt;    ? &amp;quot;yes - this is a vmware guest machine&amp;quot;&lt;br /&gt;Else&lt;br /&gt;    ? &amp;quot;not a vmware guest machine&amp;quot;&lt;br /&gt;EndIf&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-565330808226018630?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/565330808226018630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/11/am-i-vmware-guest-machine-or-not.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/565330808226018630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/565330808226018630'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/11/am-i-vmware-guest-machine-or-not.html' title='Am I a VMWare Guest Machine or Not?'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2373125665630988375</id><published>2009-10-25T10:41:00.001-07:00</published><updated>2009-10-25T10:41:51.100-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bat'/><category scheme='http://www.blogger.com/atom/ns#' term='windows7'/><category scheme='http://www.blogger.com/atom/ns#' term='installation'/><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><title type='text'>Windows 7 Clean Install using Upgrade Media</title><content type='html'>&lt;p&gt;Just a slightly different spin to the post by &lt;a href="http://www.winsupersite.com/win7/clean_install_upgrade_media.asp" target="_blank"&gt;Paul Thurrott&lt;/a&gt; about performing a clean install of Windows 7 using “upgrade” media without having to install XP or Vista first.&amp;#160; This just wraps the steps inside a .BAT script.&amp;#160; Make &lt;u&gt;sure&lt;/u&gt; you read Paul’s article first or you’ll be lost.&amp;#160; Be sure to run this from a CMD console that was launched via “Run as Administrator” or it won’t work…&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;@echo off&lt;br /&gt;rem the following line between the divider lines should NOT wrap!&lt;br /&gt;rem --------------------------------&lt;br /&gt;REG ADD &amp;quot;HKLM/Software/Microsoft/Windows/CurrentVersion/Setup/OOBE/&amp;quot; /v MediaBootInstall /d 1 /t REG_DWORD /f&lt;br /&gt;rem --------------------------------&lt;br /&gt;echo Registry key value has been set.&lt;br /&gt;pause&lt;br /&gt;slmgr /rearm&lt;br /&gt;echo Activation skip-rearm has been set.&lt;br /&gt;echo Press ENTER to reboot your computer now...&lt;br /&gt;pause&lt;br /&gt;shutdown -r -f -t 2 &lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2373125665630988375?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2373125665630988375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/windows-7-clean-install-using-upgrade.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2373125665630988375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2373125665630988375'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/windows-7-clean-install-using-upgrade.html' title='Windows 7 Clean Install using Upgrade Media'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5890370917644235486</id><published>2009-10-17T14:42:00.001-07:00</published><updated>2009-10-17T14:42:10.897-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows7'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='twitter'/><title type='text'>Using Twitter to Control Your Computer</title><content type='html'>&lt;p&gt;I’ve blogged about this before, but not with a lot of detail.&amp;#160; So here goes.&lt;/p&gt;  &lt;p&gt;In my previous post, I explained how to setup a “system” that has your computer sending a DM (Direct Message) Tweet to your &lt;a href="http://twitter.com" target="_blank"&gt;Twitter&lt;/a&gt; account.&amp;#160; But in this scenario I’m turning it around, so that you will Tweet your computer and have it perform actions based on what you Tweet.&lt;/p&gt;  &lt;p&gt;What you do with this is up to you.&amp;#160; Anything you can do with a script is fair game.&amp;#160; Anything.&amp;#160; The script will reside on your computer.&amp;#160; You will send a DM to a Twitter account, which your computer will monitor on a scheduled recurrence.&amp;#160; Your script will read and parse the DM container and look for specific phrases that it is set to recognize and will execute a task accordingly.&amp;#160; Simple enough?&amp;#160; Good.&amp;#160; I thought so.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Ingredients&lt;/strong&gt;:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;A Twitter Account &lt;/li&gt;    &lt;li&gt;Another Twitter Account &lt;/li&gt;    &lt;li&gt;A List of Things You Intend to Ask Your Computer To Do &lt;/li&gt;    &lt;li&gt;A Script &lt;/li&gt;    &lt;li&gt;A Scheduled Task &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;A Twitter Account&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This is YOUR Twitter account actually.&amp;#160; You will need this in order to send a DM (Direct Message) Tweet to your computer, which requires…&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Another Twitter Account&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This is the account your computer will monitor.&amp;#160; Remember to lock it down so only your “other” Twitter account can access it.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;A List of Things for Your Computer To Do&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You need to sit down and make a list of what specific tasks you want to be able to request of your computer.&amp;#160; Yes, you COULD make it so you Tweet any shell operation and have it blindly execute that, but trust me: THAT IS DANGEROUSLY STUPID.&amp;#160; In fact, so stupid, you should have your balls stomped with ice climbing boots in a rowdy Irish pub just for thinking it.&amp;#160; Need some pointers? Here’s a simple list to get you started:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Reboot or Shutdown a computer &lt;/li&gt;    &lt;li&gt;Disable a User Account &lt;/li&gt;    &lt;li&gt;Add/Remove A User to/from a Group &lt;/li&gt;    &lt;li&gt;Start/Stop a Service &lt;/li&gt;    &lt;li&gt;Start a Batch or Backup Job &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For the first example, I’m going to simply have the computer tweet me back.&amp;#160; That way I know the plumbing is working and the toilets flush properly.&amp;#160; To do this, I’m going to make a script that reads my DM list and parses it for a specific phrase.&amp;#160; When that phrase is found, it will simply tweet me back (by DM) to let me know it got it.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;A Script&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The script I’m using for this example is written in VBscript, but any language/platform will work fine as long as it can invoke the Twitter API.&amp;#160; This script will access my Computer Twitter account, fetch the DM queue, iterate through it for messages containing a specific phrase of “TWEET_ME_BACK @userid” and then simply turn around and send a DM to the “@userid” that sent it (which, in this situation, is me).&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;'----------------------------------------------&lt;br /&gt;' filename: twitter_monitor.vbs&lt;br /&gt;' author: skatterbrainz&lt;br /&gt;' http://scriptzilla.blogspot.com&lt;br /&gt;' give props, don't rip me off please?&lt;br /&gt;'----------------------------------------------&lt;br /&gt;Const username = &amp;quot;Computer_TwitterName&amp;quot;&lt;br /&gt;Const password = &amp;quot;Computer_TwitterPassword&amp;quot;&lt;br /&gt;Const replyTo  = &amp;quot;My_Twitter_Account&amp;quot;&lt;br /&gt;&lt;br /&gt;Function Twitter_Get_Direct(strUser,strPass)&lt;br /&gt;    wscript.echo &amp;quot;querying for direct messages...&amp;quot;&lt;br /&gt;    Dim oXml, strTwitterURL : strTwitterURL = &amp;quot;http://twitter.com/direct_messages.xml&amp;quot;&lt;br /&gt;    Set oXml = CreateObject(&amp;quot;MSXML2.ServerXMLHTTP.3.0&amp;quot;)&lt;br /&gt;    oXml.Open &amp;quot;GET&amp;quot;, strTwitterURL, False, strUser, strPass&lt;br /&gt;    oXml.setRequestHeader &amp;quot;Content-Type&amp;quot;, &amp;quot;application/x-www-form-urlencoded&amp;quot;&lt;br /&gt;    oXml.Send()&lt;br /&gt;    Twitter_Get_Direct = oXml.responseText&lt;br /&gt;    Set oXml = Nothing&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;result = Twitter_Get_Direct(username, password)&lt;br /&gt;&lt;br /&gt;'----------------------------------------------&lt;br /&gt;' if direct messages were found, iterate them&lt;br /&gt;'----------------------------------------------&lt;br /&gt;&lt;br /&gt;If Trim(result) &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;    wscript.echo &amp;quot;direct messages were found!&amp;quot;&lt;br /&gt;    Set xmlDoc = CreateObject(&amp;quot;Microsoft.XMLDOM&amp;quot;)&lt;br /&gt;    xmlDoc.async = &amp;quot;false&amp;quot;&lt;br /&gt;    xmlDoc.loadXML(result)&lt;br /&gt;    For each x in xmlDoc.documentElement.childNodes&lt;br /&gt;        msg = x.Text&lt;br /&gt;        If InStr(1, Ucase(msg), &amp;quot;TWEET ME BACK&amp;quot;) &amp;lt;&amp;gt; 0 Then&lt;br /&gt;            id = Left(msg, 9)&lt;br /&gt;            wscript.echo id, &amp;quot;: &amp;quot;, Mid(Msg, 20)&lt;br /&gt;            wscript.echo &amp;quot;sending tweet-dm...&amp;quot;&lt;br /&gt;            TweetBack()&lt;br /&gt;            DeleteDM id&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;'----------------------------------------------&lt;br /&gt;' send tweet via direct-message&lt;br /&gt;'----------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub TweetBack()&lt;br /&gt;    Dim retval, strMsg : strMsg = &amp;quot;I got your message!&amp;quot;&lt;br /&gt;    Dim oXml, strTwitterURL : strTwitterURL = &amp;quot;http://twitter.com/direct_messages/new.xml&amp;quot;&lt;br /&gt;    Set oXml = CreateObject(&amp;quot;MSXML2.ServerXMLHTTP.3.0&amp;quot;)&lt;br /&gt;    oXml.Open &amp;quot;POST&amp;quot;, strTwitterURL, False, username, password&lt;br /&gt;    oXml.setRequestHeader &amp;quot;Content-Type&amp;quot;, &amp;quot;application/x-www-form-urlencoded&amp;quot;&lt;br /&gt;    oXml.Send &amp;quot;text=&amp;quot; &amp;amp; strMsg &amp;amp; &amp;quot;&amp;amp;user=&amp;quot; &amp;amp; replyTo&lt;br /&gt;    retval = oXml.responseText&lt;br /&gt;    Set oXml = Nothing&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;'----------------------------------------------&lt;br /&gt;' delete a direct-message using the id number&lt;br /&gt;'----------------------------------------------&lt;br /&gt;&lt;br /&gt;Sub DeleteDM(id)&lt;br /&gt;    Dim retval&lt;br /&gt;    Dim oXml, strTwitterURL : strTwitterURL = &amp;quot;http://twitter.com/direct_messages/destroy/&amp;quot; &amp;amp; id &amp;amp; &amp;quot;.xml&amp;quot;&lt;br /&gt;    Set oXml = CreateObject(&amp;quot;MSXML2.ServerXMLHTTP.3.0&amp;quot;)&lt;br /&gt;    oXml.Open &amp;quot;POST&amp;quot;, strTwitterURL, False, username, password&lt;br /&gt;    oXml.setRequestHeader &amp;quot;Content-Type&amp;quot;, &amp;quot;application/x-www-form-urlencoded&amp;quot;&lt;br /&gt;    oXml.Send()&lt;br /&gt;    retval = oXml.responseText&lt;br /&gt;    Set oXml = Nothing&lt;br /&gt;End Sub&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Note that in the iteration section of code above I invoke the XMLDOM object to parse the direct_message result.&amp;#160; This is because it returns a single XML stream that contains all of the direct messages.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;A Scheduled Task&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Because your computer needs to read the Twitter account DM queue, it needs to “poll” for it using a recurrent task.&amp;#160; The easiest way to do this is by creating a scheduled task.&amp;#160; Each time the task is initiated, it will execute the script and go back to sleep until it’s scheduled to run again.&amp;#160; I’m using Windows 7 for this example, so here goes…&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Click on the Windows button (formerly “Start” button) &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Type in SCHED and as soon as “&lt;strong&gt;Task Scheduler&lt;/strong&gt;” appears at the top, press Enter. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click on Task Scheduler Library in the left-hand panel &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Right-click on Task Scheduler Library and select “&lt;strong&gt;Create Task&lt;/strong&gt;” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;In the Name box, enter “Monitor Twitter Account” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;In the Description box, enter “Monitor Twitter account ___ for Direct Messages to parse” (fill-in your computer Twitter account name). &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Select “Run whether user is logged on or not” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click “Change User or Group” button, enter “SYSTEM” and click “Check Names” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Once the name is underlined, click OK.&amp;#160; You should see “NT AUTHORITY\SYSTEM” in the user account name box. (see Fig. 1) &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click the &lt;strong&gt;Triggers&lt;/strong&gt; tab. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Change the “Repeat task every:” to “15 Minutes” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Check “Stop task if it runs longer than:” and set it to “14 Minutes” (see Fig. 2) &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click OK, to return to the Create Task form. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click the &lt;strong&gt;Actions&lt;/strong&gt; tab, click the New button &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Enter “cscript” for the program.&amp;#160; Enter “/nologo c:\scripts\monitor_twitter.vbs” in the arguments box (see Fig. 3, and 4) &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click OK to save the new Task &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_8gO-v9s9Ato/Sto6I8V_8vI/AAAAAAAAGxk/iH8ty7e8_MY/s1600-h/image%5B2%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure 1" border="0" alt="Figure 1" src="http://lh4.ggpht.com/_8gO-v9s9Ato/Sto6JQ28_nI/AAAAAAAAGxo/vbOOiT_idOE/image_thumb.png?imgmax=800" width="244" height="185" /&gt;&lt;/a&gt; Fig. 1&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_8gO-v9s9Ato/Sto6J3wVR8I/AAAAAAAAGxs/ZZAJ5fQuXzg/s1600-h/image%5B5%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure 2" border="0" alt="Figure 2" src="http://lh4.ggpht.com/_8gO-v9s9Ato/Sto6KW3sbNI/AAAAAAAAGxw/_hwmaN4qKu0/image_thumb%5B1%5D.png?imgmax=800" width="244" height="211" /&gt;&lt;/a&gt; Fig. 2&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_8gO-v9s9Ato/Sto6Kxe8paI/AAAAAAAAGx0/HM_ddZpln-c/s1600-h/image%5B11%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure 3" border="0" alt="Figure 3" src="http://lh4.ggpht.com/_8gO-v9s9Ato/Sto6LnVPS0I/AAAAAAAAGx4/D6yBlyIdWZg/image_thumb%5B3%5D.png?imgmax=800" width="226" height="244" /&gt;&lt;/a&gt; Fig. 3&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_8gO-v9s9Ato/Sto6MBNVk6I/AAAAAAAAGx8/d68mIjFoPvo/s1600-h/image%5B14%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure 4" border="0" alt="Figure 4" src="http://lh6.ggpht.com/_8gO-v9s9Ato/Sto6MuoJToI/AAAAAAAAGyA/p5GegpatPJ4/image_thumb%5B4%5D.png?imgmax=800" width="244" height="185" /&gt;&lt;/a&gt; Fig. 4&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5890370917644235486?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5890370917644235486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/using-twitter-to-control-your-computer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5890370917644235486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5890370917644235486'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/using-twitter-to-control-your-computer.html' title='Using Twitter to Control Your Computer'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_8gO-v9s9Ato/Sto6JQ28_nI/AAAAAAAAGxo/vbOOiT_idOE/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5229231205237447121</id><published>2009-10-17T10:40:00.001-07:00</published><updated>2009-10-17T10:40:06.991-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows7'/><category scheme='http://www.blogger.com/atom/ns#' term='event logs'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='twitter'/><title type='text'>Making Your Computer Tweet You When Bad Things Happen</title><content type='html'>&lt;p&gt;&lt;a href="http://twitter.com" target="_blank"&gt;Twitter&lt;/a&gt; has a decent, if not minimalist API with which you can tap into with pretty much anything that can execute a process.&amp;#160; Scripting is a natural “fit” for this, but so is mainstream/classic-style/meat-and-potatos “programming”.&amp;#160; Pick your language, it doesn’t really matter.&amp;#160; After all, anyone that says you *have* to use a particular language for general tasks is a complete idiot.&amp;#160; (&lt;em&gt;pssst: it’s the same as saying all you need is a hammer, it works on everything, including hose clamps&lt;/em&gt;).&lt;/p&gt;  &lt;p&gt;I fell off the trail a bit, I’ll get back on.&amp;#160; Where was I?&amp;#160; Oh yeah…&lt;/p&gt;  &lt;p&gt;So, let’s JUST SAY you have a &lt;a href="http://twitter.com" target="_blank"&gt;Twitter&lt;/a&gt; account and a Windows computer (XP or later).&amp;#160; And maybe you’d like to find a way to leverage that (sorry, I know “leverage” was voted one of the top 100 most overused and annoying words for 2009, at least it didn’t make the &lt;a href="http://maristpoll.marist.edu/wp-content/misc/usapolls/us090803/Annoying%20Phrase/Most%20Annoying%20Phrase%20in%20Conversation.htm" target="_blank"&gt;top 10&lt;/a&gt;), but the path from A to Q (forget Z) is a bit fuzzy?&amp;#160; Hmmm?&amp;#160; Fear not.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Ingredients&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;A Twitter account &lt;/li&gt;    &lt;li&gt;A Script &lt;/li&gt;    &lt;li&gt;An Internet connection &lt;/li&gt;    &lt;li&gt;A Scheduled Task &lt;/li&gt;    &lt;li&gt;Something to trigger this contraption to work &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;A Twitter Account&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You probably don’t want your computer tweeting you, but instead should have it DM (that’s Direct Message) you.&amp;#160; That way your computer’s messages aren’t laid bare to the public, but are instead restricted to just YOU.&amp;#160; You might think you can just use your own Twitter account to DM yourself, but you can’t.&amp;#160; Twitter doesn’t allow that.&amp;#160; So you need to create another Twitter account just for your computer to use. Or do you?&amp;#160; Actually, from the web or most Twitter clients (TweetDeck, UberTwitter, etc.) that is true.&amp;#160; However, with just the API and a script, you can DM yourself.&amp;#160; Weird, but true (for how long is anyone’s guess).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;A Script&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The pieces for this part are posted over on my other blog &lt;a href="http://skatterbrainz.blogspot.com/2009/08/sending-twitter-direct-message-using.html" target="_blank"&gt;here&lt;/a&gt; and another example of reading DM folders &lt;a href="http://skatterbrainz.blogspot.com/2009/08/fetching-twitter-direct-messages-using.html" target="_blank"&gt;here&lt;/a&gt;.&amp;#160; But for the sake of sparing your poor overworked fingers from more torturous mouse clicks, I’ll drop it below.&amp;#160; For this example, I’m using a VBScript file.&amp;#160; You can use PowerShell, &lt;a href="http://www.kixtart.org" target="_blank"&gt;KiXtart&lt;/a&gt;, BAT or whatever the **** you prefer, I really don’t give a ****.&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;Const username  = &amp;quot;Computer_TwitterName&amp;quot;&lt;br /&gt;Const password  = &amp;quot;Computer_TwitterPassword&amp;quot;&lt;br /&gt;Const recipient = &amp;quot;My_Twitter_Name&amp;quot;&lt;br /&gt;&lt;br /&gt;Function Twitter_Send_Direct(strMsg, recipient)&lt;br /&gt;    Dim oXml, strTwitterURL&lt;br /&gt;    strTwitterURL = &amp;quot;http://twitter.com/direct_messages/new.xml&amp;quot;&lt;br /&gt;    Set oXml = CreateObject(&amp;quot;MSXML2.ServerXMLHTTP.3.0&amp;quot;)&lt;br /&gt;    oXml.Open &amp;quot;POST&amp;quot;, strTwitterURL, False, username, password&lt;br /&gt;    oXml.setRequestHeader &amp;quot;Content-Type&amp;quot;, &amp;quot;application/x-www-form-urlencoded&amp;quot;&lt;br /&gt;    oXml.Send &amp;quot;text=&amp;quot; &amp;amp; strMsg &amp;amp; &amp;quot;&amp;amp;user=&amp;quot; &amp;amp; recipient&lt;br /&gt;    Twitter_Send_Direct = oXml.responseText&lt;br /&gt;    Set oXml = Nothing&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;msg = &amp;quot;Warning Event 129 NTP Synch Discovery Failure (computername)&amp;quot;&lt;br /&gt;result = Twitter_Send_Direct(msg, recipient)&lt;br /&gt;wscript.echo result&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Save the script as “twitter_event_129.vbs” in a folder called C:\scripts. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;An Internet Connection&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Not to be a smartass or anything, but if you’re reading this, there’s a pretty good chance you already have this.&amp;#160; If not, well then…&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;A Scheduled Task&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I’m going to use Windows Vista and Windows 7 for this exercise.&amp;#160; Why? Because I absolutely hate XP.&amp;#160; I hate it more than OSX or Linux.&amp;#160; But, I absolutely LOVE my Windows 7 and Windows Server 2008.&amp;#160; And one reason why is that this makes it MUCH easier to combine steps 4 and 5, and overall it just looks better on the eyes.&amp;#160; I’ll get back to this in a minute.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Something to Trigger this Contraption to Work&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;For this exercise, I’ll make this engine fire up whenever the Windows Event system logs an “Warning” Event of type 129 (that’s a NTP time synch discovery problem).&amp;#160; If you can’t find any such events, pick whatever suits you.&amp;#160; Just replace the ID number with the appropriate number below. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Since I’m using Windows 7, I’m going to combine steps 4 and 5 as follows: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Open the &lt;strong&gt;Event Viewer&lt;/strong&gt; console &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Navigate to &lt;u&gt;Windows Logs&lt;/u&gt; / &lt;u&gt;System&lt;/u&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;In the Actions panel, click “Filter Current Log…” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Check “Warnings” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;In the box with “&amp;lt;All Event IDs&amp;gt;” type in “129” and click OK &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;You should see just those events now. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Right-click on one of the events, and click “Attach Task to this Event…” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;The default title will be highlighted.&amp;#160; You can change it if you want or leave it as-is, but I would suggest you enter something in the Description box to explain what this “task” is for and what it does.&amp;#160; For my example, I’m going to replace the default title “System_Microsoft-Windows-Time-Service_129” with “&lt;em&gt;Send Twitter DM for Event 129 NTP Warnings&lt;/em&gt;” and in the Description box enter “&lt;em&gt;Call a script to send a Twitter DM when event ID 129 (warning) for NTP synch discovery is logged&lt;/em&gt;” and click Next &amp;gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click Next &amp;gt; on the “When an Event is Logged” panel. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Select “Start a Program” and click Next &amp;gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click the Browse… button to locate my .VBS script &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click Next &amp;gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click Finish &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You will see a confirmation message appear…&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_8gO-v9s9Ato/StoBc6JHATI/AAAAAAAAGxc/JyUx4Jvuq9o/s1600-h/image%5B2%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_8gO-v9s9Ato/StoBdoUQn7I/AAAAAAAAGxg/JNPitAsCtqc/image_thumb.png?imgmax=800" width="244" height="87" /&gt;&lt;/a&gt; (yes, you can just click OK)&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;But, we’re not done yet…&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Open the &lt;strong&gt;Windows Task Manager&lt;/strong&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Under &lt;u&gt;Task Scheduler Library&lt;/u&gt;, click &lt;u&gt;Event Viewer Tasks&lt;/u&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Right-click on the task you just created and select “Properties” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click the “General tab, click the “Change User or Group…” button &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Type in “SYSTEM” and click “Check Names” and the name should become underlined (validated).&amp;#160; Click OK.&amp;#160; The user account box should now display “NT AUTHORITY\SYSTEM”. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Just below that, change the option to “Run whether a user is logged on or not” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click the “Actions” tab. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click the “Edit” button &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Change the Program/Script box to “&lt;font color="#0000ff"&gt;cscript&lt;/font&gt;” &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;In the “Add arguments” box, enter &lt;font color="#0000ff"&gt;/nologo C:\scripts\twitter_event_129.vbs&lt;/font&gt; and click OK &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click the “Settings” tab. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Change the “Stop the task if it runs longer than:” value to 1 hour. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Click OK to save the changes &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Right-click on the Task and click “Run” to force it to run.&amp;#160; Go to your Twitter client to verify you received a DM.&amp;#160; If not, go back and verify your settings and the account and password settings within your script.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Cheers!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5229231205237447121?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5229231205237447121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/making-your-computer-tweet-you-when-bad.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5229231205237447121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5229231205237447121'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/making-your-computer-tweet-you-when-bad.html' title='Making Your Computer Tweet You When Bad Things Happen'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_8gO-v9s9Ato/StoBdoUQn7I/AAAAAAAAGxg/JNPitAsCtqc/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6412880977149876672</id><published>2009-10-14T16:01:00.001-07:00</published><updated>2009-10-14T16:01:42.380-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='thoughts'/><category scheme='http://www.blogger.com/atom/ns#' term='COM'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>So, what do you get with that PowerShell Combo?</title><content type='html'>&lt;p&gt;Fries? A drink? A kids toy?&amp;#160; As it turns out, not much.&amp;#160; This is just one example of what has been a trend that really bothers me about the so-called “examples” of PowerShell being published on the net lately.&amp;#160; Most are focused on WMI queries (WQL), or COM marshalling using the New-Object –COM method.&amp;#160; This really doesn’t do anything innovative or beneficial beyond learning a “different” way to code.&amp;#160; All of the WQL examples are simply search/replace code chunks which look almost identical to VBscript examples.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;VBScript&lt;/strong&gt;&lt;/p&gt;  &lt;pre style="color: blue"&gt;Set objOutlook = CreateObject(&amp;quot;Outlook.Application&amp;quot;)&lt;br /&gt;Set Namespace = objOutlook.GetNamespace(&amp;quot;MAPI&amp;quot;)&lt;br /&gt;&lt;br /&gt;For each f1 in NameSpace.Folders&lt;br /&gt;    wscript.echo f1.Name&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;For each objFolder in NameSpace.Folders&lt;br /&gt;    For each f1 in objFolder.Folders&lt;br /&gt;        wscript.echo vbTab &amp;amp; f1.Name&lt;br /&gt;    Next&lt;br /&gt;Next&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;PowerShell&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue"&gt;$Outlook = New-Object -com Outlook.Application&lt;br /&gt;$Namespace = $outlook.GetNamespace(&amp;quot;MAPI&amp;quot;)&lt;br /&gt;&lt;br /&gt;&amp;quot;{0} Root Folders:      &amp;quot; -f $Namespace.folders.count&lt;br /&gt;foreach ($Fl in $namespace.Folders) {&lt;br /&gt;    &amp;quot;   {0}&amp;quot; -f $Fl.Name}&lt;br /&gt;&amp;quot;&amp;quot;&lt;br /&gt;foreach ($Folder in $Namespace.Folders) {&lt;br /&gt;    &amp;quot;`'{0}`' subfolders: &amp;quot; -f $Folder.Name&lt;br /&gt;    foreach ($fl in $Folder.Folders) {&lt;br /&gt;        &amp;quot;   {0}&amp;quot; -f $Fl.Name&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I’m not at all trying to “bash” PowerShell.&amp;#160; It’s a cool language, but it has it’s issues that bother me.&amp;#160; I don’t consider it a classic or “true” scripting language as much as programmatic macro language.&amp;#160; Most of the benefits it provides via brevity of code are derived from cmdlets, which are similar to making DLL’s for COM extensibility, or UDF files for &lt;a href="http://www.kixtart.org" target="_blank"&gt;KiXtart&lt;/a&gt;, and so on.&amp;#160; Blah blah blah.&amp;#160; whatever.&amp;#160; I’m no pundit, so what I have to say doesn’t really matter that much really.&amp;#160; I forgot what point I was trying to make.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6412880977149876672?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6412880977149876672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/so-what-do-you-get-with-that-powershell.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6412880977149876672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6412880977149876672'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/so-what-do-you-get-with-that-powershell.html' title='So, what do you get with that PowerShell Combo?'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4472855623852505473</id><published>2009-10-11T07:30:00.001-07:00</published><updated>2009-10-11T07:30:35.275-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='adsi'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><title type='text'>Reboot Computers by Operating System</title><content type='html'>&lt;p&gt;What if you wanted to reboot every computer in your Active Directory domain that has a specific version of Windows installed?&amp;#160; One example is requesting every Windows 7 Ultimate computer to reboot (see below).&amp;#160; Just replace the “YOUR-DOMAIN” with your actual NetBIOS domain name and change the operating system string to whatever you prefer.&amp;#160; Remember to test in an isolated environment.&lt;/p&gt;  &lt;pre style="color: blue; font-size: 9pt"&gt;Set objDomain = GetObject(&amp;quot;WinNT://YOUR-DOMAIN&amp;quot;)&lt;br /&gt;&lt;br /&gt;For each objX in objDomain&lt;br /&gt;    If Lcase(objX.Class) = &amp;quot;computer&amp;quot; Then&lt;br /&gt;        n = objX.Name&lt;br /&gt;        wscript.echo n&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;Sub Reboot(strComputer)&lt;br /&gt;    Dim objWMIService, colOS, objShare, objRetval, cap&lt;br /&gt;    On Error Resume Next&lt;br /&gt;    Set objWMIService = GetObject(&amp;quot;winmgmts:\\&amp;quot; &amp;amp; strComputer &amp;amp; &amp;quot;\root\CIMV2&amp;quot;)&lt;br /&gt;    If err.Number &amp;lt;&amp;gt; 0 Then&lt;br /&gt;        wscript.echo &amp;quot;unavailable: &amp;quot; &amp;amp; strComputer&lt;br /&gt;    Else&lt;br /&gt;        Set colOS = objWMIService.ExecQuery(&amp;quot;SELECT * FROM Win32_OperatingSystem&amp;quot;,,48)&lt;br /&gt;        For each objItem in colOS&lt;br /&gt;            cap = objItem.Caption&lt;br /&gt;            If cap = &lt;font color="#008040"&gt;&amp;quot;Microsoft Windows 7 Ultimate&amp;quot;&lt;/font&gt; Then&lt;br /&gt;                Set objShare = objWMIService.Get(&amp;quot;Win32_OperatingSystem.ReplaceKeyProperty=ReplacePropertyValue&amp;quot;)&lt;br /&gt;                Set objRetval = objWMIService.ExecMethod(&amp;quot;Win32_OperatingSystem.ReplaceKeyProperty=ReplacePropertyValue&amp;quot;, &amp;quot;Reboot&amp;quot;)&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4472855623852505473?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4472855623852505473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/reboot-computers-by-operating-system.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4472855623852505473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4472855623852505473'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/reboot-computers-by-operating-system.html' title='Reboot Computers by Operating System'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5112208763240683599</id><published>2009-10-03T17:26:00.000-07:00</published><updated>2009-10-03T17:26:15.697-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='inventory'/><title type='text'>VBScript - Get Remote Asset Tag (Serial Number)</title><content type='html'>&lt;pre style="font-size:9pt;color:blue"&gt;Function AssetNumber(strComputer)&lt;br /&gt;    Dim objWmi, objWmiCS, obj, retval&lt;br /&gt;    On Error Resume Next&lt;br /&gt;    Set objWmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; _&lt;br /&gt;        strComputer &amp; "\root\cimv2")&lt;br /&gt;    If err.Number &lt;&gt; 0 Then&lt;br /&gt;        wscript.echo "error: " &amp; err.Number &amp; " / " &amp; err.Description&lt;br /&gt;        err.Clear&lt;br /&gt;        Set objWMI = Nothing&lt;br /&gt;        retval = "*** unavailable ***"&lt;br /&gt;    Else&lt;br /&gt;        Set objWmiCS = objWmi.ExecQuery("select * from Win32_ComputerSystemProduct")&lt;br /&gt;        For Each obj in objWmiCS&lt;br /&gt;            retval = obj.IdentifyingNumber&lt;br /&gt;        Next&lt;br /&gt;        Set objWmiCS = Nothing&lt;br /&gt;        Set objWMI = Nothing&lt;br /&gt;    End If&lt;br /&gt;    AssetNumber = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;wscript.echo AssetNumber("holland")&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5112208763240683599?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5112208763240683599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/vbscript-get-remote-asset-tag-serial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5112208763240683599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5112208763240683599'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/vbscript-get-remote-asset-tag-serial.html' title='VBScript - Get Remote Asset Tag (Serial Number)'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5942278195871162971</id><published>2009-10-03T17:18:00.000-07:00</published><updated>2009-10-03T17:18:04.015-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>BAT - Enable Remote Desktop on Remote Computer</title><content type='html'>Tested on XP, Vista, Windows 7, Windows Server 2003 and Windows Server 2008.&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue; font-family: courier; font-size: 9pt;"&gt;@echo off&lt;br /&gt;if %1=="" (&lt;br /&gt;    goto USAGE&lt;br /&gt;) else (&lt;br /&gt;    goto VERIFY&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;:USAGE&lt;br /&gt;echo ***************************************&lt;br /&gt;echo Usage:&lt;br /&gt;echo enable_remote_desktop.bat [computername]&lt;br /&gt;echo .&lt;br /&gt;echo ***************************************&lt;br /&gt;goto END&lt;br /&gt;&lt;br /&gt;:VERIFY&lt;br /&gt;if EXIST \\%1\c$\windows\system32 (&lt;br /&gt;    goto ENABLE&lt;br /&gt;) else (&lt;br /&gt;    goto OFFLINE&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;:OFFLINE&lt;br /&gt;echo ***************************************&lt;br /&gt;echo %1 is not accessible&lt;br /&gt;echo check the name and try again or ensure&lt;br /&gt;echo the client is online and firewall is&lt;br /&gt;echo not preventing access&lt;br /&gt;echo ***************************************&lt;br /&gt;goto END&lt;br /&gt;&lt;br /&gt;:ENABLE&lt;br /&gt;echo Configuring registry setting on %1...&lt;br /&gt;REG ADD \\%1\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server /v fDenyTSConnections /t REG_DWORD /d 0 /f&lt;br /&gt;rem goto REBOOT&lt;br /&gt;echo %1 has been configured&lt;br /&gt;goto END&lt;br /&gt;&lt;br /&gt;:REBOOT&lt;br /&gt;echo Requesting a restart of %1...&lt;br /&gt;shutdown -m \\%1 -r -f -t 5&lt;br /&gt;echo Request submitted.  Please allow a few minutes before&lt;br /&gt;echo attempting to connect via remote desktop.&lt;br /&gt;goto END&lt;br /&gt;&lt;br /&gt;:END&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5942278195871162971?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5942278195871162971/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/bat-enable-remote-desktop-on-remote.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5942278195871162971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5942278195871162971'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/10/bat-enable-remote-desktop-on-remote.html' title='BAT - Enable Remote Desktop on Remote Computer'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2402186807024577948</id><published>2009-09-29T17:46:00.000-07:00</published><updated>2009-09-29T17:46:38.062-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='textpad'/><title type='text'>TextPad Syntax and Clip Libraries for Scripting</title><content type='html'>I&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;'ve had my TextPad syntax definitions and clip libraries posted online for ASP, PHP, BAT/CMD, KiXtart, PowerShell, and VBScript for almost a year now. &amp;nbsp;But they've moved to a new location: &lt;a href="http://sites.google.com/site/skatterbrainz"&gt;http://sites.google.com/site/skatterbrainz&lt;/a&gt; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I've also updated many of them recently, so if you ever tried them, you might try them again. &amp;nbsp;Then again, if you don't care, well...&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2402186807024577948?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2402186807024577948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/textpad-syntax-and-clip-libraries-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2402186807024577948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2402186807024577948'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/textpad-syntax-and-clip-libraries-for.html' title='TextPad Syntax and Clip Libraries for Scripting'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-3691853151322843471</id><published>2009-09-25T17:52:00.001-07:00</published><updated>2009-09-25T17:54:09.900-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='forms'/><category scheme='http://www.blogger.com/atom/ns#' term='listbox'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='select'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='arrays'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>Poor Mans Nested Array Splitting</title><content type='html'>&lt;p&gt;Some will laugh.&amp;#160; Some will scoff.&amp;#160; Some will snort and then realize they accidentally blew a booger on their shirt and say “oh damn”.&amp;#160; Oh well, here goes…&lt;/p&gt;  &lt;pre style="color: #8000ff; font-size: 9pt"&gt;&amp;lt;%&lt;br /&gt;Const myList = &amp;quot;1=RED,2=YELLOW,3=GREEN,4=CYAN,5=BLUE,6=MAGENTA&amp;quot;&lt;br /&gt;&lt;br /&gt;Sub ColorNumList(default)&lt;br /&gt;    For each pair in Split(myList, &amp;quot;,&amp;quot;)&lt;br /&gt;        x = Split(pair, &amp;quot;=&amp;quot;)&lt;br /&gt;        If Cstr(default) = x(0) Then&lt;br /&gt;            Response.Write &amp;quot;&amp;lt;option value=&amp;quot; &amp;amp; x(0) &amp;amp; _&lt;br /&gt;            &amp;quot; selected&amp;gt;&amp;quot; &amp;amp; x(1) &amp;amp; &amp;quot;&amp;lt;/option&amp;gt;&amp;quot;&lt;br /&gt;        Else&lt;br /&gt;            Response.Write &amp;quot;&amp;lt;option value=&amp;quot; &amp;amp; x(0) &amp;amp; _&lt;br /&gt;            &amp;quot;&amp;gt;&amp;quot; &amp;amp; x(1) &amp;amp; &amp;quot;&amp;lt;/option&amp;gt;&amp;quot;&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;End Sub&lt;br /&gt;%&amp;gt;&lt;/pre&gt;&lt;br /&gt;To use this, you simply insert it within a matching set of ASP code tags inside of a &amp;lt;select&amp;gt;&amp;lt;/select&amp;gt; form object tag set: &lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue; font-size: 9pt"&gt;...&lt;br /&gt;&amp;lt;select name=&amp;quot;colornum&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;    &lt;font color="#8000ff"&gt;&amp;lt;% ColorNumList 3 %&amp;gt;&lt;/font&gt;&lt;br /&gt;&amp;lt;/select&amp;gt;&lt;br /&gt;...&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-3691853151322843471?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/3691853151322843471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/poor-mans-nested-array-splitting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3691853151322843471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3691853151322843471'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/poor-mans-nested-array-splitting.html' title='Poor Mans Nested Array Splitting'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7062461448296430004</id><published>2009-09-24T18:01:00.000-07:00</published><updated>2009-09-24T18:01:09.890-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='group policy'/><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Group Policy: Hide Locked User Display on Windows 7</title><content type='html'>While I did show how to set this in the registry using various script options (Daniel Petri demonstrated it first by using the registry editor), there is a MUCH easier way: Group Policy.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="color: blue;"&gt;Computer Configuration&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="color: blue;"&gt;...Policies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp; ...Windows Settings&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;...Security Settings&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...Local Policies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...Security Options:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: red;"&gt;Interactive logon: Display user information when the session is locked&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Enable --&amp;gt; &lt;span style="color: magenta;"&gt;"Do not display user information"&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7062461448296430004?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7062461448296430004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/group-policy-hide-locked-user-display.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7062461448296430004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7062461448296430004'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/group-policy-hide-locked-user-display.html' title='Group Policy: Hide Locked User Display on Windows 7'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5432069580764349775</id><published>2009-09-24T17:55:00.000-07:00</published><updated>2009-09-24T17:55:13.079-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>Registry: Hide Locked User Name on Windows 7</title><content type='html'>Borrowing from Daniel Petri's post on how to hide the display of the logged-on user when a Windows 7 computer is locked, I wanted to try to do this in different languages/scripts for the hell of it.&lt;br /&gt;&lt;br /&gt;CMD console using REG.exe...&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue; font-size: 9pt;"&gt;REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DontDisplayLockedUserId /t REG_DWORD /d 3 /f&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;VBScript using Registry object...&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue; font-size: 9pt;"&gt;Const HKEY_LOCAL_MACHINE = &amp;amp;H80000002&lt;br /&gt;&lt;span style="color: #6aa84f;"&gt;' more at http://msdn2.microsoft.com/en-us/library/aa394600.aspx&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sub AddKey(strComputer, strKeyPath)&lt;br /&gt;    Set objReg=GetObject( _&lt;br /&gt;        "winmgmts:{impersonationLevel=impersonate}!\\" &amp;amp; _&lt;br /&gt;        strComputer &amp;amp; "\root\default:StdRegProv")&lt;br /&gt;    objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath&lt;br /&gt;End Sub&lt;br /&gt;&lt;a href="javascript:void(0)"&gt;Post Options&lt;/a&gt;&lt;br /&gt;Sub AddDWValue(strComputer, strKeyPath, strValueName, iValue)&lt;br /&gt;    Set objReg=GetObject( _&lt;br /&gt;        "winmgmts:{impersonationLevel=impersonate}!\\" &amp;amp; _&lt;br /&gt;        strComputer &amp;amp; "\root\default:StdRegProv")&lt;br /&gt; objReg.SetDWordValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, iValue&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Const k = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"&lt;br /&gt;AddKey "Computer1", k&lt;br /&gt;AddDWValue "Computer1", k, "DontDisplayLockedUserId", 3&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;KiXtart...&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue; font-size: 9pt;"&gt;$k = "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System"&lt;br /&gt;$=WriteValue($k, "DontDisplayLockedUserId", 3, "REG_DWORD")&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This was thrown together pretty quick so it might need tweaking.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5432069580764349775?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5432069580764349775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/registry-hide-locked-user-name-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5432069580764349775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5432069580764349775'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/registry-hide-locked-user-name-on.html' title='Registry: Hide Locked User Name on Windows 7'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-8606174839296827552</id><published>2009-09-24T17:27:00.000-07:00</published><updated>2009-09-24T17:27:18.820-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>VBScript - Get Previous / Next Month Names</title><content type='html'>&lt;pre style="font-size:9pt; color:blue"&gt;Function NextMonthName(dateval)&lt;br /&gt;    Dim tmp : tmp = DateAdd("m", 1, dateval)&lt;br /&gt;    NextMonthName = MonthName(Month(tmp))&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Function PrevMonthName(dateval)&lt;br /&gt;    Dim tmp : tmp = DateAdd("m", -1, dateval)&lt;br /&gt;    PrevMonthName = MonthName(Month(tmp))&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-8606174839296827552?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/8606174839296827552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/vbscript-get-previous-next-month-names.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8606174839296827552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8606174839296827552'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/vbscript-get-previous-next-month-names.html' title='VBScript - Get Previous / Next Month Names'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-3877537115132726000</id><published>2009-09-24T15:12:00.001-07:00</published><updated>2009-09-24T15:12:19.558-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>VBScript - Checking for a Valid Date</title><content type='html'>&lt;pre style="font-size:9pt; color:blue"&gt;Function DateValid(dv)&lt;br /&gt;    Dim retval : retval = ""&lt;br /&gt;    On Error Resume Next&lt;br /&gt;    retval = FormatDateTime(dv, vbShortDate)&lt;br /&gt;    If err.Number = 0 Then&lt;br /&gt;        DateValid = True&lt;br /&gt;    End If&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-3877537115132726000?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/3877537115132726000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/vbscript-checking-for-valid-date.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3877537115132726000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3877537115132726000'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/vbscript-checking-for-valid-date.html' title='VBScript - Checking for a Valid Date'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-3492830275664760059</id><published>2009-09-22T16:53:00.001-07:00</published><updated>2009-09-22T16:53:32.464-07:00</updated><title type='text'>VBScript CDOsys Message Sending</title><content type='html'>&lt;pre style="color: blue; font-size: 9pt"&gt;'------------------------------------------------------&lt;br /&gt;' Send CDONTS email in ASCII text or HTML format&lt;br /&gt;'------------------------------------------------------&lt;br /&gt;Const mailServer = &amp;quot;mailserver.domain.com&amp;quot;&lt;br /&gt;&lt;br /&gt;Sub SendMail(sendto, sendfrom, subjectline, msgBody, msgFormat)&lt;br /&gt;    If (sendto &amp;lt;&amp;gt; &amp;quot;&amp;quot;) and (sendfrom &amp;lt;&amp;gt; &amp;quot;&amp;quot;) and (subjectline &amp;lt;&amp;gt; &amp;quot;&amp;quot;) and (msgBody &amp;lt;&amp;gt; &amp;quot;&amp;quot;) Then&lt;br /&gt;        Dim objMessage&lt;br /&gt;        Set objMessage = Server.CreateObject(&amp;quot;CDO.Message&amp;quot;)&lt;br /&gt;        objMessage.Subject = subjectline&lt;br /&gt;        objMessage.From  = sendfrom&lt;br /&gt;        objMessage.To = sendto&lt;br /&gt;        If msgFormat = &amp;quot;TEXT&amp;quot; Then&lt;br /&gt;            objMessage.TextBody = msgBody&lt;br /&gt;        Else&lt;br /&gt;            objMessage.HTMLBody = msgBody&lt;br /&gt;        End If&lt;br /&gt;        objMessage.Configuration.Fields.Item _&lt;br /&gt;            (&amp;quot;http://schemas.microsoft.com/cdo/configuration/sendusing&amp;quot;) = 2&lt;br /&gt;        objMessage.Configuration.Fields.Item _&lt;br /&gt;            (&amp;quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&amp;quot;) = mailServer&lt;br /&gt;        objMessage.Configuration.Fields.Item _&lt;br /&gt;            (&amp;quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&amp;quot;) = 25&lt;br /&gt;        objMessage.Configuration.Fields.Update&lt;br /&gt;        objMessage.Send&lt;br /&gt;        Set objMessage = Nothing&lt;br /&gt;    Else&lt;br /&gt;        wscript.echo &amp;quot;error: insufficient parameters (sendmail)&amp;quot;&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-3492830275664760059?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/3492830275664760059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/vbscript-cdosys-message-sending.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3492830275664760059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3492830275664760059'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/vbscript-cdosys-message-sending.html' title='VBScript CDOsys Message Sending'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7602088396913129137</id><published>2009-09-22T16:52:00.000-07:00</published><updated>2009-09-22T16:57:41.216-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><title type='text'>Windows Defrag From a Script to a Script and Back Again</title><content type='html'>&lt;p&gt;Sometimes you just have to unscrew your brain, take it out, set it down on the toilet lid and say “what the hell”.&amp;#160; Let’s just say, let’s… that we want to run the DEFRAG command using the /A option to just analyze a volume and somehow we’d like to be able to programmatically (that’s a big word) capture that output and automate something with that mess.&amp;#160; Let’s just say.&lt;/p&gt;  &lt;p&gt;The command line might look like &lt;font color="#ff0000"&gt;defrag c: /a /v &amp;gt;defrag.txt&lt;/font&gt;.&amp;#160; But we’d like to be able to schedule this to run at a certain after-hours time and maybe do something like send an email if the results meet some weird crack-infested condition we dreamed up while eating shrimp cocktail and downing four or five cold ones.&lt;/p&gt;  &lt;p&gt;The output of this command might look like this…&lt;/p&gt;  &lt;pre style="color: darkgreen; font-size: 9pt"&gt;Microsoft Disk Defragmenter&lt;br /&gt;Copyright (c) 2007 Microsoft Corp.&lt;br /&gt;&lt;br /&gt;Invoking analysis on (C:)...&lt;br /&gt;&lt;br /&gt;The operation completed successfully.&lt;br /&gt;&lt;br /&gt;Post Defragmentation Report:&lt;br /&gt;&lt;br /&gt;        Volume Information:&lt;br /&gt;                Volume size                 = 74.40 GB&lt;br /&gt;                Cluster size                = 4 KB&lt;br /&gt;                Used space                  = 24.78 GB&lt;br /&gt;                Free space                  = 49.61 GB&lt;br /&gt;&lt;br /&gt;        Fragmentation:&lt;br /&gt;                Total fragmented space      = 2%&lt;br /&gt;                Average fragments per file  = 1.08&lt;br /&gt;&lt;br /&gt;                Movable files and folders   = 75092&lt;br /&gt;                Unmovable files and folders = 45&lt;br /&gt;&lt;br /&gt;        Files:&lt;br /&gt;                Fragmented files            = 2197&lt;br /&gt;                Total file fragments        = 4809&lt;br /&gt;&lt;br /&gt;        Folders:&lt;br /&gt;                Total folders               = 15288&lt;br /&gt;                Fragmented folders          = 14&lt;br /&gt;                Total folder fragments      = 43&lt;br /&gt;&lt;br /&gt;        Free space:&lt;br /&gt;                Free space count            = 1805&lt;br /&gt;                Average free space size     = 28.14 MB&lt;br /&gt;                Largest free space size     = 30.62 GB&lt;br /&gt;&lt;br /&gt;        Master File Table (MFT):&lt;br /&gt;                MFT size                    = 76.50 MB&lt;br /&gt;                MFT record count            = 78335&lt;br /&gt;                MFT usage                   = 100%&lt;br /&gt;                Total MFT fragments         = 2&lt;br /&gt;&lt;br /&gt;        Note: File fragments larger than 64MB are not included in the fragmentation statistics.&lt;br /&gt;&lt;br /&gt;        You do not need to defragment this volume.&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So, how can we do this automation gyration prognostication?&amp;#160; Easy.&amp;#160; Using VBScript, FileSystemObject, the Shell object and some coffee, duct tape and a slice of cold pizza, we might arrive at this…&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: blue; font-size: 9pt"&gt;Const inputFile = &amp;quot;c:\windows\temp\defrag.txt&amp;quot;&lt;br /&gt;Const cmd = &amp;quot;cmd /c defrag c: /a /v&amp;quot;&lt;br /&gt;Const ForReading = 1&lt;br /&gt;Const ForWriting = 2&lt;br /&gt;&lt;br /&gt;Dim objFSO, objFile, strLine, objShell, parse&lt;br /&gt;Dim label, data&lt;br /&gt;&lt;br /&gt;Set objFSO   = CreateObject(&amp;quot;Scripting.FileSystemObject&amp;quot;)&lt;br /&gt;Set objShell = CreateObject(&amp;quot;Wscript.Shell&amp;quot;)&lt;br /&gt;&lt;br /&gt;wscript.echo &amp;quot;info: running defrag analysis on c: drive...&amp;quot;&lt;br /&gt;objShell.Run cmd &amp;amp; &amp;quot; &amp;gt;&amp;quot; &amp;amp; inputFile, 1, True&lt;br /&gt;wscript.echo &amp;quot;info: defrag completed&amp;quot;&lt;br /&gt;&lt;br /&gt;wscript.echo &amp;quot;info: checking if input file was created...&amp;quot;&lt;br /&gt;&lt;br /&gt;If objFSO.FileExists(inputFile) Then&lt;br /&gt;    wscript.echo &amp;quot;info: file was found, opening for input...&amp;quot;&lt;br /&gt;    Set objFile = objFSO.OpenTextFile(inputFile, ForReading)&lt;br /&gt;    Do Until objFile.AtEndOfStream&lt;br /&gt;        strLine = Trim(objFile.Readline)&lt;br /&gt;        If InStr(1, strLine, &amp;quot;=&amp;quot;) &amp;lt;&amp;gt; 0 Then&lt;br /&gt;            strLine = Replace(strLine, vbTab, &amp;quot;&amp;quot;)&lt;br /&gt;            parse = Split(strLine, &amp;quot;=&amp;quot;)&lt;br /&gt;            label = Trim(parse(0))&lt;br /&gt;            data  = Trim(parse(1))&lt;br /&gt;            wscript.echo label &amp;amp; vbTab &amp;amp; data&lt;br /&gt;        End If&lt;br /&gt;    Loop&lt;br /&gt;    objFile.Close&lt;br /&gt;Else&lt;br /&gt;    wscript.echo &amp;quot;fail: input file not found&amp;quot;&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set objFSO = Nothing&lt;br /&gt;Set objShell = Nothing&lt;br /&gt;&lt;br /&gt;wscript.echo &amp;quot;info: processing complete&amp;quot;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The output might look like this…&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="color: darkgreen; font-size: 9pt"&gt;info: running defrag analysis on c: drive...&lt;br /&gt;info: defrag completed&lt;br /&gt;info: checking if input file was created...&lt;br /&gt;info: file was found, opening for input...&lt;br /&gt;Volume size     74.40 GB&lt;br /&gt;Cluster size    4 KB&lt;br /&gt;Used space      24.78 GB&lt;br /&gt;Free space      49.61 GB&lt;br /&gt;Total fragmented space  2%&lt;br /&gt;Average fragments per file      1.08&lt;br /&gt;Movable files and folders       75096&lt;br /&gt;Unmovable files and folders     43&lt;br /&gt;Fragmented files        2197&lt;br /&gt;Total file fragments    4810&lt;br /&gt;Total folders   15288&lt;br /&gt;Fragmented folders      14&lt;br /&gt;Total folder fragments  43&lt;br /&gt;Free space count        1802&lt;br /&gt;Average free space size 28.19 MB&lt;br /&gt;Largest free space size 30.62 GB&lt;br /&gt;MFT size        76.50 MB&lt;br /&gt;MFT record count        78335&lt;br /&gt;MFT usage       100%&lt;br /&gt;Total MFT fragments     2&lt;br /&gt;info: processing complete&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now you can insert some code to send email &lt;a href="http://scriptzilla.blogspot.com/2009/09/vbscript-cdosys-message-sending.html" target="_blank"&gt;using CDOsys&lt;/a&gt; (or whatever you prefer) or send some info to a database table.&amp;#160; Then wrap all that up with a tuna sandwich, some fries and a cold drink and you’re off.&amp;#160; Sure, you can do a lot of this with WMI directly and that works too.&amp;#160; But sometimes there are command console utilities that do things WMI doesn’t do as easily (or simply), so you have options like this (capture the output and then parse back into your script to process further).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Options: You can modify this easily to output XML, INI or just about any text format you desire.&amp;#160; You can also pipe it into another script, or pump it into a database.&amp;#160; You can also wrap it into an email and send it.&amp;#160; Or, because you can capture each line and check the “label” string value, you can check for “Total fragmented space” and if it’s greater than some percentage value, fire an email alert.&amp;#160; The take away here is that you can do just about anything you want.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7602088396913129137?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7602088396913129137/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/windows-defrag-from-script-to-script.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7602088396913129137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7602088396913129137'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/windows-defrag-from-script-to-script.html' title='Windows Defrag From a Script to a Script and Back Again'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4548935676112182765</id><published>2009-09-19T07:45:00.000-07:00</published><updated>2009-09-19T07:45:24.597-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='thoughts'/><category scheme='http://www.blogger.com/atom/ns#' term='editorial'/><title type='text'>Back from the Brink of something</title><content type='html'>What is a "brink" anyway?&lt;br /&gt;Web dictionaries describe it as a "region marking a boundary". &amp;nbsp;But what is a "boundary"? &amp;nbsp;For that matter, what is a "region"? &amp;nbsp;I could go on, but who cares. &amp;nbsp;This is where I'll be posting script stuff. &amp;nbsp;Again. &amp;nbsp;And for those who got pissed off at me last time: &amp;nbsp;Too Fkking bad.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4548935676112182765?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4548935676112182765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/back-from-brink-of-something.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4548935676112182765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4548935676112182765'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/09/back-from-brink-of-something.html' title='Back from the Brink of something'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4820765408202420365</id><published>2009-07-15T12:21:00.000-07:00</published><updated>2009-07-15T12:35:22.466-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><category scheme='http://www.blogger.com/atom/ns#' term='editorial'/><category scheme='http://www.blogger.com/atom/ns#' term='business'/><title type='text'>Packaging Gone Awry?</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;What's up with packaging these days?  It seems every manufacturer, container shipper, and postal carrier entity is experimenting with new ways to package things.  Some are borderline clever.  Some are just outright dumb.   This goes beyond the pack-and-ship aspects.  I'm also talking about how desktop and laptop computers are assembled. &lt;br /&gt;&lt;br /&gt;Since 2000, I've counted no less than two dozen unique assembly methods used by Dell and HP alone.  Screws, thumb-screws, clips, snaps, notches, latches, folding, sliding, lifting, pulling.  You name it.  What's up with that?  Why screws anyway?  As if the little toy-like lock hasps are any deterrent to thieves and tinkerers.  Just make the cases snap together and be done with it.  And if you look at the insides of a computer, oh geez.  One minute of gazing and you can easily spot a half-dozen fabrication head-scratchers.  Things that make you ask "why do it that way?"&lt;br /&gt;&lt;br /&gt;I'm not talking about complicated things either.  This applies to simple boxes like the power supply, cd/dvd drives and backplanes.  The costs being wasted by overly complicated fastening methods, attachment methods, alignment methods, and so on, is just insane.  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight:bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The reason in most cases is patent blocking&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.  Someone holds patents on the simplest methods and won't play nice with the big players anymore.  So they do their own and it ends up being a clusterf**k.  Given that not one single manufacturer uses a common-sense assembly approach (except for maybe Apple, in some cases, pardon the pun) I am wondering if it's the patent holder that's to blame.  Demanding too high of a price for licensing.  Or maybe they just don't want to play at all.  Who knows.  We're paying the price, both literally and indirectly (ripping our fingers on the sharp edges, contorting to plug things in).  Progress and innovation have been tossed into a cell and locked up by attorneys.  The 20th century was all about making new things.  The 21st century is shaping up to be about protecting things, pure and simple.  RIP innovation.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4820765408202420365?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4820765408202420365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/packaging-gone-awry.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4820765408202420365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4820765408202420365'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/packaging-gone-awry.html' title='Packaging Gone Awry?'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7790754496325461476</id><published>2009-07-14T18:58:00.001-07:00</published><updated>2009-07-14T19:03:43.922-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='user accounts'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='ldap'/><title type='text'>VBScript Query All Domain Controllers for a User Account Status</title><content type='html'>Query all domain controllers for the status of a specified user account.  This can come in handy when there are suspected replication problems in AD and some domain controllers are not up to date on a given account (locked, disabled, modified, etc.).&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Const userid = "ServiceAccount20"&lt;br /&gt;Const ou = "OU=ServiceAccounts,OU=IT,OU=Corp,DC=contoso,DC=com"&lt;br /&gt;&lt;br /&gt;Const pageSize = 1000&lt;br /&gt;Const ADS_SCOPE_SUBTREE = 2&lt;br /&gt;&lt;br /&gt;Set dso = GetObject("LDAP:")&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Function Domain_LDAP()&lt;br /&gt;    Dim retval, objRootDSE&lt;br /&gt;    Set objRootDSE = GetObject("LDAP://RootDSE")&lt;br /&gt;    retval = objRootDSE.Get("defaultNamingContext")&lt;br /&gt;    Domain_LDAP = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' function: &lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Function CName(strval)&lt;br /&gt;    Dim tmp&lt;br /&gt;    tmp = Replace(strval, "CN=NTDS Settings,CN=", "")&lt;br /&gt;    CName = Split(tmp, ",")(0)&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' function: &lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Function DomainControllers()&lt;br /&gt;    Dim objConnection, objCommand, objRecordSet&lt;br /&gt;    Dim dn, retval : retval = ""&lt;br /&gt;&lt;br /&gt;    dcn = Domain_LDAP()&lt;br /&gt;&lt;br /&gt;    Set objConnection = CreateObject("ADODB.Connection")&lt;br /&gt;    Set objCommand = CreateObject("ADODB.Command")&lt;br /&gt;    objConnection.Provider = "ADsDSOObject"&lt;br /&gt;    objConnection.Properties("ADSI Flag") = 1&lt;br /&gt;    objConnection.Open "Active Directory Provider"&lt;br /&gt;&lt;br /&gt;    Set objCommand.ActiveConnection = objConnection&lt;br /&gt;&lt;br /&gt;    objCommand.CommandText = _&lt;br /&gt;        "SELECT distinguishedName FROM " &amp; _&lt;br /&gt;        "'LDAP://cn=Configuration," &amp; dcn &amp; "' " &amp; _&lt;br /&gt;        "WHERE objectClass='nTDSDSA'"&lt;br /&gt;&lt;br /&gt;    objCommand.Properties("Page Size") = pageSize&lt;br /&gt;    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE&lt;br /&gt;&lt;br /&gt;    Set objRecordSet = objCommand.Execute&lt;br /&gt;    objRecordSet.MoveFirst&lt;br /&gt;&lt;br /&gt;    wscript.echo "info: querying for list of domain controllers..."&lt;br /&gt;&lt;br /&gt;    Do Until objRecordSet.EOF&lt;br /&gt;        dn = objRecordSet.Fields("distinguishedName").Value&lt;br /&gt;        If retval &lt;&gt; "" Then&lt;br /&gt;            retval = retval &amp; vbTab &amp; dn&lt;br /&gt;        Else&lt;br /&gt;            retval = dn&lt;br /&gt;        End If&lt;br /&gt;        objRecordSet.MoveNext&lt;br /&gt;    Loop&lt;br /&gt;    DomainControllers = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;wscript.echo "info: user account = " &amp; userid&lt;br /&gt;dclist = DomainControllers()&lt;br /&gt;&lt;br /&gt;wscript.echo "info: querying user account status from each domain controller..."&lt;br /&gt;&lt;br /&gt;For each strDC in Split(dclist, vbTab)&lt;br /&gt;    cn = CName(strDC)&lt;br /&gt;    dcn = Replace(strDC, "CN=NTDS Settings,", "")&lt;br /&gt; &lt;br /&gt;    Set objUser = GetObject("LDAP://" &amp; cn &amp; "/CN=" &amp; userid &amp; "," &amp; ou)&lt;br /&gt;    On Error Resume Next&lt;br /&gt; &lt;br /&gt;    ' refer to http://support.microsoft.com/kb/305144&lt;br /&gt; &lt;br /&gt;    uac = objUser.Get("userAccountControl")&lt;br /&gt;    If err.Number &lt;&gt; 0 Then&lt;br /&gt;        wscript.echo err.Number &amp; " - " &amp; err.Description&lt;br /&gt;    Else&lt;br /&gt;        ' add more cases below if you prefer, or logand the results&lt;br /&gt;        Select Case uac&lt;br /&gt;            Case 512: wscript.echo "info: " &amp; cn &amp; " = normal"&lt;br /&gt;            Case 16: wscript.echo "info: " &amp; cn &amp; " = locked"&lt;br /&gt;            Case 2: wscript.echo "info: " &amp; cn &amp; " = disabled"&lt;br /&gt;            Case 65536: wscript.echo "info: " &amp; cn &amp; " = never-expires"&lt;br /&gt;            Case Else: wscript.echo "info: " &amp; cn &amp; " = unknown: " &amp; uac&lt;br /&gt;        End Select&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7790754496325461476?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7790754496325461476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-query-all-domain-controllers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7790754496325461476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7790754496325461476'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-query-all-domain-controllers.html' title='VBScript Query All Domain Controllers for a User Account Status'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7069407615233565473</id><published>2009-07-14T18:44:00.000-07:00</published><updated>2009-07-14T18:50:48.941-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='user accounts'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='ldap'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP Secure LDAP Query of User Group Membership</title><content type='html'>Check if a user is a member of a specified domain security group using a secure LDAP query with ADsDSoObject provider.  Works for ASP and VBScript using a specified domain service/proxy user account (when anonymous LDAP is disabled).&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt; color:green"&gt;&lt;br /&gt;Example:&lt;br /&gt;If IsMemberOf("SalesManagers", "JohnDoe") Then&lt;br /&gt;    Response.Write "is a member"&lt;br /&gt;End If&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Const ldap_user = "domain\useraccount"&lt;br /&gt;Const ldap_pwd  = "P@ssW0rd$"&lt;br /&gt;Const ou = "OU=Sales,OU=North America,OU=Corp,DC=contoso,DC=com"&lt;br /&gt;Const ADS_SCOPE_SUBTREE = 2&lt;br /&gt;&lt;br /&gt;Function IsMemberOf(groupName, uid)&lt;br /&gt;    Dim objConnection, objCommand, objRecordSet&lt;br /&gt;    Dim retval : retval = False&lt;br /&gt;    Dim i, gplen : gplen = Len(groupName)+3&lt;br /&gt; &lt;br /&gt;    On Error Resume Next&lt;br /&gt;    Set objConnection = CreateObject("ADODB.Connection")&lt;br /&gt;    Set objCommand =   CreateObject("ADODB.Command")&lt;br /&gt; &lt;br /&gt;    objConnection.Provider = "ADsDSOObject"&lt;br /&gt;    objConnection.Properties("User ID")  = ldap_user&lt;br /&gt;    objConnection.Properties("Password") = ldap_pwd&lt;br /&gt;    objConnection.Properties("Encrypt Password") = TRUE&lt;br /&gt;    objConnection.Properties("ADSI Flag") = 1&lt;br /&gt;    objConnection.Open "Active Directory Provider"&lt;br /&gt;&lt;br /&gt;    Set objCommand.ActiveConnection = objConnection&lt;br /&gt;&lt;br /&gt;    objCommand.Properties("Page Size") = 1000&lt;br /&gt;    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE&lt;br /&gt;    objCommand.CommandText = "SELECT memberof FROM 'LDAP://" &amp; ou &amp; "' " &amp; _&lt;br /&gt;        "WHERE objectCategory='user' AND sAMAccountName='" &amp; uid &amp; "'"&lt;br /&gt;&lt;br /&gt;    Set objRecordSet = objCommand.Execute&lt;br /&gt;&lt;br /&gt;    objRecordSet.MoveFirst&lt;br /&gt;    Do Until objRecordSet.EOF&lt;br /&gt;        For i = 0 to objRecordSet.Fields.Count -1&lt;br /&gt;            For each m in objRecordSet.Fields("memberof").value&lt;br /&gt;                If Left(Ucase(m),gplen) = Ucase("CN=" &amp; groupname) Then&lt;br /&gt;                    retval = True&lt;br /&gt;                End If&lt;br /&gt;            Next&lt;br /&gt;        Next&lt;br /&gt;        objRecordSet.MoveNext&lt;br /&gt;    Loop&lt;br /&gt;    objRecordSet.Close&lt;br /&gt;    Set objRecordSet = Nothing&lt;br /&gt;    Set objCommand = Nothing&lt;br /&gt;    Set objConnection = Nothing&lt;br /&gt;    IsMemberOf = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7069407615233565473?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7069407615233565473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-secure-ldap-query-of-user.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7069407615233565473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7069407615233565473'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-secure-ldap-query-of-user.html' title='VBScript / ASP Secure LDAP Query of User Group Membership'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4369667223075714665</id><published>2009-07-14T18:34:00.001-07:00</published><updated>2009-07-14T18:53:05.561-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='user accounts'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='ldap'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP Secure LDAP User Query</title><content type='html'>Query Active Directory using a service/proxy user account from within VBScript or an ASP web page.  Returns results as a tab-delimited string, where each token is sub-delimited using a pipe character "|".&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt;color:green"&gt;&lt;br /&gt;example:&lt;br /&gt;x = GetUserData("JohnDoe", "ADsPath, mail, department, givenName, sn")&lt;br /&gt; &lt;br /&gt;For each v in Split(x, vbTab)&lt;br /&gt;    response.write Replace(v, "|", " = ") &amp; "&amp;lt;br/&amp;gt;"&lt;br /&gt;Next&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="font-size:8pt;color:blue"&gt;&lt;br /&gt;Const ldap_user = "domain\useraccount"&lt;br /&gt;Const ldap_pwd  = "P@ssW0rd$"&lt;br /&gt;Const ou = "OU=Sales,OU=North America,OU=Corp,DC=contoso,DC=com"&lt;br /&gt;&lt;br /&gt;Function GetUserData(uid, fields)&lt;br /&gt;    Const ADS_SCOPE_SUBTREE = 2&lt;br /&gt;    Dim objConnection, objComment, objRecordSet&lt;br /&gt;    Dim retval : retval = ""&lt;br /&gt;    Dim i, fieldname, strvalue&lt;br /&gt; &lt;br /&gt;    On Error Resume Next&lt;br /&gt;    Set objConnection = CreateObject("ADODB.Connection")&lt;br /&gt;    Set objCommand    = CreateObject("ADODB.Command")&lt;br /&gt; &lt;br /&gt;    objConnection.Provider = "ADsDSOObject"&lt;br /&gt;    objConnection.Properties("User ID")  = ldap_user&lt;br /&gt;    objConnection.Properties("Password") = ldap_pwd&lt;br /&gt;    objConnection.Properties("Encrypt Password") = TRUE&lt;br /&gt;    objConnection.Properties("ADSI Flag") = 1&lt;br /&gt;    objConnection.Open "Active Directory Provider"&lt;br /&gt; &lt;br /&gt;    Set objCommand.ActiveConnection = objConnection&lt;br /&gt;&lt;br /&gt;    objCommand.Properties("Page Size") = 1000&lt;br /&gt;    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE&lt;br /&gt;    objCommand.CommandText = "SELECT " &amp; fields &amp; _&lt;br /&gt;        " FROM 'LDAP://" &amp; ou &amp; "' " &amp; _&lt;br /&gt;        "WHERE objectCategory='user' AND sAMAccountName='" &amp; uid &amp; "'"&lt;br /&gt;&lt;br /&gt;    Set objRecordSet = objCommand.Execute&lt;br /&gt;&lt;br /&gt;    objRecordSet.MoveFirst&lt;br /&gt;    Do Until objRecordSet.EOF&lt;br /&gt;        For i = 0 to objRecordSet.Fields.Count -1&lt;br /&gt;            fieldname = objRecordSet.Fields(i).Name&lt;br /&gt;            strvalue = objRecordSet.Fields(i).Value&lt;br /&gt;            If retval &lt;&gt; "" Then&lt;br /&gt;                retval = retval &amp; vbTab &amp; fieldname &amp; "|" &amp; strValue&lt;br /&gt;            Else&lt;br /&gt;                retval = fieldname &amp; "|" &amp; strValue&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        objRecordSet.MoveNext&lt;br /&gt;    Loop&lt;br /&gt;    GetUserData = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4369667223075714665?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4369667223075714665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-security-ldap-user-query.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4369667223075714665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4369667223075714665'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-security-ldap-user-query.html' title='VBScript / ASP Secure LDAP User Query'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5080804734969693269</id><published>2009-07-13T16:28:00.000-07:00</published><updated>2009-07-13T16:30:56.819-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='ldap'/><title type='text'>VBScript Enumerate AD OUs and Containers</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Dim objDSE, strDefaultDN, strDN, objContainer, objChild&lt;br /&gt;Const enumContainersAlso = False&lt;br /&gt;&lt;br /&gt;Set objRootDSE = GetObject("LDAP://rootDSE")&lt;br /&gt;strDefaultDN = Domain_LDAP()&lt;br /&gt;Set objContainer = GetObject("LDAP://" &amp; strDefaultDN)&lt;br /&gt;&lt;br /&gt;Call ListObjects(objContainer, "")&lt;br /&gt;&lt;br /&gt;Function Domain_LDAP()&lt;br /&gt;    Dim retval&lt;br /&gt;    retval = objRootDSE.Get("defaultNamingContext")&lt;br /&gt;    Domain_LDAP = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Function Domain_NetBIOS(ldapdn)&lt;br /&gt; Domain_NetBIOS = Replace(Replace(ldapdn,"DC=",""),",",".")&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Sub ListObjects(objADObject, strSpace)&lt;br /&gt;    Dim objChild&lt;br /&gt;    For Each objChild in objADObject&lt;br /&gt;        Select Case objChild.Class&lt;br /&gt;            Case "organizationalUnit":&lt;br /&gt;                objName = Mid(objChild.Name,4)&lt;br /&gt;                objContainer = objChild.distinguishedName&lt;br /&gt;                wscript.echo strSpace &amp; "(o) " &amp; objName&lt;br /&gt;                Call ListObjects(objChild, "....")&lt;br /&gt;            Case "container":&lt;br /&gt;                If enumContainersAlso Then&lt;br /&gt;                    objName = Mid(objChild.Name,4)&lt;br /&gt;                    objContainer = objChild.distinguishedName&lt;br /&gt;                    wscript.echo strSpace &amp; "(c) " &amp; objName&lt;br /&gt;                End If&lt;br /&gt;                Call ListObjects(objChild, "....")&lt;br /&gt;        End Select&lt;br /&gt;    Next&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5080804734969693269?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5080804734969693269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-enumerate-ad-ous-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5080804734969693269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5080804734969693269'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-enumerate-ad-ous-and.html' title='VBScript Enumerate AD OUs and Containers'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5852406417305535131</id><published>2009-07-13T16:07:00.000-07:00</published><updated>2009-07-13T16:09:15.972-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='ldap'/><title type='text'>VBScript Get Active Directory Environment Data</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Set objRootDSE = GetObject("LDAP://rootDSE")&lt;br /&gt; &lt;br /&gt;wscript.Echo "defaultNamingContext = " &amp; objRootDSE.Get("defaultNamingContext")&lt;br /&gt;wscript.Echo "rootdomainNamingContext = " &amp; objRootDSE.Get("rootDomainNamingContext")&lt;br /&gt;wscript.Echo "configurationNamingContext = " &amp; objRootDSE.Get("configurationNamingContext")&lt;br /&gt;wscript.Echo "dnsHostName = " &amp; objRootDSE.Get("dnsHostName")&lt;br /&gt;wscript.echo "CN: " &amp; GetCN(objRootDSE.Get("defaultNamingContext"))&lt;br /&gt;&lt;br /&gt;Function GetCN(dn)&lt;br /&gt;    Dim retval&lt;br /&gt;    retval = Split(dn, ",")&lt;br /&gt;    GetCN = Mid(retval(0),4)&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5852406417305535131?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5852406417305535131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-get-active-directory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5852406417305535131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5852406417305535131'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-get-active-directory.html' title='VBScript Get Active Directory Environment Data'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-8111761300392051803</id><published>2009-07-12T18:29:00.000-07:00</published><updated>2009-07-12T18:36:18.962-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='editorial'/><category scheme='http://www.blogger.com/atom/ns#' term='apple'/><title type='text'>Editorial: Stupid Damn Apple iPhone Commerical</title><content type='html'>I have to step off the wagon for a moment to bitch about something irritating the living shit out of me:  The latest Apple commercial for the iPhone.  This is the one that brags about being able to copy and paste crap from one place to another.  Such as phone numbers into emails, and so on.&lt;br /&gt;&lt;br /&gt;Really?  For real?!!&lt;br /&gt;&lt;br /&gt;I've been doing that on my cheap, crappy old Blackberry for years.  YEARS!!!!  God damn years!!!&lt;br /&gt;&lt;br /&gt;I have to assume Steve Jobs wasn't consulted about this idea before it went to press.  I can't believe he would have consented to it.  Of all the cool, innovative things the iPhone can do, copy-and-paste is an embarrassing late-comer to the party.  Why would they make a whole commercial for just that one thing?  What next, a commercial that they finally got a multi-button mouse?  &lt;br /&gt;&lt;br /&gt;Yes, I know about the stupid-as-hell "mighty mouse" product.  Ironic that I learned to use a computer in the 1980's using a 16-button digitizer mouse.  It was fantastic!  I could program the buttons to do everything I needed and it saved me a ton of time and effort.  But Apple faggoty fans kept saying that a one-button cyclops mouse was "elegant" and "genius".  Then the Mighty Mouse comes out and those same two-face bastards go on a back-patting spree with testimonials of how Apple re-innovated the concept of a multi-button mouse.  Holy f-ing crap.&lt;br /&gt;&lt;br /&gt;I like Apple.&lt;br /&gt;&lt;br /&gt;I fucking hate Apple fans.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-8111761300392051803?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/8111761300392051803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/editorial-stupid-damn-apple-iphone.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8111761300392051803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8111761300392051803'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/editorial-stupid-damn-apple-iphone.html' title='Editorial: Stupid Damn Apple iPhone Commerical'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4931074515698952979</id><published>2009-07-12T17:42:00.001-07:00</published><updated>2009-07-12T17:44:09.069-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='user accounts'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='ldap'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>LDAP Query for User Accounts Created Since a Specific Date</title><content type='html'>Just modify the date string to use the YYYYMMDDHHMMSS.0Z format.  So, for June 1, 2009, you would specify "20090601000000.0Z"&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;(&amp;amp;(objectCategory=user)(whenCreated&amp;gt;=20090601000000.0Z))&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4931074515698952979?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4931074515698952979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/ldap-query-for-user-accounts-created.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4931074515698952979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4931074515698952979'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/ldap-query-for-user-accounts-created.html' title='LDAP Query for User Accounts Created Since a Specific Date'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-991070453819244106</id><published>2009-07-12T17:38:00.000-07:00</published><updated>2009-07-12T17:40:06.316-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='printers'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='ldap'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>LDAP Query for Printers = HP DesignJet Plotters</title><content type='html'>&lt;pre style=""&gt;&lt;br /&gt;(&amp;amp;(&amp;amp;&lt;br /&gt;(uncName=*)&lt;br /&gt;(objectCategory=printQueue)&lt;br /&gt;(objectCategory=printQueue)&lt;br /&gt;(driverName=*DesignJet*)&lt;br /&gt;))&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-991070453819244106?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/991070453819244106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/ldap-query-for-printers-hp-designjet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/991070453819244106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/991070453819244106'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/ldap-query-for-printers-hp-designjet.html' title='LDAP Query for Printers = HP DesignJet Plotters'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6157459608971296199</id><published>2009-07-12T17:36:00.000-07:00</published><updated>2009-07-12T17:37:38.896-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active directory'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='ldap'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>LDAP Query for Windows Server 2003 SP1 Computers in AD</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;(&amp;amp;(&amp;amp;(&amp;amp;(&amp;amp;(&amp;amp;(&amp;amp;(&amp;amp;(&amp;amp;(&amp;amp;(&amp;amp;&lt;br /&gt;(objectCategory=Computer)&lt;br /&gt;(operatingSystem=Windows Server 2003*)&lt;br /&gt;(operatingSystemServicePack=Service Pack 1)&lt;br /&gt;))))))))))&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6157459608971296199?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6157459608971296199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/ldap-query-for-windows-server-2003-sp1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6157459608971296199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6157459608971296199'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/ldap-query-for-windows-server-2003-sp1.html' title='LDAP Query for Windows Server 2003 SP1 Computers in AD'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6761692905983432424</id><published>2009-07-12T17:33:00.001-07:00</published><updated>2009-07-12T17:34:05.551-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>ASP Get Page Input (Form or QueryString)</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Function GetParam(strLabel)&lt;br /&gt;    Dim retval : retval = ""&lt;br /&gt;    retval = Trim(Request.Form(strLabel))&lt;br /&gt;    If retval = "" Then&lt;br /&gt;        retval = Trim(Request.QueryString(strLabel))&lt;br /&gt;    End If&lt;br /&gt;    GetParam = retval&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6761692905983432424?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6761692905983432424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-get-page-input-form-or-querystring.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6761692905983432424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6761692905983432424'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-get-page-input-form-or-querystring.html' title='ASP Get Page Input (Form or QueryString)'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4584430051862604650</id><published>2009-07-12T17:29:00.000-07:00</published><updated>2009-07-12T17:31:10.319-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP Function to Convert Dates to/from MySQL</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;' MySqlDate(Now, 1) --&gt; "2008-02-20"&lt;br /&gt;' MySqlDate(Now, 2) --&gt; "2/20/2008"&lt;br /&gt;&lt;br /&gt;Function MySqlDate( d, dir )&lt;br /&gt;    If Not isDate( d ) Then d = Date()&lt;br /&gt;    Dim strNewDate&lt;br /&gt;    Select Case dir&lt;br /&gt;        Case 1:&lt;br /&gt;            '=== store in db&lt;br /&gt;            strNewDate = Year( d ) &amp; "-" &amp; Month( d ) &amp; "-" &amp; Day( d )&lt;br /&gt;        Case 2: &lt;br /&gt;            '=== use with asp&lt;br /&gt;            strNewDate = Month( d )&amp; "/"  &amp; Day( d ) &amp; "/" &amp; Year( d )&lt;br /&gt;            strNewDate = cDate( strNewDate )&lt;br /&gt;    End Select&lt;br /&gt;    mysqlDate = strNewDate&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4584430051862604650?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4584430051862604650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-function-to-convert-dates.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4584430051862604650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4584430051862604650'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-function-to-convert-dates.html' title='VBScript / ASP Function to Convert Dates to/from MySQL'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-3399776565485888496</id><published>2009-07-12T17:25:00.000-07:00</published><updated>2009-07-12T17:27:05.308-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>PHP: Determine Zodiac Sign from Birth Date</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;function ZodiacSign($date){&lt;br /&gt;    list($year,$month,$day)=explode("-",$date);&lt;br /&gt;    if (($month==1 &amp;&amp; $day&gt;20)||($month==2 &amp;&amp; $day&lt;20)) {&lt;br /&gt;        return "Aquarius";&lt;br /&gt;    } else if (($month==2 &amp;&amp; $day&gt;18 )||($month==3 &amp;&amp; $day&lt;21)) {&lt;br /&gt;        return "Pisces";&lt;br /&gt;    } else if (($month==3 &amp;&amp; $day&gt;20)||($month==4 &amp;&amp; $day&lt;21)) {&lt;br /&gt;        return "Aries";&lt;br /&gt;    } else if (($month==4 &amp;&amp; $day&gt;20)||($month==5 &amp;&amp; $day&lt;22)) {&lt;br /&gt;        return "Taurus";&lt;br /&gt;    } else if (($month==5 &amp;&amp; $day&gt;21)||($month==6 &amp;&amp; $day&lt;22)) {&lt;br /&gt;        return "Gemini";&lt;br /&gt;    } else if (($month==6 &amp;&amp; $day&gt;21)||($month==7 &amp;&amp; $day&lt;24)) {&lt;br /&gt;        return "Cancer";&lt;br /&gt;    } else if (($month==7 &amp;&amp; $day&gt;23)||($month==8 &amp;&amp; $day&lt;24)) {&lt;br /&gt;        return "Leo";&lt;br /&gt;    } else if (($month==8 &amp;&amp; $day&gt;23)||($month==9 &amp;&amp; $day&lt;24)) {&lt;br /&gt;        return "Virgo";&lt;br /&gt;    } else if (($month==9 &amp;&amp; $day&gt;23)||($month==10 &amp;&amp; $day&lt;24)) {&lt;br /&gt;        return "Libra";&lt;br /&gt;    } else if (($month==10 &amp;&amp; $day&gt;23)||($month==11 &amp;&amp; $day&lt;23)) {&lt;br /&gt;        return "Scorpio";&lt;br /&gt;    } else if (($month==11 &amp;&amp; $day&gt;22)||($month==12 &amp;&amp; $day&lt;23)) {&lt;br /&gt;        return "Sagittarius";&lt;br /&gt;    } else if (($month==12 &amp;&amp; $day&gt;22)||($month==1 &amp;&amp; $day&lt;21)) {&lt;br /&gt;        return "Capricorn";&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-3399776565485888496?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/3399776565485888496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/php-determine-zodiac-sign-from-birth.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3399776565485888496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3399776565485888496'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/php-determine-zodiac-sign-from-birth.html' title='PHP: Determine Zodiac Sign from Birth Date'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-1551602684539298636</id><published>2009-07-12T17:23:00.001-07:00</published><updated>2009-07-12T17:24:39.173-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>PHP: Generate List of U.S. State Abbreviations</title><content type='html'>For form select listbox populating...&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;function StateCodes($deft) {&lt;br /&gt;    $clist = "AL,AK,AS,AZ,AR,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,"&lt;br /&gt;    . "KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NY,"&lt;br /&gt;    . "OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VA,VT,WA,WI,WV,WY";&lt;br /&gt;    $tok = strtok($clist, ",");&lt;br /&gt;    while ($tok != false) {&lt;br /&gt;        if ($deft == $tok) {&lt;br /&gt;            echo "&lt;option selected&gt;$tok&lt;/option&gt;\n";&lt;br /&gt;        }&lt;br /&gt;        else {&lt;br /&gt;            echo "&lt;option&gt;$tok&lt;/option&gt;\n";&lt;br /&gt;        }&lt;br /&gt;        $tok = strtok(",");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-1551602684539298636?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/1551602684539298636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/php-generate-list-of-us-state.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1551602684539298636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1551602684539298636'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/php-generate-list-of-us-state.html' title='PHP: Generate List of U.S. State Abbreviations'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7960734690503087292</id><published>2009-07-11T18:03:00.000-07:00</published><updated>2009-07-11T18:12:17.285-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><title type='text'>KiXtart: Customize OEM Support Information</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;? "[OEMSupportTag].....: Configuring OEM Support applet..."&lt;br /&gt;Dim $oeminfo, $oemlogo, $oemsupp, $x, $regkey&lt;br /&gt;Dim $logfile, $oemlogosrc, $oemsuppsrc&lt;br /&gt;Dim $wmi, $wmi_compsys, $wmi_comp, $model, $desc, $asset&lt;br /&gt;$weblink = "https://intranet.company.com/helpdesk"&lt;br /&gt;&lt;br /&gt;$regkey = "HKLM\System\CurrentControlSet\Control\Windows"&lt;br /&gt;$value = ReadValue($regkey,"SystemDirectory")&lt;br /&gt;$windir = ExpandEnvironmentVars($value)&lt;br /&gt;&lt;br /&gt;If $windir &lt;&gt; ""&lt;br /&gt;    $oeminfo = $windir+"\oeminfo.ini"&lt;br /&gt;    $oemlogo = $windir+"\oemlogo.bmp"&lt;br /&gt;    $oemsupp = $windir+"\web\support.htm"&lt;br /&gt;    $logfile = $windir+"\custom_oem.ini"&lt;br /&gt;    $oemlogosrc = @lserver+"\netlogon\oemlogo.bmp"&lt;br /&gt;    $oemsuppsrc = @lserver+"\netlogon\support.htm"&lt;br /&gt;&lt;br /&gt;    If Exist( $oeminfo ) = 1&lt;br /&gt;        ? "[OEMSupportTag].....: removing existing oeminfo.ini file..."&lt;br /&gt;        Del( $oeminfo )&lt;br /&gt;    Else&lt;br /&gt;        ? "[OEMSupportTag].....: no existing oeminfo.ini file found."&lt;br /&gt;    EndIf&lt;br /&gt;&lt;br /&gt;    ? "[OEMSupportTag].....: attempting to create new oeminfo.ini file..."&lt;br /&gt;    If Open(2, $oeminfo, 5) = 0&lt;br /&gt;        ? "[OEMSupportTag].....: file created successfully, updating contents..."&lt;br /&gt;        $wmi = "WINMGMTS:{IMPERSONATIONLEVEL=IMPERSONATE}!//"+@wksta&lt;br /&gt;        $wmi_compsys = "SELECT * FROM Win32_ComputerSystemProduct"&lt;br /&gt;        $wmi_comp = GetObject($wmi).ExecQuery($wmi_compsys)&lt;br /&gt;        For Each $objsys In $wmi_comp&lt;br /&gt;            $model = $objsys.Name&lt;br /&gt;            $desc  = $objsys.Description&lt;br /&gt;            $asset = $objsys.IdentifyingNumber&lt;br /&gt;        Next&lt;br /&gt;        $=WriteLine(2,"[General]" + @crlf)&lt;br /&gt;        $=WriteLine(2,"Manufacturer=MY COMPANY, INC." + @crlf)&lt;br /&gt;        $=WriteLine(2,"Model="+$model + @crlf)&lt;br /&gt;        $=WriteLine(2,"SupportURL=$weblink" + @crlf)&lt;br /&gt;        $=WriteLine(2,"LocalFile=%windir%\web\support.htm" + @crlf + @crlf)&lt;br /&gt;        $=WriteLine(2,"[OEMSpecific]" + @crlf)&lt;br /&gt;        $=WriteLine(2,"SubModel=" + @crlf)&lt;br /&gt;        $=WriteLine(2,"SerialNo=" + @crlf)&lt;br /&gt;        $=WriteLine(2,"OEM1="+$asset + @crlf)&lt;br /&gt;        $=WriteLine(2,"OEM2=" + @crlf + @crlf)&lt;br /&gt;        $=WriteLine(2,"[ICW]" + @crlf)&lt;br /&gt;        $=WriteLine(2,"Product=Computer Asset" + @crlf + @crlf)&lt;br /&gt;        $=WriteLine(2,"[Support Information]" + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line1=COMPUTER HELP DESK" + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line2= " + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line3=Contact Technical Support by web or phone:" + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line4= " + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line5=  $weblink" + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line6=  1-800-555-1212" + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line7= " + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line8=After hours/weekends/holidays..." + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line9=support options may be limited." + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line10=------------------------------" + @crlf)&lt;br /&gt;        $=WriteLine(2,"Line11=Computer Name: " + @wksta + @crlf)&lt;br /&gt;        If Trim($asset) &lt;&gt; ""&lt;br /&gt;            $=WriteLine(2,"Line12=Asset Tag: " + Trim($asset) + @crlf)&lt;br /&gt;            $=WriteLine(2,"Line13=IPAddress: " + @ipaddress0 + @crlf)&lt;br /&gt;        Else&lt;br /&gt;            $=WriteLine(2,"Line12=IPAddress: " + @ipaddress0 + @crlf)&lt;br /&gt;        EndIf&lt;br /&gt;        Close(2)&lt;br /&gt;        ? "[OEMSupportTag].....: oeminfo.ini file has been successfully updated!"&lt;br /&gt;    Else&lt;br /&gt;        ? "[OEMSupportTag].....: Error: failed to create new oeminfo.ini file!"&lt;br /&gt;    EndIf&lt;br /&gt;&lt;br /&gt;    ? "[OEMSupportTag].....: oeminfo logo graphic updated already?..."&lt;br /&gt;    If Exist( $logfile ) = 0&lt;br /&gt;        ? "[OEMSupportTag].....: attempting to create new oeminfo update log file..."&lt;br /&gt;        If Exist( $oemlogosrc ) = 1&lt;br /&gt;            ? "[OEMSupportTag].....: downloading oeminfo logo graphic file..."&lt;br /&gt;            Copy $oemlogosrc $oemlogo&lt;br /&gt;            If Open(3, $logfile, 5) = 0&lt;br /&gt;                WriteLine(3,"[General]"+@crlf)&lt;br /&gt;                WriteLine(3,"DateAdded="+@date+@crlf)&lt;br /&gt;                Close(3)&lt;br /&gt;                ? "[OEMSupportTag].....: oeminfo log updated."&lt;br /&gt;            EndIf&lt;br /&gt;        Else&lt;br /&gt;            ? "[OEMSupportTag].....: oeminfo graphic file missing: "+$oemlogosrc&lt;br /&gt;        EndIf&lt;br /&gt;    Else&lt;br /&gt;        ? "[OEMSupportTag].....: "+$logfile+" previously recorded."&lt;br /&gt;    EndIf&lt;br /&gt;Else&lt;br /&gt;    ? "[OEMSupportTag].....: Error: windir variable not set, aborting process."&lt;br /&gt;EndIf&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7960734690503087292?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7960734690503087292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-customize-oem-support.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7960734690503087292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7960734690503087292'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-customize-oem-support.html' title='KiXtart: Customize OEM Support Information'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4427998122939738037</id><published>2009-07-11T17:55:00.001-07:00</published><updated>2009-07-11T17:57:52.172-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='inventory'/><title type='text'>KiXtart: Get Asset Number</title><content type='html'>WMI query for asset number (e.g. Dell Asset, HP Serial number, etc.)&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Function AssetNumber()&lt;br /&gt;    Dim $objWmi, $objWmiCS, $obj, $retval, $pc&lt;br /&gt;    $pc = @wksta&lt;br /&gt;    $objWmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\$pc\root\cimv2")&lt;br /&gt;    $objWmiCS = $objWmi.ExecQuery("select * from Win32_ComputerSystemProduct")&lt;br /&gt;    For Each $obj in $objWmiCS&lt;br /&gt;        $retval = $obj.IdentifyingNumber&lt;br /&gt;    Next&lt;br /&gt;    $AssetNumber = Trim($retval)&lt;br /&gt;EndFunction&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4427998122939738037?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4427998122939738037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-get-asset-number.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4427998122939738037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4427998122939738037'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-get-asset-number.html' title='KiXtart: Get Asset Number'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-1391754572351066214</id><published>2009-07-11T17:52:00.000-07:00</published><updated>2009-07-11T17:55:07.826-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>KiXtart: Open Browser / Display Web Page</title><content type='html'>Great for login banners and bulletins...&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Function OpenWebPage($url, $show, Optional $height, $width, $fixed)&lt;br /&gt;    $ie = CreateObject("InternetExplorer.Application")&lt;br /&gt;    If $ie &lt;&gt; 0 and @ERROR = 0&lt;br /&gt;        $ie.Navigate($url)&lt;br /&gt;        If $show = 1&lt;br /&gt;            If $height &gt; 0&lt;br /&gt;                $ie.Height = $height&lt;br /&gt;            EndIf&lt;br /&gt;            If $width &gt; 0&lt;br /&gt;                $ie.Width  = $width&lt;br /&gt;            EndIf&lt;br /&gt;            If $fixed = 1&lt;br /&gt;                $ie.Resizable = 0&lt;br /&gt;                $ie.StatusBar = 0&lt;br /&gt;                $ie.Toolbar = 0&lt;br /&gt;            EndIf&lt;br /&gt;            $ie.Visible = 1&lt;br /&gt;            Sleep 1&lt;br /&gt;        Else&lt;br /&gt;            ? "(openwebpage): accessing document in silent-mode"&lt;br /&gt;            Sleep 1&lt;br /&gt;            $ie.Quit&lt;br /&gt;            $ie = 0&lt;br /&gt;        EndIf&lt;br /&gt;    Else&lt;br /&gt;        ? "(openwebpage): error / unable to launch IE application object"&lt;br /&gt;    EndIf&lt;br /&gt;EndFunction&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-1391754572351066214?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/1391754572351066214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-open-browser-display-web-page.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1391754572351066214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1391754572351066214'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-open-browser-display-web-page.html' title='KiXtart: Open Browser / Display Web Page'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2674192956634805028</id><published>2009-07-10T15:26:00.000-07:00</published><updated>2009-07-10T15:28:29.255-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='networking'/><title type='text'>KiXtart: Enumerate HOSTS file Entries</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Break ON&lt;br /&gt;&lt;br /&gt;$systemRoot = ExpandEnvironmentVars("%systemroot%")&lt;br /&gt;$hostsFile  = $systemRoot+"\system32\drivers\etc\hosts"&lt;br /&gt;$fileHandle = FreeFileHandle()&lt;br /&gt;$entries = 0&lt;br /&gt;&lt;br /&gt;If Exist($hostsFile)&lt;br /&gt;    ? "info: hosts file found at "+$hostsFile&lt;br /&gt;    If Open($fileHandle, $hostsFile, 1) = 0&lt;br /&gt;        ? "info: reading file..."&lt;br /&gt;        $line = ReadLine($fileHandle)&lt;br /&gt;        While @ERROR = 0&lt;br /&gt;            If Left($line, 1) &lt;&gt; "#"&lt;br /&gt;                ; ignore lines beginning with # as they are comments&lt;br /&gt;                ? "line --&gt; $line"&lt;br /&gt;                $entries = $entries + 1&lt;br /&gt;            EndIf&lt;br /&gt;            $line = ReadLine($fileHandle)&lt;br /&gt;        Loop&lt;br /&gt;        $=Close($fileHandle)&lt;br /&gt;        ? "info: $entries entries found"&lt;br /&gt;    Else&lt;br /&gt;        ? "fail: unable to open hosts file!"&lt;br /&gt;    EndIf&lt;br /&gt;Else&lt;br /&gt;    ? "fail: hosts file cannot be found!"&lt;br /&gt;EndIf&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2674192956634805028?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2674192956634805028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-enumerate-hosts-file-entries.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2674192956634805028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2674192956634805028'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-enumerate-hosts-file-entries.html' title='KiXtart: Enumerate HOSTS file Entries'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6793325292291704750</id><published>2009-07-10T14:18:00.000-07:00</published><updated>2009-07-10T14:24:14.707-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><category scheme='http://www.blogger.com/atom/ns#' term='adox'/><title type='text'>VBScript: ADOX Create Access Database, Table and Insert Row</title><content type='html'>Adapted from portions of code on MSDN at http://msdn.microsoft.com/en-us/library/ms681497(VS.85).aspx &lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' first we create the database file itself&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Const dbFile = "c:\database.mdb"&lt;br /&gt;strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &amp; dbFile&lt;br /&gt;&lt;br /&gt;Const adVarWChar = 202&lt;br /&gt;Const adSingle = 4&lt;br /&gt;Const adLockOptimistic = 3&lt;br /&gt;Const adOpenDynamic = 2&lt;br /&gt;Const adCmdTable = &amp;H0002&lt;br /&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;wscript.echo "info: creating database..."&lt;br /&gt;Dim objCatalog&lt;br /&gt;Set objCatalog = CreateObject("ADOX.Catalog")&lt;br /&gt;objCatalog.Create strDSN&lt;br /&gt;If err.Number = 0 Then&lt;br /&gt;    wscript.echo "info: database created successfully"&lt;br /&gt;Else&lt;br /&gt;    wscript.echo "fail: error = " &amp; err.Number &amp; " (" &amp; err.Description &amp; ")"&lt;br /&gt;    wscript.Quit(1)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' next we create a table in the new database&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;wscript.echo "info: creating table..."&lt;br /&gt;&lt;br /&gt;Set objTable = CreateObject("ADOX.Table")&lt;br /&gt;objCatalog.ActiveConnection = strDSN&lt;br /&gt;&lt;br /&gt;With objTable&lt;br /&gt;    .Name = "tbl_Employees"&lt;br /&gt;    .Columns.Append "empID", adVarWChar, 12&lt;br /&gt;    .Columns.Append "fname", adVarWChar, 50&lt;br /&gt;    .Columns.Append "lname", adVarWChar, 50&lt;br /&gt;    .Columns.Append "dept", adVarWChar, 50&lt;br /&gt;    .Columns.Append "phone", adVarWChar, 50&lt;br /&gt;    .Columns.Append "email", adVarWChar, 50&lt;br /&gt;    .Columns.Append "jobID", adSingle&lt;br /&gt;    .Columns.Append "birthDay", adVarWChar, 20&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;objCatalog.Tables.Append objTable&lt;br /&gt;&lt;br /&gt;If Err.Number &lt;&gt; 0 Then&lt;br /&gt;    wscript.echo "fail: " &amp; err.Number &amp; ": " &amp; err.Description&lt;br /&gt;    Set objTable = Nothing&lt;br /&gt;    Set objCatalog = Nothing&lt;br /&gt;    wscript.Quit(1)&lt;br /&gt;Else&lt;br /&gt;    wscript.echo "info: table created successfully"&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set objTable = Nothing&lt;br /&gt;Set objCatalog = Nothing&lt;br /&gt;&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;' comment: SQL INSERT&lt;br /&gt;'----------------------------------------------------------------&lt;br /&gt;wscript.echo "info: entering a new row..."&lt;br /&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;Set rs = CreateObject("ADODB.Recordset")&lt;br /&gt;rs.Open "tbl_Employees", strDSN, adOpenDynamic, adLockOptimistic, adCmdTable&lt;br /&gt;&lt;br /&gt;If err.Number &lt;&gt; 0 Then&lt;br /&gt;    rs.Close&lt;br /&gt;    Set rs = Nothing&lt;br /&gt;    wscript.echo "fail: error = " &amp; err.Number &amp; " (" &amp; err.Description &amp; ")"&lt;br /&gt;    wscript.Quit(1)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;rs.AddNew&lt;br /&gt;rs("empID").value = "100400"&lt;br /&gt;rs("fname").value = "JOHN"&lt;br /&gt;rs("lname").value = "DOE"&lt;br /&gt;rs("dept").value  = "SALES"&lt;br /&gt;rs("phone").value = "800-555-1212"&lt;br /&gt;rs("email").value = "john_doe@dumbass.local"&lt;br /&gt;rs("jobID").value = 4002&lt;br /&gt;rs("birthDay").value = "#03/01/1966#"&lt;br /&gt;rs.Update&lt;br /&gt;If err.Number &lt;&gt; 0 Then&lt;br /&gt;    rs.Close&lt;br /&gt;    Set rs = Nothing&lt;br /&gt;    wscript.echo "fail: error = " &amp; err.Number &amp; " (" &amp; err.Description &amp; ")"&lt;br /&gt;    wscript.Quit(1)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;rs.Close&lt;br /&gt;Set rs = Nothing&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6793325292291704750?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6793325292291704750/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-adox-create-access-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6793325292291704750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6793325292291704750'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-adox-create-access-database.html' title='VBScript: ADOX Create Access Database, Table and Insert Row'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5772798694634515617</id><published>2009-07-10T13:47:00.000-07:00</published><updated>2009-07-10T13:50:48.358-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='registry'/><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>VBScript: Sort Start Menu Items</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Const optionType = 1&lt;br /&gt;Const regBase = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder"&lt;br /&gt;&lt;br /&gt;Set objShell = CreateObject("Wscript.Shell")&lt;br /&gt;&lt;br /&gt;If optionType = 1 Then&lt;br /&gt;    ' a sloppy, cheap, but effective way to do this with Wscript&lt;br /&gt;    cmd1 = "start /wait reg delete """ &amp; regBase &amp; "\Start Menu"" /f"&lt;br /&gt;    cmd2 = "start /wait reg delete """ &amp; regBase &amp; "\Start Menu2"" /f"&lt;br /&gt;    cmd3 = "start /wait taskkill /im explorer.exe /F"&lt;br /&gt;    cmd4 = "explorer.exe"&lt;br /&gt;    objShell.Run "cmd.exe /c " &amp; cmd1, 1, True&lt;br /&gt;    objShell.Run "cmd.exe /c " &amp; cmd2, 1, True&lt;br /&gt;    objShell.Run "cmd.exe /c " &amp; cmd3, 1, True&lt;br /&gt;    objShell.Run "cmd.exe /c " &amp; cmd4, 1, True&lt;br /&gt;Else&lt;br /&gt;    ' a more elegant, poofy and girly way of doing this with style and ambiance&lt;br /&gt;    objShell.RegDelete regBase &amp; "\Start Menu\"&lt;br /&gt;    objShell.RegDelete regBase &amp; "\Start Menu2\"&lt;br /&gt;    objShell.Run "cmd.exe /c start /wait taskkill /im explorer.exe /F", 1, True&lt;br /&gt;    objShell.Run "cmd.exe /c explorer.exe", 1, True&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set objShell = Nothing&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5772798694634515617?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5772798694634515617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-sort-start-menu-items.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5772798694634515617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5772798694634515617'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-sort-start-menu-items.html' title='VBScript: Sort Start Menu Items'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4422201168856115114</id><published>2009-07-09T20:22:00.000-07:00</published><updated>2009-07-09T20:23:31.801-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><title type='text'>PowerShell: Update Desktop Shortcut Targets</title><content type='html'>&lt;pre style="font-size:8pt;color:blue"&gt;&lt;br /&gt;# iterate shortcuts to find matching target paths and &lt;br /&gt;# if found, replace with new target path and save link&lt;br /&gt;&lt;br /&gt;$desktop = $home+"\desktop"&lt;br /&gt;$oldPath = "\\server1\sharename1"&lt;br /&gt;$newPath = "\\server2\sharename1"&lt;br /&gt;&lt;br /&gt;$shell = New-Object -ComObject WScript.Shell&lt;br /&gt;&lt;br /&gt;$Dir = get-childitem $desktop -recurse&lt;br /&gt;&lt;br /&gt;foreach($file in $Dir) {&lt;br /&gt;    $fname = $file.Name&lt;br /&gt;    # write-host $fname&lt;br /&gt;    $lnk = $shell.CreateShortcut($desktop+"\"+$fname)&lt;br /&gt;    $target = $lnk.TargetPath&lt;br /&gt;    if ($target -eq $oldPath) {&lt;br /&gt;        write-host "Updating shortcut target..."&lt;br /&gt;        $lnk.TargetPath = $newPath&lt;br /&gt;        $lnk.Save()&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4422201168856115114?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4422201168856115114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/powershell-update-desktop-shortcut.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4422201168856115114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4422201168856115114'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/powershell-update-desktop-shortcut.html' title='PowerShell: Update Desktop Shortcut Targets'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-7145333439492356743</id><published>2009-07-07T19:19:00.001-07:00</published><updated>2009-07-07T19:24:42.411-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='listbox'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>ASP - Generate Alphabet List</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;&amp;lt;select name="letter" size="1"&amp;gt;&lt;br /&gt;&amp;lt;%&lt;br /&gt;For i = Asc("A") to Asc("Z")&lt;br /&gt;    Response.Write "&amp;lt;option&amp;gt;" &amp;amp; Chr(i) &amp;amp; "&amp;lt;/option&amp;gt;"&lt;br /&gt;Next&lt;br /&gt;%&amp;gt;&lt;br /&gt;&amp;lt;/select&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-7145333439492356743?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/7145333439492356743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-generate-alphabet-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7145333439492356743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/7145333439492356743'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-generate-alphabet-list.html' title='ASP - Generate Alphabet List'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-3293218730749152498</id><published>2009-07-07T19:14:00.000-07:00</published><updated>2009-07-07T19:16:54.825-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><title type='text'>KiXtart: Update Desktop Shortcuts</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Break ON&lt;br /&gt;&lt;br /&gt;$oldPath = "\\server1\shareName1"&lt;br /&gt;$newPath = "\\server2\shareName2"&lt;br /&gt;&lt;br /&gt;$shell = CreateObject("WScript.Shell")&lt;br /&gt;$DesktopPath = ExpandEnvironmentVars("%userprofile%")+"\Desktop"&lt;br /&gt;&lt;br /&gt;$FileName = Dir("$DesktopPath\*.lnk")&lt;br /&gt;While $FileName &lt;&gt; "" And @error = 0&lt;br /&gt;    ? $FileName&lt;br /&gt;    $link = $shell.CreateShortcut("$DesktopPath\$FileName")&lt;br /&gt;    If Ucase($link.TargetPath) = Ucase($oldPath)&lt;br /&gt;        $link.TargetPath = $newPath&lt;br /&gt;        $link.Save&lt;br /&gt;    EndIf&lt;br /&gt;    $FileName = Dir()&lt;br /&gt;Loop&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-3293218730749152498?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/3293218730749152498/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-update-desktop-shortcuts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3293218730749152498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3293218730749152498'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-update-desktop-shortcuts.html' title='KiXtart: Update Desktop Shortcuts'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-867156786510935574</id><published>2009-07-07T19:08:00.000-07:00</published><updated>2009-07-07T19:11:03.558-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><category scheme='http://www.blogger.com/atom/ns#' term='adox'/><title type='text'>KiXtart: Enumerate Access Database Tables with ADOX</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;$dbfile = "\\servername\share\folder\database.mdb"&lt;br /&gt;&lt;br /&gt;Function ListTablesADOX($db)&lt;br /&gt;    Dim $Conn, $strConn, $Catalog, $Table, $Column&lt;br /&gt;    $strConn = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=$db"&lt;br /&gt; &lt;br /&gt;    ? "Database: $db @CRLF"&lt;br /&gt; &lt;br /&gt;    $Conn    = CreateObject("ADODB.Connection")&lt;br /&gt;    $Catalog = CreateObject("ADOX.Catalog")&lt;br /&gt;    $Table   = CreateObject("ADOX.Table")&lt;br /&gt;    $Column  = CreateObject("ADOX.Column")&lt;br /&gt; &lt;br /&gt;    $Conn.Open($strConn)&lt;br /&gt;    $Catalog.ActiveConnection = $Conn&lt;br /&gt;&lt;br /&gt;    For Each $Table In $Catalog.Tables&lt;br /&gt;        ? "Table: " + $Table.Name&lt;br /&gt;        For Each $Column In $Table.Columns&lt;br /&gt;            ? Chr(9) + "Column: " + $Column.Name&lt;br /&gt;        Next&lt;br /&gt;    Next&lt;br /&gt;    $Conn.Close&lt;br /&gt;EndFunction&lt;br /&gt;&lt;br /&gt;$=ListTablesADOX($dbfile)&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-867156786510935574?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/867156786510935574/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-enumerate-access-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/867156786510935574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/867156786510935574'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-enumerate-access-database.html' title='KiXtart: Enumerate Access Database Tables with ADOX'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-3179181112290976059</id><published>2009-07-07T14:21:00.001-07:00</published><updated>2009-07-07T14:22:28.189-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='shares'/><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><title type='text'>KiXtart: Enumerate Local Shares</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Break ON&lt;br /&gt;&lt;br /&gt;$strComputer = "."&lt;br /&gt;$tab = Chr(9)&lt;br /&gt;&lt;br /&gt;$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\$strComputer\root\cimv2")&lt;br /&gt;$colShares = $objWMIService.ExecQuery("Select * from Win32_Share")&lt;br /&gt;$numshares = $colShares.Count&lt;br /&gt;&lt;br /&gt;? "shares found: $numshares"&lt;br /&gt;&lt;br /&gt;For each $objShare in $colShares&lt;br /&gt;    $n = $objShare.Name&lt;br /&gt;    If Right($n,1) = "$$"&lt;br /&gt;        $shareType = "HIDDEN"&lt;br /&gt;    Else&lt;br /&gt;        $shareType = "OPEN"&lt;br /&gt;    EndIf&lt;br /&gt;    ? $objShare.Name + $tab + $shareType + $tab +&lt;br /&gt;        $objShare.Path + $tab + $objShare.Caption + $tab +&lt;br /&gt;        $objShare.Type&lt;br /&gt;Next&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-3179181112290976059?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/3179181112290976059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-enumerate-local-shares.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3179181112290976059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3179181112290976059'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-enumerate-local-shares.html' title='KiXtart: Enumerate Local Shares'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5684691772038413885</id><published>2009-07-05T12:16:00.000-07:00</published><updated>2009-07-05T12:18:49.669-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><title type='text'>VBscript Outsourcing to KiXtart</title><content type='html'>If you register the Kixtart.dll component you can invoke the "KiXtart.Application" interface to handle some basic inventory chores.  This does not work from PowerShell v2 by the way.&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;Set objKiX = CreateObject("KiXtart.Application")&lt;br /&gt;If err.Number = 0 Then&lt;br /&gt;    wscript.echo "Processor: " &amp; vbTab &amp; Trim(objKiX.CPU)&lt;br /&gt;    wscript.echo "UserName: " &amp; vbTab &amp;  objKiX.UserId&lt;br /&gt;    wscript.echo "Domain: " &amp; vbTab &amp;  objKiX.LDomain&lt;br /&gt;    wscript.echo "MAC id: " &amp; vbTab &amp;  objKiX.Address&lt;br /&gt;    wscript.echo "Privilege: " &amp; vbTab &amp; objKiX.Priv&lt;br /&gt;    wscript.echo "Password Age: " &amp; vbTab &amp; objKiX.PwAge&lt;br /&gt;    wscript.echo "ProductType: " &amp; vbTab &amp; objKiX.ProductType&lt;br /&gt;    Set objKiX = Nothing&lt;br /&gt;Else&lt;br /&gt;    wscript.echo "kixtart.dll has not been registered"&lt;br /&gt;End If&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5684691772038413885?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5684691772038413885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-outsourcing-to-kixtart.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5684691772038413885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5684691772038413885'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-outsourcing-to-kixtart.html' title='VBscript Outsourcing to KiXtart'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-4468153540239213419</id><published>2009-07-05T12:13:00.000-07:00</published><updated>2009-07-05T12:15:12.944-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='jscript'/><category scheme='http://www.blogger.com/atom/ns#' term='trigonometry'/><category scheme='http://www.blogger.com/atom/ns#' term='math'/><category scheme='http://www.blogger.com/atom/ns#' term='scriptcontrol'/><title type='text'>KixTart: ScriptControl JScript to Outsource Expression</title><content type='html'>Use Jscript object to calculate Cosine of a value...&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Function Cosine($numValue)&lt;br /&gt;    $sc = CreateObject("ScriptControl")&lt;br /&gt;    $sc.Language = "jscript"&lt;br /&gt;    $result = $sc.Eval("Math.cos("+$numValue+")")&lt;br /&gt;    $sc = 0&lt;br /&gt;    $Cosine = $result&lt;br /&gt;EndFunction&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Test examples...&lt;br /&gt;&lt;pre style="font-size:8pt; color:green"&gt;&lt;br /&gt;$testvalue = 45&lt;br /&gt;$test = Cosine($testvalue)&lt;br /&gt;? "cosine of $testvalue is: "+$test&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-4468153540239213419?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/4468153540239213419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-scriptcontrol-jscript-to.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4468153540239213419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/4468153540239213419'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-scriptcontrol-jscript-to.html' title='KixTart: ScriptControl JScript to Outsource Expression'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-1820137818230869906</id><published>2009-07-05T12:09:00.000-07:00</published><updated>2009-07-05T12:12:03.691-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='formatting'/><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='scriptcontrol'/><title type='text'>KiXtart: ScriptControl VBScript to Outsource Expressions</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Function DaysOld($date)&lt;br /&gt;    Dim $sc, $result&lt;br /&gt;    $sc = CreateObject("ScriptControl")&lt;br /&gt;    $sc.Language = "vbscript"&lt;br /&gt;    $result = $sc.Eval("DateDiff("+Chr(34)+"d"+Chr(34)+", "+Chr(34)+$date+Chr(34)+", Now)")&lt;br /&gt;    $sc = 0&lt;br /&gt;    $DaysOld = $result&lt;br /&gt;EndFunction&lt;br /&gt;&lt;br /&gt;Function FormatDateTime($strDate, $format)&lt;br /&gt;    Dim $sc, $result&lt;br /&gt;    $sc = CreateObject("ScriptControl")&lt;br /&gt;    $sc.Language = "vbscript"&lt;br /&gt;    $result = $sc.Eval("FormatDateTime("+Chr(34)+$strDate+Chr(34)+","+$format+")")&lt;br /&gt;    $sc = 0&lt;br /&gt;    $FormatDateTime = $result&lt;br /&gt;EndFunction&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Test examples:&lt;br /&gt;&lt;pre style="font-size:8pt; color:green"&gt;&lt;br /&gt;$testvalue = '2009/01/03 12:34:56'&lt;br /&gt;&lt;br /&gt;$test1 = FormatDateTime($testvalue, 'vbShortDate')&lt;br /&gt;$test2 = FormatDateTime($testvalue, 'vbLongDate')&lt;br /&gt;$test3 = FormatDateTime($testvalue, 'vbLongTime')&lt;br /&gt;&lt;br /&gt;? "shortdate: $test1"&lt;br /&gt;? "longdate: $test2"&lt;br /&gt;? "longtime: $test3"&lt;br /&gt;&lt;br /&gt;$test4 = DaysOld($testvalue)&lt;br /&gt;? "days old: $test4"&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-1820137818230869906?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/1820137818230869906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-scriptcontrol-vbscript-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1820137818230869906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1820137818230869906'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-scriptcontrol-vbscript-to.html' title='KiXtart: ScriptControl VBScript to Outsource Expressions'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-8335401224111084244</id><published>2009-07-05T12:06:00.000-07:00</published><updated>2009-07-05T12:08:15.482-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kixtart'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><category scheme='http://www.blogger.com/atom/ns#' term='arrays'/><title type='text'>KiXtart: Array List Sorting</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Function ArrayList()&lt;br /&gt;    ; this code creates and populates an ArrayList&lt;br /&gt;    ? "Example: ArrayList object"&lt;br /&gt;    $myArrayList = CreateObject("System.Collections.ArrayList")&lt;br /&gt;    $=$myArrayList.Add("Dog")&lt;br /&gt;    $=$myArrayList.Add("Chicken")&lt;br /&gt;    $=$myArrayList.Add("Rooster")&lt;br /&gt;    $=$myArrayList.Add("Hen")&lt;br /&gt;&lt;br /&gt;    ; Now, to add an element and sort the ArrayList, all we need to do is:&lt;br /&gt;&lt;br /&gt;    ; [1] add the new element to the ArrayList&lt;br /&gt;    $=$myArrayList.Add("Pig")&lt;br /&gt;    ; [2] sort the ArrayList&lt;br /&gt;    $=$myArrayList.Sort()&lt;br /&gt;    For each $item in $myArrayList&lt;br /&gt;        ? $item&lt;br /&gt;    Next&lt;br /&gt;EndFunction&lt;br /&gt;&lt;br /&gt;$x = ArrayList()&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-8335401224111084244?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/8335401224111084244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-array-list-sorting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8335401224111084244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8335401224111084244'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/kixtart-array-list-sorting.html' title='KiXtart: Array List Sorting'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2364161677019554531</id><published>2009-07-05T12:04:00.000-07:00</published><updated>2009-07-05T12:06:17.801-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><title type='text'>VBScript Scrape Links/IMG tags from URL</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;args = WScript.Arguments.Count&lt;br /&gt;&lt;br /&gt;If args &lt;&gt; 1 Then&lt;br /&gt;    Wscript.Echo "usage: ScrapeLinks.vbs URL"&lt;br /&gt;    Wscript.Quit&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;URL = WScript.Arguments.Item(0)&lt;br /&gt;&lt;br /&gt;Set ie = CreateObject("InternetExplorer.Application")&lt;br /&gt;ie.Navigate URL&lt;br /&gt;&lt;br /&gt;Do Until ie.ReadyState = 4&lt;br /&gt;    Wscript.sleep 10&lt;br /&gt;Loop&lt;br /&gt;&lt;br /&gt;Wscript.Echo "DOCUMENT LINKS"&lt;br /&gt;Wscript.Echo&lt;br /&gt;&lt;br /&gt;For each link in ie.Document.Links&lt;br /&gt;    Wscript.Echo link, link.InnerText&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;Wscript.Echo&lt;br /&gt;Wscript.Echo "DOCUMENT IMAGE TAGS"&lt;br /&gt;Wscript.Echo&lt;br /&gt;&lt;br /&gt;For each pix in ie.Document.Images&lt;br /&gt;    Wscript.Echo pix.Src&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;ie.Quit&lt;br /&gt;Set ie = Nothing&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2364161677019554531?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2364161677019554531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-scrape-linksimg-tags-from-url.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2364161677019554531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2364161677019554531'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-scrape-linksimg-tags-from-url.html' title='VBScript Scrape Links/IMG tags from URL'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5729806876492905195</id><published>2009-07-05T12:01:00.000-07:00</published><updated>2009-07-05T12:03:24.486-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='shortcuts'/><title type='text'>VBScript Enumerate Shortcuts</title><content type='html'>Enumerate shortcuts under all-users profile and report in XML format...&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Option Explicit&lt;br /&gt;Const strComputer = "."&lt;br /&gt;&lt;br /&gt;Const rKey = "Software\Microsoft\Windows NT\CurrentVersion\ProfileList"&lt;br /&gt;Const rVal = "ProfilesDirectory"&lt;br /&gt;Const HKCU = &amp;H80000001&lt;br /&gt;Const HKLM = &amp;H80000002&lt;br /&gt;&lt;br /&gt;Dim objShell, objFSO, oReg, objRootFolder, psub, p&lt;br /&gt;Dim objFolder, objLink, objFsub, linkpath, uid, objLnk&lt;br /&gt;&lt;br /&gt;Set objShell = CreateObject("Wscript.Shell")&lt;br /&gt;Set objFSO   = CreateObject("Scripting.FileSystemObject")&lt;br /&gt;&lt;br /&gt;On Error Resume Next&lt;br /&gt;Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; _&lt;br /&gt;    strComputer &amp; "\root\default:StdRegProv")&lt;br /&gt;&lt;br /&gt;If err.Number &lt;&gt; 0 Then&lt;br /&gt;    wscript.echo "error: computer is not accessible"&lt;br /&gt;    wscript.Quit(1)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;oReg.GetExpandedStringValue HKLM, rKey, rVal, p&lt;br /&gt;If VarType(p) = vbNull Then&lt;br /&gt;    wscript.echo "error: registry key not found"&lt;br /&gt;    wscript.Quit(1)&lt;br /&gt;End If&lt;br /&gt;&lt;br /&gt;Set objRootFolder = objFSO.GetFolder(p)&lt;br /&gt;&lt;br /&gt;wscript.echo "&lt;?xml version=""1.0"" ?&gt;"&lt;br /&gt;wscript.echo "&lt;folders&gt;"&lt;br /&gt;For each objFolder in objRootFolder.SubFolders&lt;br /&gt;    uid = objFolder.Name&lt;br /&gt;    psub = p &amp; "\" &amp; uid &amp; "\desktop"&lt;br /&gt;    If objFSO.FolderExists(psub) Then&lt;br /&gt;        wscript.echo vbTab &amp; "&lt;folder name=" &amp; psub &amp; " owner=" &amp; uid &amp; "&gt;"&lt;br /&gt;        Set objFsub = objFSO.GetFolder(psub)&lt;br /&gt;        For each objLink in objFsub.Files&lt;br /&gt;            If InStr(1, ".lnk .url", Lcase(Right(objLink.Name,4))) &lt;&gt; 0 Then&lt;br /&gt;                wscript.echo vbTab &amp; vbTab &amp; "&lt;shortcut&gt;"&lt;br /&gt;                linkpath = psub &amp; "\" &amp; objLink.Name&lt;br /&gt;                Set objLnk = objShell.CreateShortcut(linkpath)&lt;br /&gt;                Select Case Lcase(Right(linkpath,4))&lt;br /&gt;                    Case ".lnk":&lt;br /&gt;                        ClosedTag 3, "name", objLnk.Name&lt;br /&gt;                        ClosedTag 3, "fullname", objLnk.FullName&lt;br /&gt;                        ClosedTag 3, "arguments", objLnk.Arguments&lt;br /&gt;                        ClosedTag 3, "working", objLnk.WorkingDirectory&lt;br /&gt;                        ClosedTag 3, "target", objLnk.TargetPath&lt;br /&gt;                        ClosedTag 3, "icon", objLnk.IconLocation&lt;br /&gt;                        ClosedTag 3, "hokey", objLnk.Hotkey&lt;br /&gt;                        ClosedTag 3, "windowstyle", objLnk.WindowStyle&lt;br /&gt;                        ClosedTag 3, "description", objLnk.Description&lt;br /&gt;                        ClosedTag 3, "type", "filesystem"&lt;br /&gt;                    Case ".url":&lt;br /&gt;                        ClosedTag 3, "name", objLnk.Name&lt;br /&gt;                        ClosedTag 3, "fullname", objLnk.FullName&lt;br /&gt;                        ClosedTag 3, "target", objLnk.TargetPath&lt;br /&gt;                        ClosedTag 3, "type", "internet"&lt;br /&gt;                End Select&lt;br /&gt;                wscript.echo vbTab &amp; vbTab &amp; "&lt;/shortcut&gt;"&lt;br /&gt;            End If&lt;br /&gt;        Next&lt;br /&gt;        wscript.echo vbTab &amp; "&lt;/folder&gt;"&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;wscript.echo "&lt;/folders&gt;"&lt;br /&gt;&lt;br /&gt;Sub ClosedTag(indent, label, val)&lt;br /&gt;    Dim i, s : s = ""&lt;br /&gt;    For i = 1 to indent&lt;br /&gt;        s = s &amp; vbTab&lt;br /&gt;    Next&lt;br /&gt;    If Trim(val) = "" Then&lt;br /&gt;        s = s &amp; "&lt;" &amp; label &amp; "&gt;_&lt;/" &amp; label &amp; "&gt;"&lt;br /&gt;    Else&lt;br /&gt;        s = s &amp; "&lt;" &amp; label &amp; "&gt;" &amp; val &amp; "&lt;/" &amp; label &amp; "&gt;"&lt;br /&gt;    End If&lt;br /&gt;    wscript.echo s&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Set objFolder = Nothing&lt;br /&gt;Set objFSO = Nothing&lt;br /&gt;Set objShell = Nothing&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5729806876492905195?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5729806876492905195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-enumerate-shortcuts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5729806876492905195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5729806876492905195'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-enumerate-shortcuts.html' title='VBScript Enumerate Shortcuts'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-1251944207757429489</id><published>2009-07-05T11:31:00.000-07:00</published><updated>2009-07-05T11:33:46.358-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP Determine Next Pay Date</title><content type='html'>&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Function NextPayDate()&lt;br /&gt;    Dim wd, base : base = CDate("6/12/2009")&lt;br /&gt;    Dim today : today = Now&lt;br /&gt;    If IsPayDate(today) Then&lt;br /&gt;        NextPayDate = today&lt;br /&gt;    Else&lt;br /&gt;    wd = WeekDay(today)&lt;br /&gt;    Select Case wd&lt;br /&gt;        Case 6:&lt;br /&gt;            ' if today is a friday&lt;br /&gt;            If IsPayDate(DateAdd("d", 14, today)) Then&lt;br /&gt;                NextPayDate = DateAdd("d", 14, today)&lt;br /&gt;            End If&lt;br /&gt;        Case 7:&lt;br /&gt;            ' if today is a saturday&lt;br /&gt;            If IsPayDate(DateAdd("d", 6, today)) Then&lt;br /&gt;                NextPayDate = DateAdd("d", 6, today)&lt;br /&gt;            Else&lt;br /&gt;                NextPayDate = DateAdd("d", 13, today)&lt;br /&gt;            End If&lt;br /&gt;        Case Else:&lt;br /&gt;            If IsPayDate(DateAdd("d", 6-wd, today)) Then&lt;br /&gt;                NextPayDate = DateAdd("d", 6-wd, today)&lt;br /&gt;            Else&lt;br /&gt;                NextPayDate = DateAdd("d", 13-wd, today)&lt;br /&gt;            End If&lt;br /&gt;        End Select&lt;br /&gt;    End If&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-1251944207757429489?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/1251944207757429489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-determine-next-pay-date.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1251944207757429489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1251944207757429489'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-determine-next-pay-date.html' title='VBScript / ASP Determine Next Pay Date'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5007925443813869636</id><published>2009-07-05T11:16:00.001-07:00</published><updated>2009-07-05T11:18:38.330-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP Is-PayDate (Crude Version)</title><content type='html'>Returns True if [dateval] is a multiple of 14 days (two weeks) from a known base pay date in the past (I picked June 12, 2009).&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt; color:blue"&gt;&lt;br /&gt;Function IsPayDate(dateval)&lt;br /&gt;    Dim days&lt;br /&gt;    Dim base : base = CDate("6/12/2009")&lt;br /&gt;    If WeekDay(dateval) = 6 Then&lt;br /&gt;        days = DateDiff("d", base, dateval)&lt;br /&gt;        If (days Mod 14) = 0 Then&lt;br /&gt;            IsPayDate = True&lt;br /&gt;        End If&lt;br /&gt;    End If&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Example...&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt;color:green;"&gt;&lt;br /&gt;For each d in Split("7/2/2009,7/3/2009,7/10/2009,7/24/2009", ",")&lt;br /&gt;    If IsPayDate(d) Then&lt;br /&gt;        wscript.echo d &amp; " is a pay date"&lt;br /&gt;    Else&lt;br /&gt;        wscript.echo d &amp; " is not a pay date"&lt;br /&gt;    End If&lt;br /&gt;Next&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5007925443813869636?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5007925443813869636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-is-paydate-crude-version.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5007925443813869636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5007925443813869636'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-is-paydate-crude-version.html' title='VBScript / ASP Is-PayDate (Crude Version)'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-1182718146828745735</id><published>2009-07-03T08:25:00.001-07:00</published><updated>2009-07-03T08:25:56.276-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP String Validate</title><content type='html'>Check if string contains a value (not Null and not empty)&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;Function StringVal(strval)&lt;br /&gt;    If Not(IsNull(strval)) And Trim(strval) &lt;&gt; "" Then&lt;br /&gt;        StringVal = True&lt;br /&gt;    End If&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-1182718146828745735?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/1182718146828745735/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-string-validate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1182718146828745735'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/1182718146828745735'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-string-validate.html' title='VBScript / ASP String Validate'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2322241398840910244</id><published>2009-07-03T08:23:00.001-07:00</published><updated>2009-07-03T08:24:36.300-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP Function Days-In-Month</title><content type='html'>&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;Function DaysInMonth(dateval)&lt;br /&gt;    Dim nxt&lt;br /&gt;    Dim tmp : tmp = DateAdd("d", -(Day(dateval)-1), dateval) ' get first day of month&lt;br /&gt;    nxt = DateAdd("m", 1, tmp) ' get first day of next month&lt;br /&gt;    DaysInMonth = Day(DateAdd("d", -1, nxt))&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2322241398840910244?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2322241398840910244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-function-days-in-month.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2322241398840910244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2322241398840910244'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-function-days-in-month.html' title='VBScript / ASP Function Days-In-Month'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-2096154401555094916</id><published>2009-07-03T08:08:00.001-07:00</published><updated>2009-07-03T08:09:19.659-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='arrays'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP Array_Slice Function</title><content type='html'>Almost as good as the PHP function Array_Slice()&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;Function Array_Slice(arr, start, newArray)&lt;br /&gt; Dim x : x = 0&lt;br /&gt; For i = start-1 to Ubound(arr)-1&lt;br /&gt;  ReDim Preserve newArray(x)&lt;br /&gt;  newArray(x) = arr(i)&lt;br /&gt;  x = x + 1&lt;br /&gt; Next&lt;br /&gt; Array_Slice = Ubound(newArray)&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-2096154401555094916?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/2096154401555094916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-arrayslice-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2096154401555094916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/2096154401555094916'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-arrayslice-function.html' title='VBScript / ASP Array_Slice Function'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-3385890086733558594</id><published>2009-07-03T08:06:00.000-07:00</published><updated>2009-07-03T08:07:33.391-07:00</updated><title type='text'>ASP version of PHP [Die] Function</title><content type='html'>&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;Sub Die(msg)&lt;br /&gt; Response.Write "&amp;lt;hr/&amp;gt;&amp;lt;div style=""font-family:verdana; font-size:10pt; color:red""&amp;gt;"&lt;br /&gt; Response.Write msg &amp; "&amp;lt;/div&amp;gt;&amp;lt;hr/&amp;gt;" &amp; vbCRLF&lt;br /&gt; Response.End&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-3385890086733558594?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/3385890086733558594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-version-of-php-die-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3385890086733558594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3385890086733558594'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-version-of-php-die-function.html' title='ASP version of PHP [Die] Function'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-8474485690702025842</id><published>2009-07-03T08:04:00.000-07:00</published><updated>2009-07-03T08:05:44.316-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='email'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>ASP MailTo Link Generator</title><content type='html'>&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;Function LinkMail(strval)&lt;br /&gt; If StringVal(strval) Then&lt;br /&gt;  If InStr(1, strval, "@") &lt;&gt; 0 Then&lt;br /&gt;   LinkMail = "&amp;lt;a href='mailto:" &amp; strval &amp; "'&amp;gt;" &amp; strval &amp; "&amp;lt;/a&amp;gt;"&lt;br /&gt;  Else&lt;br /&gt;   LinkMail = strval&lt;br /&gt;  End If&lt;br /&gt; Else&lt;br /&gt;  LinkMail = strval&lt;br /&gt; End If&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-8474485690702025842?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/8474485690702025842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-mailto-link-generator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8474485690702025842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8474485690702025842'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-mailto-link-generator.html' title='ASP MailTo Link Generator'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-6582131053465348377</id><published>2009-07-03T08:02:00.001-07:00</published><updated>2009-07-03T08:04:18.096-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mapping'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>ASP Google-Map Link Function</title><content type='html'>Spock: "&lt;i&gt;Crude, but effective&lt;/i&gt;"&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;Function MapLink(strAddress, strCity, strStateZip)&lt;br /&gt; Dim url&lt;br /&gt; If StringVal(strAddress) And StringVal(strCity) And StringVal(strStateZip) Then&lt;br /&gt;  url = "http://maps.google.com/maps?hl=en&amp;amp;q=" &amp;amp; _&lt;br /&gt;   Replace(strAddress, " ", "+") &amp;amp; ",+" &amp;amp; _&lt;br /&gt;   Replace(strCity, " ", "+") &amp;amp; ",+" &amp;amp; strStateZip &amp;amp; _&lt;br /&gt;   "&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;ei=OWlNStjaNo-Ztgfi5p2oBA&amp;amp;t=h&amp;amp;z=16&amp;amp;iwloc=A"&lt;br /&gt;  MapLink = "&lt;br /&gt;&amp;lt;a href="http://www.blogger.com/%22%20&amp;amp;%20url%20&amp;amp;%20%22" target="_blank"&amp;gt;View Map&amp;lt;/a&amp;gt;" &amp;amp; vbCRLF&lt;br /&gt; Else&lt;br /&gt;  MapLink = ""&lt;br /&gt; End If&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-6582131053465348377?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/6582131053465348377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-google-map-link-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6582131053465348377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/6582131053465348377'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-google-map-link-function.html' title='ASP Google-Map Link Function'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-8924090570014704370</id><published>2009-07-03T07:59:00.002-07:00</published><updated>2009-07-03T08:01:56.345-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='forms'/><category scheme='http://www.blogger.com/atom/ns#' term='listbox'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>ASP ListBox for U.S. State Abbreviations</title><content type='html'>&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;Sub StatesList(default)&lt;br /&gt; Dim lst, x&lt;br /&gt; lst = "AL,AK,AZ,AR,CA,CO,CT,DE,DC,FL," &amp; _&lt;br /&gt;  "GA,HI,ID,IL,IN,IA,KS,KY,LA,ME," &amp; _&lt;br /&gt;  "MD,MA,MI,MN,MS,MO,MT,NE,NV,NH," &amp; _&lt;br /&gt;  "NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI," &amp; _&lt;br /&gt;  "SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY"&lt;br /&gt;&lt;br /&gt; If default = "" Then&lt;br /&gt;  Response.Write "&lt;option selected&gt;&lt;/option&gt;" &amp; vbCRLF&lt;br /&gt; End If&lt;br /&gt;&lt;br /&gt; For each x in Split(lst, ",")&lt;br /&gt;  If Ucase(x) = Ucase(default) Then&lt;br /&gt;   Response.Write "&lt;option selected&gt;" &amp; x &amp; "&lt;/option&gt;" &amp; vbCRLF&lt;br /&gt;  Else&lt;br /&gt;   Response.Write "&lt;option&gt;" &amp; x &amp; "&lt;/option&gt;" &amp; vbCRLF&lt;br /&gt;  End If&lt;br /&gt; Next&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;&amp;lt;select name="state" size="1"&amp;gt;&lt;br /&gt;    &amp;lt;% StatesList "VA" %&amp;gt;&lt;br /&gt;&amp;lt;/select&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-8924090570014704370?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/8924090570014704370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-listbox-for-us-state-abbreviations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8924090570014704370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/8924090570014704370'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/asp-listbox-for-us-state-abbreviations.html' title='ASP ListBox for U.S. State Abbreviations'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-3507008505596251193</id><published>2009-07-03T07:59:00.001-07:00</published><updated>2009-07-03T07:59:47.666-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='formatting'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP String Padding</title><content type='html'>&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;Function PadString(strval, delim, length, side)&lt;br /&gt; Dim tmp : tmp = Trim(strval)&lt;br /&gt; Select Case Ucase(Left(side,1))&lt;br /&gt;  Case "L":&lt;br /&gt;   Do While Len(tmp) &lt; length&lt;br /&gt;    tmp = delim &amp; tmp&lt;br /&gt;   Loop&lt;br /&gt;  Case "R":&lt;br /&gt;   Do While Len(tmp) &lt; length&lt;br /&gt;    tmp = tmp &amp; delim&lt;br /&gt;   Loop&lt;br /&gt; End Select&lt;br /&gt; PadString = tmp&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-3507008505596251193?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/3507008505596251193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-string-padding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3507008505596251193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/3507008505596251193'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-string-padding.html' title='VBScript / ASP String Padding'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5747639431463092648.post-5115897389898879156</id><published>2009-07-03T07:56:00.000-07:00</published><updated>2009-07-03T07:57:42.892-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dates'/><category scheme='http://www.blogger.com/atom/ns#' term='formatting'/><category scheme='http://www.blogger.com/atom/ns#' term='vbscript'/><category scheme='http://www.blogger.com/atom/ns#' term='asp'/><title type='text'>VBScript / ASP Date Formatter Function</title><content type='html'>&lt;pre style="font-size:8pt"&gt;&lt;br /&gt;&lt;br /&gt;Function FDate(dateval, mode)&lt;br /&gt; Select Case mode&lt;br /&gt;  Case "MM/DD/YYYY": &lt;br /&gt;   FDate = FormatDateTime(dateval, vbShortDate)&lt;br /&gt;  Case "YYYY-MM-DD": &lt;br /&gt;   FDate = Year(dateval) &amp; "-" &amp; _&lt;br /&gt;    PadString(Month(dateval), "0", 2, "Left") &amp; "-" &amp; _&lt;br /&gt;    PadString(Day(dateval), "0", 2, "Left")&lt;br /&gt;  Case "Mmm D, YYYY":&lt;br /&gt;   FDate = FormatDateTime(dateval, vbLongDate)&lt;br /&gt;  Case "Mmm D, YYYY HH:MM:SS":&lt;br /&gt;   FDate = FormatDateTime(dateval, vbLongDate) &amp; " " &amp; FormatDateTime(dateval, vbLongTime)&lt;br /&gt;  Case "MM/DD":&lt;br /&gt;   FDate = Month(dateval) &amp; "/" &amp; Day(dateval)&lt;br /&gt;  Case "Mmm DD":&lt;br /&gt;   FDate = MonthName(Month(dateval), True) &amp; " " &amp; Day(dateval)&lt;br /&gt;  Case "MMM DD":&lt;br /&gt;   FDate = MonthName(Month(dateval), False) &amp; " " &amp; Day(dateval)&lt;br /&gt;  Case Else:&lt;br /&gt;   FDate = "[FDate] invalid option parameter specified"&lt;br /&gt; End Select&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5747639431463092648-5115897389898879156?l=scriptzilla.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://scriptzilla.blogspot.com/feeds/5115897389898879156/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-date-formatter-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5115897389898879156'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5747639431463092648/posts/default/5115897389898879156'/><link rel='alternate' type='text/html' href='http://scriptzilla.blogspot.com/2009/07/vbscript-asp-date-formatter-function.html' title='VBScript / ASP Date Formatter Function'/><author><name>David Stein</name><uri>https://profiles.google.com/110918701133252279727</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-XlfmeOwRpq8/AAAAAAAAAAI/AAAAAAAAJdg/_4F5FKJ2EiI/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>
