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

<channel>
	<title>Dwarfsoft [GPA] &#187; Work</title>
	<atom:link href="http://www.dwarfsoft.com/blog/category/work/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dwarfsoft.com/blog</link>
	<description>Great Programming Artistry</description>
	<lastBuildDate>Tue, 06 Sep 2011 11:18:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>SEP11 Scan Logs</title>
		<link>http://www.dwarfsoft.com/blog/2011/03/03/sep11-scan-logs/</link>
		<comments>http://www.dwarfsoft.com/blog/2011/03/03/sep11-scan-logs/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 01:29:08 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tweet]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Antivirus]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[CMD]]></category>
		<category><![CDATA[Logs]]></category>
		<category><![CDATA[SEP11]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/2011/03/03/sep11-scan-logs/</guid>
		<description><![CDATA[I will start out by simply stating how much I HATE SEP11, and how it handles client scan logs. For some reason there is NO way of getting a client scan log out of the Central Management Console. The whole point of Central Management is being able to … manage CENTRALLY. Anyway, enough rant. I [...]]]></description>
			<content:encoded><![CDATA[<p>I will start out by simply stating how much I HATE SEP11, and how it handles client scan logs. For some reason there is NO way of getting a client scan log out of the Central Management Console. The whole point of Central Management is being able to … manage CENTRALLY.</p>
<p>Anyway, enough rant. I wrote a batch file to pull the latest (or specified) log file from a list of servers (in a file called Servers.txt). More Source:<span id="more-332"></span></p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;"><span style="color: #66cc66;">@</span>echo <span style="color: #0080FF; font-weight: bold;">off</span>
<span style="color: #800080;">if</span> not exist <span style="color: #ff0000;">&quot;SEP11Logs&quot;</span> mkdir SEP11Logs
&nbsp;
<span style="color: #800080;">for</span> <span style="color: #66cc66;">/</span>f <span style="color: #ff0000;">&quot;tokens=*&quot;</span> <span style="color: #66cc66;">%%</span>A <span style="color: #800080;">IN</span> <span style="color: #66cc66;">&#40;</span>Servers.txt<span style="color: #66cc66;">&#41;</span> DO <span style="color: #66cc66;">&#40;</span>
  <span style="color: #800080;">IF</span> <span style="color: #66cc66;">/</span>I <span style="color: #ff0000;">&quot;%~1&quot;</span> EQU <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">&#40;</span>
    <span style="color: #800080;">CALL</span> <span style="color: #FF1010; font-weight: bold;">:GetLatestLog &quot;%%A&quot;</span>
    <span style="color: #800080;">CALL</span> <span style="color: #FF1010; font-weight: bold;">:CopyLog &quot;%%A&quot; &quot;%%_LogFile%%&quot;</span>
    <span style="color: #66cc66;">&#41;</span> <span style="color: #800080;">ELSE</span> <span style="color: #66cc66;">&#40;</span>
    <span style="color: #800080;">CALL</span> <span style="color: #FF1010; font-weight: bold;">:CopyLog &quot;%%A&quot; &quot;%~1&quot;</span>
    <span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #800080;">GOTO</span><span style="color: #FF1010; font-weight: bold;">:EOF</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:GetLatestLog</span>
SET _ServerName=<span style="color: #66cc66;">%~</span><span style="color: #cc66cc;">1</span>
<span style="color: #800080;">FOR</span> <span style="color: #66cc66;">/</span>F <span style="color: #ff0000;">&quot;tokens=* delims=&quot;</span> <span style="color: #66cc66;">%%</span>B <span style="color: #800080;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'dir &quot;\\%_ServerName%\C$\Documents and Settings\All Users\Application Data\Symantec\Symantec Endpoint Protection\Logs\*.log&quot; /b /o:-d'</span><span style="color: #66cc66;">&#41;</span> DO <span style="color: #66cc66;">&#40;</span>
  SET _LogFile=<span style="color: #66cc66;">%%</span>B
  ECHO <span style="color: #ff0000;">&quot;Logfile is %%B&quot;</span>
  <span style="color: #800080;">GOTO</span><span style="color: #FF1010; font-weight: bold;">:EOF</span>
  <span style="color: #66cc66;">&#41;</span>
<span style="color: #800080;">GOTO</span><span style="color: #FF1010; font-weight: bold;">:EOF</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:CopyLog</span>
ECHO Copying <span style="color: #ff0000;">&quot;%~2&quot;</span> <span style="color: #0080FF; font-weight: bold;">on</span> <span style="color: #ff0000;">&quot;%~1&quot;</span>
COPY <span style="color: #66cc66;">/</span>Y <span style="color: #ff0000;">&quot;\\%~1\C$\Documents and Settings\All Users\Application Data\Symantec\Symantec Endpoint Protection\Logs\%~2&quot;</span> <span style="color: #ff0000;">&quot;SEP11Logs\%~1-%~2&quot;</span>
<span style="color: #FF1010; font-weight: bold;">:EOF</span></pre></div></div>

<p>This script goes through the list of servers copying the logs into a folder called SEP11Logs and renaming them to &#8220;&lt;ServerName&gt;-&lt;Logname&gt;&#8221; so they come out as something like &#8220;SERVER-02262011.log”.</p>
<p>Once I received the logs I was then struck with a problem of not being able to easily determine the date and time of each finding. After a short search I managed to track down a description of the <a href="http://www.symantec.com/business/support/index?page=content&#038;id=TECH100099&#038;locale=en_US" target="_blank">SEP11 log file format</a>. I wrote a quick and [very] dirty script to add a little more detail to the original log.</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">' See http://www.symantec.com/business/support/index?page=content&amp;id=TECH100099&amp;locale=en_US</span>
<span style="color: #FF8000;">On</span> <span style="color: #FF8000;">Error</span> <span style="color: #FF8000;">Resume</span> <span style="color: #FF8000;">Next</span>
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForReading</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
<span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForWriting</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>
&nbsp;
<span style="color: #0600FF;">Dim</span> fso, <span style="color: #008000;">folder</span>, <span style="color: #008000;">files</span>, NewsFile,sFolder
&nbsp;
<span style="color: #FF8000;">Set</span> fso <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
sFolder <span style="color: #008000;">=</span> Wscript.<span style="color: #0000FF;">Arguments</span>.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">If</span> sFolder <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span> <span style="color: #FF8000;">Then</span>
    Wscript.<span style="color: #0000FF;">Echo</span> <span style="color: #808080;">&quot;No Folder parameter was passed&quot;</span>
    Wscript.<span style="color: #0000FF;">Quit</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #FF8000;">Set</span> <span style="color: #008000;">folder</span> <span style="color: #008000;">=</span> fso.<span style="color: #0000FF;">GetFolder</span><span style="color: #000000;">&#40;</span>sFolder<span style="color: #000000;">&#41;</span>
<span style="color: #FF8000;">Set</span> <span style="color: #008000;">files</span> <span style="color: #008000;">=</span> <span style="color: #008000;">folder</span>.<span style="color: #008000;">Files</span>
&nbsp;
<span style="color: #FF8000;">For</span> <span style="color: #0600FF;">each</span> folderIdx In <span style="color: #008000;">files</span>
&nbsp;
  <span style="color: #FF8000;">Set</span> LogFile <span style="color: #008000;">=</span> fso.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>folderIdx.<span style="color: #0000FF;">Path</span>, <span style="color: #0600FF;">ForReading</span><span style="color: #000000;">&#41;</span>
  <span style="color: #FF8000;">Set</span> LogFileCsv <span style="color: #008000;">=</span> fso.<span style="color: #0000FF;">CreateTextFile</span><span style="color: #000000;">&#40;</span>folderIdx.<span style="color: #0000FF;">Path</span><span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;.csv&quot;</span>, <span style="color: #0600FF;">True</span><span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">Do</span> <span style="color: #0600FF;">While</span> <span style="color: #804040;">not</span> LogFile.<span style="color: #0000FF;">AtEndOfStream</span>
    <span style="color: #0600FF;">line</span> <span style="color: #008000;">=</span> LogFile.<span style="color: #0000FF;">ReadLine</span>
	Splt<span style="color: #008000;">=</span><span style="color: #0600FF;">Split</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">line</span>,<span style="color: #808080;">&quot;,&quot;</span><span style="color: #000000;">&#41;</span>
	hTime <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
	hTimeYear  <span style="color: #008000;">=</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;0000&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1970</span> <span style="color: #008000;">+</span> <span style="color: #0600FF;">CLng</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&amp;H&quot;</span><span style="color: #008000;">&amp;</span>Mid<span style="color: #000000;">&#40;</span>hTime,<span style="color: #FF0000;">1</span>,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>,<span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span>
	hTimeMonth <span style="color: #008000;">=</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;00&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">CLng</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&amp;H&quot;</span><span style="color: #008000;">&amp;</span>Mid<span style="color: #000000;">&#40;</span>hTime,<span style="color: #FF0000;">3</span>,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">+</span><span style="color: #FF0000;">1</span>,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
	hTimeDay   <span style="color: #008000;">=</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;00&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">CLng</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&amp;H&quot;</span><span style="color: #008000;">&amp;</span>Mid<span style="color: #000000;">&#40;</span>hTime,<span style="color: #FF0000;">5</span>,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
	hTimeHour  <span style="color: #008000;">=</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;00&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">CLng</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&amp;H&quot;</span><span style="color: #008000;">&amp;</span>Mid<span style="color: #000000;">&#40;</span>hTime,<span style="color: #FF0000;">7</span>,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
	hTimeMin   <span style="color: #008000;">=</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;00&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">CLng</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&amp;H&quot;</span><span style="color: #008000;">&amp;</span>Mid<span style="color: #000000;">&#40;</span>hTime,<span style="color: #FF0000;">9</span>,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
	hTimeSec   <span style="color: #008000;">=</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;00&quot;</span> <span style="color: #008000;">&amp;</span> <span style="color: #0600FF;">CLng</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&amp;H&quot;</span><span style="color: #008000;">&amp;</span>Mid<span style="color: #000000;">&#40;</span>hTime,<span style="color: #FF0000;">11</span>,<span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>, <span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
&nbsp;
	hDateAndTime <span style="color: #008000;">=</span> hTimeYear <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;-&quot;</span> <span style="color: #008000;">&amp;</span> hTimeMonth <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;-&quot;</span> <span style="color: #008000;">&amp;</span> hTimeDay <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; &quot;</span> <span style="color: #008000;">&amp;</span> hTimeHour <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;:&quot;</span> <span style="color: #008000;">&amp;</span> hTimeMin <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;:&quot;</span> <span style="color: #008000;">&amp;</span> hTimeSec
	hDate <span style="color: #008000;">=</span> hTimeYear <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;-&quot;</span> <span style="color: #008000;">&amp;</span> hTimeMonth <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;-&quot;</span> <span style="color: #008000;">&amp;</span> hTimeDay
	hTime <span style="color: #008000;">=</span> hTimeHour <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;:&quot;</span> <span style="color: #008000;">&amp;</span> hTimeMin <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;:&quot;</span> <span style="color: #008000;">&amp;</span> hTimeSec
&nbsp;
	<span style="color: #0600FF;">Select</span> <span style="color: #0600FF;">Case</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">1</span>
	    hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_IS_ALERT&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">2</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCAN_STOP&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">3</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCAN_START&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">4</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_PATTERN_UPDATE&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">5</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_INFECTION&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">6</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_FILE_NOT_OPEN&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">7</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LOAD_PATTERN&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">8</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;//GL_STD_MESSAGE_INFO NOT USED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">9</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;//GL_STD_MESSAGE_ERROR NOT USED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">10</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_CHECKSUM&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">11</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_TRAP&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">12</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_CONFIG_CHANGE&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">13</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SHUTDOWN&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">14</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_STARTUP&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">16</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_PATTERN_DOWNLOAD&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">17</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_TOO_MANY_VIRUSES&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">18</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_FWD_TO_QSERVER&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">19</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCANDLVR&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">20</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_BACKUP&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">21</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCAN_ABORT&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">22</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_RTS_LOAD_ERROR&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">23</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_RTS_LOAD&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">24</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_RTS_UNLOAD&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">25</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_REMOVE_CLIENT&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">26</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCAN_DELAYED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">27</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCAN_RESTART&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">28</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_ADD_SAVROAMCLIENT_TOSERVER&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">29</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_REMOVE_SAVROAMCLIENT_FROMSERVER&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">30</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LICENSE_WARNING&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">31</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LICENSE_ERROR&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">32</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LICENSE_GRACE&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">33</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_UNAUTHORIZED_COMM&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">34</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LOG_FWD_THRD_ERR&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">35</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LICENSE_INSTALLED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">36</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LICENSE_ALLOCATED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">37</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LICENSE_OK&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">38</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LICENSE_DEALLOCATED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">39</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_BAD_DEFS_ROLLBACK&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">40</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_BAD_DEFS_UNPROTECTED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">41</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SAV_PROVIDER_PARSING_ERROR&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">42</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_RTS_ERROR&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">43</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_COMPLIANCE_FAIL&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">44</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_COMPLIANCE_SUCCESS&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">45</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SECURITY_SYMPROTECT_POLICYVIOLATION&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">46</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_ANOMALY_START&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">47</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_DETECTION_ACTION_TAKEN&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">48</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_REMEDIATION_ACTION_PENDING&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">49</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_REMEDIATION_ACTION_FAILED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">50</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_REMEDIATION_ACTION_SUCCESSFUL&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">51</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_ANOMALY_FINISH&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">52</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_COMMS_LOGIN_FAILED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">53</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_COMMS_LOGIN_SUCCESS&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">54</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_COMMS_UNAUTHORIZED_COMM&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">55</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_CLIENT_INSTALL_AV&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">56</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_CLIENT_INSTALL_FW&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">57</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_CLIENT_UNINSTALL&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">58</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_CLIENT_UNINSTALL_ROLLBACK&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">59</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_COMMS_SERVER_GROUP_ROOT_CERT_ISSUE&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">60</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_COMMS_SERVER_CERT_ISSUE&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">61</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_COMMS_TRUSTED_ROOT_CHANGE&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">62</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_COMMS_SERVER_CERT_STARTUP_FAILED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">63</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_CLIENT_CHECKIN&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">64</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_CLIENT_NO_CHECKIN&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">65</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCAN_SUSPENDED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">66</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCAN_RESUMED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">67</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCAN_DURATION_INSUFFICIENT&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">68</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_CLIENT_MOVE&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">69</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_SCAN_FAILED_ENHANCED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">70</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_MAX_EVENT_NUMBER&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">71</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_HEUR_THREAT_NOW_WHITELISTED&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">72</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_INTERESTING_PROCESS_DETECTED_START&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">73</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LOAD_ERROR_COH&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">74</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_LOAD_ERROR_SYKNAPPS&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">75</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_INTERESTING_PROCESS_DETECTED_FINISH&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">76</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_HPP_SCAN_NOT_SUPPORTED_FOR_OS&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">77</span>
        hEvent <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_EVENT_HEUR_THREAT_NOW_KNOWN&quot;</span>
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Select</span>
&nbsp;
	<span style="color: #0600FF;">Select</span> <span style="color: #0600FF;">Case</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">1</span>
	    hCategory <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_CAT_INFECTION&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">2</span>
	    hCategory <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_CAT_SUMMARY&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">3</span>
	    hCategory <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_CAT_PATTERN&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">4</span>
	    hCategory <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;GL_CAT_SECURITY&quot;</span>
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Select</span>
&nbsp;
    hLogger <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>
	hComputer <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span>
	hUser <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">5</span><span style="color: #000000;">&#41;</span>
	hVirus <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">6</span><span style="color: #000000;">&#41;</span>
	hFile <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">7</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #0600FF;">Select</span> <span style="color: #0600FF;">Case</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">8</span><span style="color: #000000;">&#41;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">1</span>
	    hAction <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Quarantine&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">2</span>
	    hAction <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Rename&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">3</span>
	    hAction <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Delete&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">4</span>
	    hAction <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Leave Alone&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">5</span>
	    hAction <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Clean File&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">6</span>
	    hAction <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Clean Macros&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF8000;">Else</span>
	    hAction <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Unknown Action&quot;</span>
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Select</span>
&nbsp;
	<span style="color: #0600FF;">Select</span> <span style="color: #0600FF;">Case</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">9</span><span style="color: #000000;">&#41;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">1</span>
	    hAction2 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Quarantine&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">2</span>
	    hAction2 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Rename&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">3</span>
	    hAction2 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Delete&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">4</span>
	    hAction2 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Leave Alone&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">5</span>
	    hAction2 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Clean File&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">6</span>
	    hAction2 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Clean Macros&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF8000;">Else</span>
	    hAction2 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Unknown Action&quot;</span>
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Select</span>
&nbsp;
	<span style="color: #0600FF;">Select</span> <span style="color: #0600FF;">Case</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">1</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Quarantine&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">2</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Rename&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">3</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Delete&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">4</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Leave Alone&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">5</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Clean File&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">6</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Clean Macros&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">7</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Saved file as...&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">8</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Sent to Intel (AMS)&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">9</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Moved to backup location&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">10</span>
        hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Renamed backup file&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">11</span>
        hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Undo action in Quarantine View&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">12</span>
        hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Write protected or lack of permissions - Unable to act on file&quot;</span>
      <span style="color: #0600FF;">Case</span> <span style="color: #FF0000;">13</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Backed up file&quot;</span>
	  <span style="color: #0600FF;">Case</span> <span style="color: #FF8000;">Else</span>
	    hAction3 <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Unknown Action&quot;</span>
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Select</span>
&nbsp;
	hVirusType <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">11</span><span style="color: #000000;">&#41;</span>
	hFlags <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">12</span><span style="color: #000000;">&#41;</span>
	hDescription <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">13</span><span style="color: #000000;">&#41;</span>
	hScanId <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">14</span><span style="color: #000000;">&#41;</span>
	hNewExt <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">15</span><span style="color: #000000;">&#41;</span>
	hGroupId <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">16</span><span style="color: #000000;">&#41;</span>
	hEventData <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">17</span><span style="color: #000000;">&#41;</span>
	hQuarantineID <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">18</span><span style="color: #000000;">&#41;</span>
	hVirusID <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">19</span><span style="color: #000000;">&#41;</span>
	hQuarantineStatus <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">20</span><span style="color: #000000;">&#41;</span>
	hAccess <span style="color: #008000;">=</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">21</span><span style="color: #000000;">&#41;</span>
&nbsp;
	outline <span style="color: #008000;">=</span> hDate <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> hTime <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> hEvent <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> hCategory <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">5</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">6</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span>
	outline <span style="color: #008000;">=</span> outline <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">7</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">8</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> hAction <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">9</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> hAction2 <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> Splt<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;,&quot;</span> <span style="color: #008000;">&amp;</span> hAction3
	<span style="color: #FF8000;">For</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">11</span> <span style="color: #FF8000;">to</span> <span style="color: #0600FF;">UBound</span><span style="color: #000000;">&#40;</span>Splt<span style="color: #000000;">&#41;</span>
	  outline<span style="color: #008000;">=</span>outline<span style="color: #008000;">&amp;</span><span style="color: #808080;">&quot;,&quot;</span><span style="color: #008000;">&amp;</span>Splt<span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span>
	<span style="color: #FF8000;">Next</span>
&nbsp;
	LogFileCsv.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span>outline<span style="color: #000000;">&#41;</span>
  <span style="color: #0600FF;">Loop</span>
  LogFileCsv.<span style="color: #0600FF;">Close</span>
  LogFile.<span style="color: #0600FF;">Close</span>
&nbsp;
<span style="color: #FF8000;">Next</span></pre></div></div>

<p>I know, not exactly brimming with comments. I leave this code here, as is. Worked for me… Just take note, that in these logs there are a lot of files that get picked up that have 3 actions listed as  “Leave Alone” but (if opened in Excel) under column X it lists a File Remediation and a Delete action. The log file format is abysmal and the above linked description of the format does not accurately explain the remediation information… I have as yet been unable to determine which field of the description the remediation is supposed to be in.</p>
<p>So, Run the Batch File to copy the logs into the SEP11Logs folder. Run the VBScript with the path to SEP11Logs and it will create a copy of the log files with a .csv extension that has a bit more information.</p>
<p>Enjoy.</p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2011/03/03/sep11-scan-logs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SYSTEM Account Permissions</title>
		<link>http://www.dwarfsoft.com/blog/2010/05/25/system-account-permissions/</link>
		<comments>http://www.dwarfsoft.com/blog/2010/05/25/system-account-permissions/#comments</comments>
		<pubDate>Tue, 25 May 2010 01:08:45 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Novell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tweet]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[eDirectory]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=305</guid>
		<description><![CDATA[Recently I have been working on some rather complicated projects preparing our SOE to move from Novell eDirectory to an Active Directory environment. One of the packages I built was required to run periodically and so I set up a Scheduled Task to accomplish this. Rather than introduce a security risk by creating a new [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have been working on some rather complicated projects preparing our SOE to move from Novell eDirectory to an Active Directory environment. One of the packages I built was required to run periodically and so I set up a Scheduled Task to accomplish this. Rather than introduce a security risk by creating a new Administrator Account I just created the scheduled task to run as the local SYSTEM account. It turns out that the SYSTEM account does not have as much access as I required, especially when managing user registry hives.</p>
<p>After quite some time looking in to how to achieve my goal I came up with a rather simple, yet ultimately hacky, solution. Give the SYSTEM Account Administrative Privileges.</p>
<p><span id="more-305"></span></p>
<p>It turns out that the SYSTEM Account, despite not having Administrator level permissions, does have permission to modify group memberships. As such I came up with two functions to manage these permissions for itself:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'*****************************************************************
</span><span style="color: #008000;">' Elevates the System Account to a Member of the Administrators Group
</span><span style="color: #E56717; font-weight: bold;">Function</span> ElevateSystem
  strSystemUser = <span style="color: #800000;">&quot;WinNT://NT AUTHORITY/SYSTEM&quot;</span>
  <span style="color: #151B8D; font-weight: bold;">Set</span> objGroup = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;WinNT://./Administrators,group&quot;</span>)
  <span style="color: #8D38C9; font-weight: bold;">If</span> <span style="color: #8D38C9; font-weight: bold;">Not</span> objGroup.isMember(strSystemUser) <span style="color: #8D38C9; font-weight: bold;">Then</span>
    objGroup.Add (strSystemUser)
  <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span>
&nbsp;
<span style="color: #008000;">'*****************************************************************
</span><span style="color: #008000;">' Removes the System Account from the Administrators Group
</span><span style="color: #E56717; font-weight: bold;">Function</span> RelegateSystem
  strSystemUser = <span style="color: #800000;">&quot;WinNT://NT AUTHORITY/SYSTEM&quot;</span>
  <span style="color: #151B8D; font-weight: bold;">Set</span> objGroup = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;WinNT://./Administrators,group&quot;</span>)
  <span style="color: #8D38C9; font-weight: bold;">If</span> objGroup.isMember(strSystemUser) <span style="color: #8D38C9; font-weight: bold;">Then</span>
    objGroup.Remove (strSystemUser)
  <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>I just run ElevateSystem at the start of the script and then RelegateSystem at the end of the script and I have no issue with permissions anymore.</p>
<p>Elegant, yet hacky. Hope somebody found this useful, because it sure beats creating (and then managing) a new Administrator User on thousands of Workstations. </p>
<p>N.B. I should also point out that if you are installing a script onto Workstations that you will be using this kind of workaround on, make sure you set the permissions on it. The last thing you need is somebody hijacking your script to do whatever they want with Administrative Privileges.</p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2010/05/25/system-account-permissions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Last Login Time</title>
		<link>http://www.dwarfsoft.com/blog/2010/04/22/last-login-time/</link>
		<comments>http://www.dwarfsoft.com/blog/2010/04/22/last-login-time/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 01:54:33 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tweet]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[bginfo]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=300</guid>
		<description><![CDATA[I have recently been having a look into determining the Last Login Time of a user for a BGInfo implementation. Firstly I had a look at the getCurrentUserLastLoginTime script suggested for use with BGInfo. The limitation of this script, however, is that it will reset the login time to the last time the Windows login [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been having a look into determining the Last Login Time of a user for a BGInfo implementation. Firstly I had a look at the <a href="http://slingfive.com/pages/code/bgInfo_scripts/scripts/getCurrentUserLastLoginTime.vbs">getCurrentUserLastLoginTime script</a> suggested for use with BGInfo. The limitation of this script, however, is that it will reset the login time to the last time the Windows login box was Authenticated against, which also includes the time that the workstation was unlocked.</p>
<p>In order to maintain current BGInfo information the implementation is running periodically, so this is unnacceptable. Therefore I had to work to resolve the issue manually. As I have had a fair bit of experience with Windows Profiles recently (see the <a href="http://www.dwarfsoft.com/blog/2010/03/15/shared-user-profiles-staging-scripts/">last blog post</a>) I was familiar with the ProfileLoadTimeHigh and ProfileLoadTimeLow registry keys in the ProfileList. So I set out to determine how to actually use these to determine the login time. I first wrote some code to get the User SID based on the users &#8220;%userdomain%&#8221; and &#8220;%username%&#8221;:</p>
<p><span id="more-300"></span></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #151B8D; font-weight: bold;">DIM</span> oNet, strComputerName, strUserName, strUserDomain
<span style="color: #151B8D; font-weight: bold;">SET</span> oNet = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;WScript.Network&quot;</span>)
strComputerName = oNet.Computername
strUserName = oNet.UserName
strUserDomain = oNet.UserDomain
<span style="color: #151B8D; font-weight: bold;">SET</span> oNet = <span style="color: #00C2FF; font-weight: bold;">nothing</span>
&nbsp;
<span style="color: #151B8D; font-weight: bold;">Set</span> WMI = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;</span>)
&nbsp;
SubKey = <span style="color: #800000;">&quot;&quot;</span>
&nbsp;
<span style="color: #151B8D; font-weight: bold;">Set</span> wmiCol = WMI.ExecQuery (<span style="color: #800000;">&quot;SELECT Domain, Name, SID FROM Win32_Account where Name=&quot;</span><span style="color: #800000;">&quot;&quot;</span>&amp;strUserName&amp;<span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot; And Domain=&quot;</span><span style="color: #800000;">&quot;&quot;</span>&amp;strUserDomain&amp;<span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;&quot;</span>)
<span style="color: #8D38C9; font-weight: bold;">For</span> <span style="color: #8D38C9; font-weight: bold;">each</span> wmiItem <span style="color: #8D38C9; font-weight: bold;">in</span> wmiCol
  SubKey = wmiItem.SID
  <span style="color: #E56717; font-weight: bold;">Exit</span> <span style="color: #8D38C9; font-weight: bold;">For</span>
<span style="color: #8D38C9; font-weight: bold;">Next</span></pre></div></div>

<p>So I set Subkey to be the String SID of the user, which I could then use to read the ProfileLoadTimeHigh and ProfileLoadTimeLow keys for the correct profile. I used the basic script from <a href="http://www.myitforum.com/forums/tm.aspx?high=&#038;m=163289&#038;mpage=1#163289">MyITForum</a>, however this failed to take into account the timezone on the local machine. Therefore the first thing I needed to do was get the users timezone.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">tz = 0
<span style="color: #8D38C9; font-weight: bold;">For</span> <span style="color: #8D38C9; font-weight: bold;">Each</span> os <span style="color: #8D38C9; font-weight: bold;">In</span> <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:&quot;</span>).InstancesOf (<span style="color: #800000;">&quot;Win32_OperatingSystem&quot;</span>)
  tz = os.CurrentTimeZone
  <span style="color: #E56717; font-weight: bold;">Exit</span> <span style="color: #8D38C9; font-weight: bold;">For</span>  
<span style="color: #8D38C9; font-weight: bold;">Next</span></pre></div></div>

<p>Then I integrated the Timezone offset (in minutes) into the <a href="http://www.myitforum.com/forums/tm.aspx?high=&#038;m=163289&#038;mpage=1#163289">original ProfileLoadTime script</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">Const HKEY_LOCAL_MACHINE = &amp;H80000002
&nbsp;
strReturn = <span style="color: #800000;">&quot;&quot;</span>
&nbsp;
<span style="color: #151B8D; font-weight: bold;">Set</span> objReg = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv&quot;</span>  )
strKeyPath = <span style="color: #800000;">&quot;SOFTWARE\MICROSOFT\Windows NT\CurrentVersion\ProfileList\&quot;</span> &amp; SubKey 
&nbsp;
strValueName = <span style="color: #800000;">&quot;ProfileLoadTimeHigh&quot;</span>
Return = objReg.GetDWORDValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,lngHighValue)
strValueName = <span style="color: #800000;">&quot;ProfileLoadTimeLow&quot;</span>
Return = objReg.GetDWORDValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,lngLowValue)
<span style="color: #8D38C9; font-weight: bold;">If</span> typename(lngHighValue) &lt;&gt; <span style="color: #800000;">&quot;Null&quot;</span> <span style="color: #8D38C9; font-weight: bold;">then</span>
  NanoSecs = (lngHighValue * 2 ^ 32 + lngLowValue)
  <span style="color: #008000;">'' /* Returns time in Workstation Timezone */
</span>  DT = #1/1/1601# + (NanoSecs / 600000000 / 1440) + (tz / 1440)
  strReturn = CDate(DT)
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">if</span></pre></div></div>

<p>Finally the output is printed as per a standard BGInfo script</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #151B8D; font-weight: bold;">On</span> <span style="color: #151B8D; font-weight: bold;">Error</span> <span style="color: #151B8D; font-weight: bold;">Resume</span> <span style="color: #8D38C9; font-weight: bold;">Next</span>
	<span style="color: #E56717; font-weight: bold;">call</span> WScript.Echo(strReturn)	<span style="color: #008000;">'for cmd line
</span>	<span style="color: #E56717; font-weight: bold;">call</span> Echo(strReturn)	<span style="color: #008000;">'for BGInfo
</span><span style="color: #151B8D; font-weight: bold;">on</span> <span style="color: #151B8D; font-weight: bold;">error</span> <span style="color: #8D38C9; font-weight: bold;">goto</span> 0</pre></div></div>

<p>This works for Power Users as well, which the original script did not (due to permissions issues). Hope this helped you in some way <img src='http://www.dwarfsoft.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2010/04/22/last-login-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shared User Profiles &#8211; Staging Scripts</title>
		<link>http://www.dwarfsoft.com/blog/2010/03/15/shared-user-profiles-staging-scripts/</link>
		<comments>http://www.dwarfsoft.com/blog/2010/03/15/shared-user-profiles-staging-scripts/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 05:19:40 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Novell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tweet]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[eDirectory]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[Profile]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=291</guid>
		<description><![CDATA[As promised, here are the scripts required for the Pre-staging of Domain User Profiles on the local machine. The first thing we need to do is Enumerate all the Local User Accounts. Function StageAllUsers(DomainFQDN, strDomain) ' Enumerate all users that are Local and not built in accounts. strComputer = &#34;.&#34; Set objWMIService = GetObject(&#34;winmgmts:\\&#34; &#38; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dwarfsoft.com/blog/2010/03/12/shared-user-profiles-alternative-to-migration/">As promised</a>, here are the scripts required for the Pre-staging of Domain User Profiles on the local machine. The first thing we need to do is Enumerate all the Local User Accounts.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Function</span> StageAllUsers(DomainFQDN, strDomain)
   <span style="color: #008000;">' Enumerate all users that are Local and not built in accounts.
</span>   strComputer = <span style="color: #800000;">&quot;.&quot;</span>
   <span style="color: #151B8D; font-weight: bold;">Set</span> objWMIService = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:\\&quot;</span> &amp; strComputer &amp; <span style="color: #800000;">&quot;\root\cimv2&quot;</span>)
   <span style="color: #008000;">'Enumerate users where the User Domain is the Local Machine
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> colItems = objWMIService.ExecQuery _
                  (<span style="color: #800000;">&quot;Select * from Win32_UserAccount &quot;</span> &amp; _
                   <span style="color: #800000;">&quot;Where Domain = '&quot;</span> &amp; GetComputerName &amp; <span style="color: #800000;">&quot;' &quot;</span> &amp; _
                   <span style="color: #800000;">&quot;And Disabled = FALSE And Name &lt;&gt; 'Administrator'&quot;</span>)
   <span style="color: #008000;">' Stage each user
</span>   <span style="color: #8D38C9; font-weight: bold;">For</span> <span style="color: #8D38C9; font-weight: bold;">Each</span> objItem <span style="color: #8D38C9; font-weight: bold;">In</span> colItems
      <span style="color: #008000;">' Ensure the account actually has a profile (otherwise we can ignore it)
</span>      <span style="color: #8D38C9; font-weight: bold;">If</span> GetLocalUserProfile(objItem.Name) &lt;&gt; <span style="color: #800000;">&quot;&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Then</span>
         ret = StageUser(objItem.Name, DomainFQDN, strDomain)
      <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span>
   <span style="color: #8D38C9; font-weight: bold;">Next</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>The functions called here are GetComputerName, which returns the name of the local machine, and the other important ones are GetLocalUserProfile and Stage User. The first we can check is GetLocalUserProfile.<span id="more-291"></span></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'Gets the Profile Path for the User passed in UserName.
</span><span style="color: #008000;">' This requires the profile to exist on the local machine
</span><span style="color: #008000;">' Returns an empty string on error
</span><span style="color: #E56717; font-weight: bold;">Function</span> GetLocalUserProfile(UserName)
   <span style="color: #151B8D; font-weight: bold;">On</span> <span style="color: #151B8D; font-weight: bold;">Error</span> <span style="color: #151B8D; font-weight: bold;">Resume</span> <span style="color: #8D38C9; font-weight: bold;">Next</span>
   GetLocalUserProfile = <span style="color: #800000;">&quot;&quot;</span>
   SDDL = GetLocalUserSDDL(UserName)
   <span style="color: #8D38C9; font-weight: bold;">If</span> SDDL = <span style="color: #800000;">&quot;&quot;</span> <span style="color: #8D38C9; font-weight: bold;">Then</span>
      <span style="color: #E56717; font-weight: bold;">Exit</span> <span style="color: #E56717; font-weight: bold;">Function</span>
   <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span>
   <span style="color: #151B8D; font-weight: bold;">Set</span> objShell = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;WScript.Shell&quot;</span>)
   GetLocalUserProfile = objShell.ExpandEnvironmentStrings( _
                            objShell.RegRead( _
                               <span style="color: #800000;">&quot;HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\&quot;</span> &amp; _
                               SDDL &amp; _
                               <span style="color: #800000;">&quot;\ProfileImagePath&quot;</span>))
  <span style="color: #151B8D; font-weight: bold;">On</span> <span style="color: #151B8D; font-weight: bold;">Error</span> <span style="color: #8D38C9; font-weight: bold;">Goto</span> 0
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>The registry path (including the SDDL, covered next) returns the profile path for the user. This relies on a function called GetLocalUserSDDL which goes as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Function</span> GetLocalUserSDDL(UserName)
   strComputer = <span style="color: #800000;">&quot;.&quot;</span>
   <span style="color: #151B8D; font-weight: bold;">Set</span> objWMIService = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:\\&quot;</span> &amp; strComputer &amp; <span style="color: #800000;">&quot;\root\cimv2&quot;</span>)
   <span style="color: #008000;">'Enumerate users where the User Domain is the Local Machine
</span>   <span style="color: #008000;">'and the username matches the Supplied Name
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> colItems = objWMIService.ExecQuery _
                     (<span style="color: #800000;">&quot;Select * from Win32_UserAccount  &quot;</span> &amp; _
                      <span style="color: #800000;">&quot;Where Domain = '&quot;</span> &amp; GetComputerName &amp; <span style="color: #800000;">&quot;' &quot;</span> &amp; _
                      <span style="color: #800000;">&quot;And Name = '&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;'&quot;</span>)
   GetLocalUserSDDL = <span style="color: #800000;">&quot;&quot;</span>
   <span style="color: #8D38C9; font-weight: bold;">For</span> <span style="color: #8D38C9; font-weight: bold;">Each</span> objItem <span style="color: #8D38C9; font-weight: bold;">In</span> colItems
      <span style="color: #008000;">'Get the first returned SID/SDDL then exit
</span>      GetLocalUserSDDL = objItem.SID
      <span style="color: #E56717; font-weight: bold;">Exit</span> <span style="color: #E56717; font-weight: bold;">Function</span>
   <span style="color: #8D38C9; font-weight: bold;">Next</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>This reads the SDDL (eg S-1-5-21-791012361-4073638415-1907800938-1006 or otherwise known as the String SID) for the User on the local machine. The next major function is Stage User:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Function</span> StageUser(UserName, DomainFQDN, strDomain)
   <span style="color: #151B8D; font-weight: bold;">Set</span> objShell = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;WScript.Shell&quot;</span>)
   <span style="color: #008000;">' Not Assuming &quot;C:\Documents and Settings\&quot; &amp; UserName:
</span>   <span style="color: #008000;">'   Get SDDL of user via WMI interrogation of UserAccount
</span>   <span style="color: #008000;">'   Get Profile Location of user (from HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\&quot; &amp; SDDL &amp; &quot;ProfileImagePath&quot;
</span>   strProfile = GetLocalUserProfile(UserName)
&nbsp;
   <span style="color: #008000;">' Set ACLs on ProfileLocation
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;subinacl /subdirectories &quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; strProfile &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot; /grant=&quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;@&quot;</span> &amp; DomainFQDN &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;=F&quot;</span>,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
&nbsp;
   <span style="color: #008000;">' Set ACLs on D:\UserData\%username%
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;subinacl /subdirectories &quot;</span><span style="color: #800000;">&quot;D:\UserData\&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot; /grant=&quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;@&quot;</span> &amp; DomainFQDN &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;=F&quot;</span>,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
&nbsp;
   <span style="color: #008000;">' Reg load ProfileLocation\NTUSER.DAT into HKU\%username%
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;reg load &quot;</span><span style="color: #800000;">&quot;HKU\&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot; &quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; strProfile &amp; <span style="color: #800000;">&quot;\NTUSER.DAT&quot;</span><span style="color: #800000;">&quot;&quot;</span> ,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
   <span style="color: #008000;">' Reg load ProfileLocation\Local Settings\Application Data\Microsoft\Windows\UsrClass.DAT into HKU\%username%_Classes
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;reg load &quot;</span><span style="color: #800000;">&quot;HKU\&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;_Classes&quot;</span><span style="color: #800000;">&quot; &quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; strProfile &amp; <span style="color: #800000;">&quot;\Local Settings\Application Data\Microsoft\Windows\UsrClass.DAT&quot;</span><span style="color: #800000;">&quot;&quot;</span> ,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
&nbsp;
   <span style="color: #008000;">'Try both of the following. One should fail, the other should pass.
</span>   <span style="color: #008000;">' Set ACLs on HKU\%username%
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;subinacl /subkeyreg &quot;</span><span style="color: #800000;">&quot;HKEY_USERS\&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot; /grant=&quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;@&quot;</span> &amp; DomainFQDN &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;=F&quot;</span>,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
   <span style="color: #008000;">' If User is already logged in then the registry will be open at HKU\SDDL
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;subinacl /subkeyreg &quot;</span><span style="color: #800000;">&quot;HKEY_USERS\&quot;</span> &amp; GetLocalUserSDDL(UserName) &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot; /grant=&quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;@&quot;</span> &amp; DomainFQDN &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;=F&quot;</span>,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
&nbsp;
   <span style="color: #008000;">'Try both of the following. One should fail, the other should pass.
</span>   <span style="color: #008000;">' Set ACLs on HKU\%username%
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;subinacl /subkeyreg &quot;</span><span style="color: #800000;">&quot;HKEY_USERS\&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;_Classes&quot;</span><span style="color: #800000;">&quot; /grant=&quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;@&quot;</span> &amp; DomainFQDN &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;=F&quot;</span>,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
   <span style="color: #008000;">' If User is already logged in then the registry will be open at HKU\SDDL
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;subinacl /subkeyreg &quot;</span><span style="color: #800000;">&quot;HKEY_USERS\&quot;</span> &amp; GetLocalUserSDDL(UserName) &amp; <span style="color: #800000;">&quot;_Classes&quot;</span><span style="color: #800000;">&quot; /grant=&quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;@&quot;</span> &amp; DomainFQDN &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;=F&quot;</span>,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
&nbsp;
   <span style="color: #008000;">' Reg unload HKU\%username%
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;reg unload &quot;</span><span style="color: #800000;">&quot;HKU\&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;&quot;</span>,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
   <span style="color: #008000;">' Reg unload HKU\%username%_Classes
</span>   ret = objShell.Run(<span style="color: #800000;">&quot;reg unload &quot;</span><span style="color: #800000;">&quot;HKU\&quot;</span> &amp; UserName &amp; <span style="color: #800000;">&quot;_Classes&quot;</span><span style="color: #800000;">&quot;&quot;</span>,0,<span style="color: #00C2FF; font-weight: bold;">True</span>)
&nbsp;
   <span style="color: #008000;">' Get Domain User SID from ProfileLocation ACL
</span>   arrSID = GetDomainUserSidFromFolderACL(strProfile, UserName, strDomain)
&nbsp;
   <span style="color: #8D38C9; font-weight: bold;">If</span> <span style="color: #151B8D; font-weight: bold;">UBound</span>(arrSID) &gt; 0 <span style="color: #8D38C9; font-weight: bold;">Then</span>
      <span style="color: #008000;">' Convert Domain User SID to SDDL
</span>      WScript.Echo <span style="color: #800000;">&quot;Getting Sid for &quot;</span> &amp; UserName
      SDDL = ArraySidToStrSid(arrSID)
&nbsp;
      <span style="color: #008000;">' Stage Domain User Profile into Registry under HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\%DomainUserSDDL%
</span>      ret = CreateAndLinkProfile(SDDL, arrSID, strProfile)
   <span style="color: #8D38C9; font-weight: bold;">Else</span>
      <span style="color: #008000;">'Account didn't exist in the domain or ACL failed to set on Folder
</span>   <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>For the most part this function behaves by running external commands to mount registry hives, and set ACLs on folders and registry, all up until we call GetDomainUserSidFromFolderACL. This is where we retrieve the SID of the Domain User that we are pre-staging via the ACL we set earlier on the Local User Profile folder. This subverts the need to query Active Directory for the SID through other means.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Function</span> GetDomainUserSidFromFolderACL(strFolder, strUserName, strUserDomain)
   <span style="color: #151B8D; font-weight: bold;">Dim</span> arrSID(0)
   GetDomainUserSidFromFolderACL = arrSID
&nbsp;
   <span style="color: #151B8D; font-weight: bold;">Set</span> objFSO = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;Scripting.FileSystemObject&quot;</span>)
   <span style="color: #8D38C9; font-weight: bold;">If</span> <span style="color: #8D38C9; font-weight: bold;">Not</span> objFSO.FolderExists(strFolder) <span style="color: #8D38C9; font-weight: bold;">Then</span>
      <span style="color: #151B8D; font-weight: bold;">Set</span> objFSO = <span style="color: #00C2FF; font-weight: bold;">Nothing</span>
      <span style="color: #E56717; font-weight: bold;">Exit</span> <span style="color: #E56717; font-weight: bold;">Function</span>
   <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span>
&nbsp;
   <span style="color: #008000;">' Ensure that strFolder is of the form C:\\Documents and Settings\\UserName
</span>    strFolderName = Replace(strFolder, <span style="color: #800000;">&quot;\\&quot;</span>,<span style="color: #800000;">&quot;\&quot;</span>)
    strFolderName = Replace(strFolderName, <span style="color: #800000;">&quot;\&quot;</span>,<span style="color: #800000;">&quot;\\&quot;</span>)
&nbsp;
   <span style="color: #151B8D; font-weight: bold;">Set</span> wmiFileSecSetting = <span style="color: #E56717; font-weight: bold;">GetObject</span>( _
      <span style="color: #800000;">&quot;winmgmts:Win32_LogicalFileSecuritySetting.path='&quot;</span> &amp; strFolderName &amp; <span style="color: #800000;">&quot;'&quot;</span>)
&nbsp;
   RetVal = wmiFileSecSetting. _
       GetSecurityDescriptor(wmiSecurityDescriptor)
   <span style="color: #8D38C9; font-weight: bold;">If</span> Err &lt;&gt; 0 <span style="color: #8D38C9; font-weight: bold;">Then</span>
       <span style="color: #E56717; font-weight: bold;">Exit</span> <span style="color: #E56717; font-weight: bold;">Function</span>
   <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span>
&nbsp;
   <span style="color: #008000;">' Retrieve the DACL array of Win32_ACE objects.
</span>   DACL = wmiSecurityDescriptor.DACL
&nbsp;
   <span style="color: #8D38C9; font-weight: bold;">For</span> <span style="color: #8D38C9; font-weight: bold;">each</span> wmiAce <span style="color: #8D38C9; font-weight: bold;">in</span> DACL
   <span style="color: #008000;">' Get Win32_Trustee object from ACE 
</span>      <span style="color: #151B8D; font-weight: bold;">Set</span> Trustee = wmiAce.Trustee
      <span style="color: #8D38C9; font-weight: bold;">If</span> (StrComp(Trustee.Name, strUserName, vbTextCompare) = 0) <span style="color: #8D38C9; font-weight: bold;">And</span> _
         (StrComp(Trustee.Domain, strUserDomain, vbTextCompare) = 0) <span style="color: #8D38C9; font-weight: bold;">Then</span>
         GetDomainUserSidFromFolderACL = Trustee.SID
         <span style="color: #E56717; font-weight: bold;">Exit</span> <span style="color: #E56717; font-weight: bold;">Function</span>
      <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span>
   <span style="color: #8D38C9; font-weight: bold;">Next</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>Although this subverts the need to Query Active Directory, this does also mean that we receive the SID in a format that is unexpected. Normally, via querying Active Directory we would have received a SID in an Octet String format. Querying the SID from WMI returned it in SDDL or String SID format. The format that we receive the SID from the ACL is in an Array of Integers. In order to Pre-stage an account we need the SDDL/String SID, and the only way to get this in VBScript is to manually convert it using some functions developed by Richard Mueller and Wilfred Wong in <a href="http://groups.google.com.au/group/microsoft.public.windows.server.active_directory/browse_thread/thread/5e26b20bba486280/95eb5a589be4cf11">this newsgroup posting</a>.</p>
<p>Instead of using only the code listed, we need to alter it for dealing with the SID array we received back from the ACL.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Function</span> ArraySidToStrSid(arrSid)
   <span style="color: #008000;">' Function to convert OctetString (byte array) to Decimal string (SDDL) Sid.
</span>   <span style="color: #151B8D; font-weight: bold;">Dim</span> strHex, strDec
&nbsp;
   strHex = ArraySidToHexStr(arrSid)
   strDec = HexStrToDecStr(strHex)
   ArraySidToStrSid = strDec
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span>
&nbsp;
<span style="color: #E56717; font-weight: bold;">Function</span> ArraySidToHexStr(arrSid)
   ArraySidToHexStr = <span style="color: #800000;">&quot;&quot;</span>
   <span style="color: #8D38C9; font-weight: bold;">For</span> <span style="color: #8D38C9; font-weight: bold;">Each</span> x <span style="color: #8D38C9; font-weight: bold;">In</span> arrSid
      ArraySidToHexStr = ArraySidToHexStr &amp; _
         Right(<span style="color: #800000;">&quot;0&quot;</span> &amp; Hex(x), 2)
   <span style="color: #8D38C9; font-weight: bold;">Next</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>The HexStrToDecStr function is the same as it was from the <a href="http://groups.google.com.au/group/microsoft.public.windows.server.active_directory/browse_thread/thread/5e26b20bba486280/95eb5a589be4cf11">Richard Mueller posting</a> listed above.</p>
<p>Finally we just need to run through the actual staging of the account:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Function</span> CreateAndLinkProfile(strNewSDDL, strNewSID, strProfilePath)
   WScript.Echo <span style="color: #800000;">&quot;Creating Profile for &quot;</span> &amp; strNewSDDL &amp; <span style="color: #800000;">&quot;: &quot;</span> &amp; strProfilePath
   <span style="color: #008000;">'Write Sid to registry
</span>   ret = WriteRegBinaryToRegistry(HKEY_LOCAL_MACHINE,<span style="color: #800000;">&quot;SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\&quot;</span> &amp; strNewSDDL,<span style="color: #800000;">&quot;Sid&quot;</span>,strNewSID)
   ret = WriteRegStringToRegistry(HKEY_LOCAL_MACHINE,<span style="color: #800000;">&quot;SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\&quot;</span> &amp; strNewSDDL,<span style="color: #800000;">&quot;ProfileImagePath&quot;</span>,strProfilePath)
   ret = WriteRegStringToRegistry(HKEY_LOCAL_MACHINE,<span style="color: #800000;">&quot;SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\&quot;</span> &amp; strNewSDDL,<span style="color: #800000;">&quot;CentralProfile&quot;</span>,<span style="color: #800000;">&quot;&quot;</span>)
   ret = WriteRegDwordToRegistry(HKEY_LOCAL_MACHINE,<span style="color: #800000;">&quot;SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\&quot;</span> &amp; strNewSDDL,<span style="color: #800000;">&quot;Flags&quot;</span>,1)
   ret = WriteRegDwordToRegistry(HKEY_LOCAL_MACHINE,<span style="color: #800000;">&quot;SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\&quot;</span> &amp; strNewSDDL,<span style="color: #800000;">&quot;State&quot;</span>,0)
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>At this point if the Domain User logs in they get redirected to the existing local users profile. Then if rollback is initiated they log on with the Local User account with the same profile. This is seamless to end users, both forward and backward. </p>
<p>On a side note the functions for writing to the registry are through WMI due to needing to write Binary values to the Registry</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Function</span> WriteRegBinaryToRegistry(Hive, strKeyPath, strValueName, ArrValues)
   strComputer = <span style="color: #800000;">&quot;.&quot;</span>
   <span style="color: #151B8D; font-weight: bold;">Set</span> oReg = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot;</span> &amp; _
               strComputer &amp; <span style="color: #800000;">&quot;\root\default:StdRegProv&quot;</span>)
   oReg.CreateKey Hive,strKeyPath
&nbsp;
   oReg.SetBinaryValue Hive, strKeyPath, strValueName,ArrValues
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span>
&nbsp;
<span style="color: #E56717; font-weight: bold;">Function</span> WriteRegDwordToRegistry(Hive, strKeyPath, strValueName, Value)
   strComputer = <span style="color: #800000;">&quot;.&quot;</span>
   <span style="color: #151B8D; font-weight: bold;">Set</span> oReg = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot;</span> &amp; _
               strComputer &amp; <span style="color: #800000;">&quot;\root\default:StdRegProv&quot;</span>)
   oReg.CreateKey Hive,strKeyPath
&nbsp;
   oReg.SetDwordValue Hive, strKeyPath, strValueName,Value
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span>
&nbsp;
<span style="color: #E56717; font-weight: bold;">Function</span> WriteRegStringToRegistry(Hive, strKeyPath, strValueName, Value)
   strComputer = <span style="color: #800000;">&quot;.&quot;</span>
   <span style="color: #151B8D; font-weight: bold;">Set</span> oReg = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot;</span> &amp; _
               strComputer &amp; <span style="color: #800000;">&quot;\root\default:StdRegProv&quot;</span>)
   oReg.CreateKey Hive,strKeyPath
&nbsp;
   oReg.SetStringValue Hive, strKeyPath, strValueName,Value
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>Cheers, Chris.</p>
<p>Edit: <a href='http://www.dwarfsoft.com/blog/wp-content/uploads/2010/03/DomainAccountProfileStaging.vbs_.txt'>DomainAccountProfileStaging.vbs</a> has been uploaded as a complete file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2010/03/15/shared-user-profiles-staging-scripts/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Shared User Profiles &#8211; Alternative to Migration</title>
		<link>http://www.dwarfsoft.com/blog/2010/03/12/shared-user-profiles-alternative-to-migration/</link>
		<comments>http://www.dwarfsoft.com/blog/2010/03/12/shared-user-profiles-alternative-to-migration/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 10:01:16 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Novell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tweet]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[eDirectory]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[Profile]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=287</guid>
		<description><![CDATA[Well, I have been very slack in that I haven&#8217;t updated with my Group Policy investigations or the eDirectory VBScript classes I was working on, but what I have been involved in recently is working on Migrating Workstations from Novell eDirectory to Active Directory. In this process I have come across an array of options [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I have been very slack in that I haven&#8217;t updated with my Group Policy investigations or the eDirectory VBScript classes I was working on, but what I have been involved in recently is working on Migrating Workstations from Novell eDirectory to Active Directory.</p>
<p>In this process I have come across an array of options in migrating accounts from a Local User account to Domain User account and transferring the profiles across to keep the user &#8220;look and feel&#8221; that they are accustomed to.</p>
<p>One problem: In this scenario it makes for a very manual rollback strategy, no matter how much scripting and automation is involved in the migration process. This boils down to Novells implementation of &#8220;Dynamic Local User&#8221; which effectively creates a Local User Account that is not really bound to a User Account in eDirectory for Authentication or mapping purposes (which you can see if you look at the account SIDs).</p>
<p><span id="more-287"></span></p>
<p>So, how can you Migrate a local profile to a Domain User account while still maintaining a seamless rollback option (without using Roaming Profiles&#8230; This is out of the question)? The solution I have worked on is what I am terming &#8220;pre-staging&#8221; or &#8220;seeding&#8221; the Domain User Profile.</p>
<ol>
<li>Enumerate all Local Enabled Users (except for &#8220;Administrator&#8221;)</li>
<li>Get the SID for that User (and the SDDL/String SID)</li>
<li>Read the Profile Path for that User from Registry</li>
<li>Set an ACL on that folder for &lt;Domain>\&lt;UserName> (we have the UserName being replicated between eDirectory and Active Directory</li>
<li>Mount the existing users NTUser.dat into HKU\&lt;UserName></li>
<li>Set ACL on HKU\&lt;UserName> and all subkeys for &lt;Domain>\&lt;UserName></li>
<li>Set ACL on HKU\&lt;LocalUserSID> and all subkeys  for &lt;Domain>\&lt;UserName> (just in case the user is actually logged in)</li>
<li>Dismount HKU\&lt;UserName></li>
<li>Mount the User Class hive (UsrClass.dat) into HKU\&lt;UserName>_Classes</li>
<li>Set ACL on HKU\&lt;UserName>_Classes and all subkeys for &lt;Domain>\&lt;UserName></li>
<li>Set ACL on HKU\&lt;LocalUserSID>_Classes and all subkeys  for &lt;Domain>\&lt;UserName> (just in case the user is actually logged in)</li>
<li>Dismount HKU\&lt;UserName>_Classes</li>
<li>Read the ACL on the Profile Folder (set Earlier) for &lt;Domain>\&lt;UserName> to get the Domain User SID</li>
<li>Convert the Domain User SID to an SDDL/String SID</li>
<li>Pre-stage/Seed the Domain User Profile by creating a new Registry key in HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\&lt;DomainUserSDDL></li>
<li>Write in a few choice keys, the two most important being ProfileImagePath (String) and Sid (Binary). (The others I seeded were the DWords State and Flags, which were set to 0, and CentralProfile, which was an empty string).</li>
</ol>
<p>Once the eDirectory user is no longer a member of a DLU enabled User Profile Package, they will be forced to log on through the Active Directory Domain (yes, we are still logging on through the Novell Client). The Profile used for the Domain User will be the same as that used by the Local user. The added benefit is that our rollback strategy becomes &#8220;Add user to a DLU enabled User Policy Package&#8221; and gets them to log back into their original profile. To safely secure a situation where there is a catastrophic failure of the profile (loss) a backup of the profile can also be done at the seeding stage (just check %userdomain% for equality with %computername% to see if they are logging on with a Local account or a Domain Account).</p>
<p>This has had only minor testing at this stage, but as no paths have changed and there appears to be no problem with the Domain User using the existing Profile I believe this is a reasonably comprehensive solution. This, I must stress, is not a recommended way to deal with migrating users, but it is a tricky little feature that can be abused as I have just demonstrated.</p>
<p>Code (or VBScript) will follow soon</p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2010/03/12/shared-user-profiles-alternative-to-migration/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>GroupWise Audit and Batch/Cmd Escaping</title>
		<link>http://www.dwarfsoft.com/blog/2009/07/27/groupwise-audit-and-batchcmd-escaping/</link>
		<comments>http://www.dwarfsoft.com/blog/2009/07/27/groupwise-audit-and-batchcmd-escaping/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 04:52:37 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Novell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tweet]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[CMD]]></category>
		<category><![CDATA[Groupwise]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=259</guid>
		<description><![CDATA[I was required recently to audit passwords on all the Novell GroupWise accounts in the cluster. This was not too much of a problem using existing solutions, except that all the existing solutions limited searches to either Users, or to objects with the &#8220;NGW: Object ID&#8221; attribute. The Solutions I found include Check GroupWise Users [...]]]></description>
			<content:encoded><![CDATA[<p>I was required recently to audit passwords on all the Novell GroupWise accounts in the cluster. This was not too much of a problem using existing solutions, except that all the existing solutions limited searches to either Users, or to objects with the &#8220;NGW: Object ID&#8221; attribute.</p>
<p>The Solutions I found include <a href="http://www.novell.com/coolsolutions/tools/17221.html">Check GroupWise Users for Password &#8211; Batch</a> and <a href="http://www.novell.com/communities/node/5753/check-groupwise-users-password">Check GroupWise Users for Password &#8211; Exe</a>, both of which made use of <a href="http://www.novell.com/coolsolutions/tools/13913.html">GWSend</a>. Being an avid scripting aficionado myself I opted for the first, so I could make changes.</p>
<p>First step was to export all User Objects with NGW: Object ID into an Excel sheet using <a href="http://www.novell.com/coolsolutions/tools/13908.html">DSReport</a>. Then export all GroupWise External Entities with NGW: Object ID to a different Excel Sheet. Finally I needed to export all GroupWise Resources, which do not have an NGW: Object ID, but their CN is effectively the NGW: Object ID for which we can log in and try to send emails. Upon completing this I compiled a single list of Allusers.csv which had the NGW: ObjectID/CN in the first column, and the DN for the Object Name and Location within the tree. This makes it far easier to track down the location of generic accounts (Something that none of the scripts account for).</p>
<p><span id="more-259"></span></p>
<p>So, my first run through the script ended in Fail. Apparently the above solutions are expecting Email Addresses without Spaces. So after fixing that up I run it again, and again hit a Fail. Apparently the above solutions fail to account for special characters (/ in this instance). So, I fix this up as well&#8230; My script runs, I get a report, then I realise that I have more results than original users. Apparently the above script also assumes that there is only 1 line in the result.txt file. So I modified the script to only print out a result once all lines of the result.txt file had been parsed, using a SET to determine if the &#8220;Error:&#8221; had been encountered or not (Error indicating that a Password is on the account, no Error indicating that there is No password).</p>
<p>So, now I run through and notice that the audit fails to log the full line of text, even though it is capable of actually running the audit against that account. Fortunately none of the accounts without passwords were affected by this, but I decided to fix this for future runs. To break down the issues I needed to fix into a list here is the summary:</p>
<ol>
<li>We have spaces in our Email Account Names</li>
<li>We have /&#8217;s in our Email Account Names</li>
<li>We have &amp;&#8217;s in our Email Account Names</li>
<li>We are trying to create a HTML file with the above special characters (specifically &amp;)</li>
<li>&amp; doesn&#8217;t tend to work too nicely in batch files when using an open Echo (tries to run everything after the &amp; as a program</li>
<li>I wanted to be able to track back to objects (DN&#8217;s) as opposed to just the GroupWise Account Name</li>
</ol>
<p>Spaces were easy to fix&#8230; When running the command against an account simply put the &#8220;account in quotes&#8221;. The next step is to handle the Email and DN objects as Strings within Quotes as well, but we don&#8217;t want to output the quotes, which means we need to handle them properly. Examine the following issue:</p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;">SET <span style="color: #0080FF; font-weight: bold;">String</span>=A <span style="color: #0080FF; font-weight: bold;">String</span> With Special Chars<span style="color: #66cc66;">&amp;</span>Slashes<span style="color: #66cc66;">/</span> <span style="color: #800080;">In</span> \ it<span style="color: #66cc66;">^</span> OK
ECHO <span style="color: #66cc66;">%</span>String<span style="color: #66cc66;">%</span></pre></div></div>

<p>This will return &#8220;&#8216;Slashes&#8217; is not recognized as an internal or external command, operable program or batch file.&#8221; Also, if we try and escape each of the characters we run into issues too.</p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;">SET <span style="color: #0080FF; font-weight: bold;">String</span>=A <span style="color: #0080FF; font-weight: bold;">String</span> With Special Chars<span style="color: #66cc66;">&amp;</span>Slashes<span style="color: #66cc66;">/</span> <span style="color: #800080;">In</span> \ it<span style="color: #66cc66;">^</span> OK
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:^=^^%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:\=^\%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:/=^/%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:&amp;=^&amp;%</span>
ECHO <span style="color: #66cc66;">%</span>String<span style="color: #66cc66;">%</span></pre></div></div>

<p>The Output ends up as &#8220;A String With Special Chars&#8221;. So, in order to fix this we need to handle the string within Quotes, and only output it at the end:</p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;">SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #ff0000;">&quot;A String With Special Chars&amp;Slashes/ In \ it^ OK&quot;</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:^=^^%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:\=^\%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:/=^/%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:&amp;=^&amp;%</span>
ECHO <span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:~1,-1%</span></pre></div></div>

<p>Finally, our output is &#8220;A String With Special Chars&amp;Slashes/ In \ it^ OK&#8221;, without the quotes. So the first part works now for my output to the Logs (although my logs are CSV so I tend to leave the quotes on just in case there is a lurking comma, but this does provide a pretty Output to the Console). Now we need to convert these for HTML output.</p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;">SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:^&amp;=^&amp;amp;%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:&lt;=^&amp;lt;%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:&gt;=^&amp;gt;%</span>
ECHO <span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:~1,-1%</span></pre></div></div>

<p>Just provides that little added extra safety net for an echo directly into a HTML log. I am annoyed that I didn&#8217;t manage to figure this out earlier as I had some scripts I went directly to VBScript for to avoid the &amp; errors I was getting. I had no idea that it was my subsequent SET x=%x:a=b%, SET x=%x:c=d% calls on an unquoted string.</p>
<p>The one caveat I have found to this is fixing quote marks within a string. I have yet to find a way to strip them effectively without breaking the string/batch file in the process. The closest I have come will work in most situations, but requires a placeholder you have to be sure will never exist within your string:</p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;">SET <span style="color: #0080FF; font-weight: bold;">String</span>=Thi\s<span style="color: #ff0000;">&quot; is ^a &amp;t&quot;</span>es<span style="color: #66cc66;">/</span>t
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #ff0000;">&quot;%String:&quot;</span>=<span style="color: #66cc66;">&amp;</span>quot<span style="color: #008000; font-style: italic;">;%&quot;</span>
Set <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:^=^^%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:&amp;=^&amp;%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:/=^/%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:\=^\%</span>
SET <span style="color: #0080FF; font-weight: bold;">String</span>=<span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:&amp;quot;=^&quot;%</span>
ECHO <span style="color: #66cc66;">%</span><span style="color: #0080FF; font-weight: bold;">String</span><span style="color: #FF1010; font-weight: bold;">:~1,-1%</span></pre></div></div>

<p>One other note I&#8217;d like to add is that of Padding numbers. This is a fairly well known feature of WinBatch, but I found it useful for getting well aligned output for which record I was currently up to:</p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;">Set _Num=<span style="color: #cc66cc;">0</span>
...
SET <span style="color: #66cc66;">/</span>A <span style="color: #66cc66;">%</span>_Num<span style="color: #66cc66;">%</span>=<span style="color: #66cc66;">%</span>_Num<span style="color: #66cc66;">%+</span><span style="color: #cc66cc;">1</span>
SET DispNum=     <span style="color: #66cc66;">%</span>_Num<span style="color: #66cc66;">%</span>
Echo <span style="color: #66cc66;">%</span>DispNum<span style="color: #FF1010; font-weight: bold;">:~-4%</span></pre></div></div>

<p>This pads the leading digits with spaces and specifies that I want a 4 character long string returned for the end of the string. (so &#8221;   1&#8243; in the first instance but in my case up to &#8221; 900&#8243; or  &#8220;9091&#8243;).</p>
<p>Hope this adds a little food for thought.</p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2009/07/27/groupwise-audit-and-batchcmd-escaping/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Back Behind the Keyboard</title>
		<link>http://www.dwarfsoft.com/blog/2009/07/20/back-behind-the-keyboard/</link>
		<comments>http://www.dwarfsoft.com/blog/2009/07/20/back-behind-the-keyboard/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 04:31:21 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Home]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Uni]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Certification]]></category>
		<category><![CDATA[Daugher]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[Graduation]]></category>
		<category><![CDATA[GTD]]></category>
		<category><![CDATA[Novell]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PyTA]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[TED]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=252</guid>
		<description><![CDATA[It has again been some time since my last update. I have been quite busy getting used to balancing my new life with my daughter now nearly 3 months old. Fatherhood has obviously taken a lot of my time that I previously used for development, and learning. The past few months have also seen my [...]]]></description>
			<content:encoded><![CDATA[<p>It has again been some time since my last update. I have been quite busy getting used to balancing my new life with my daughter now nearly 3 months old. Fatherhood has obviously taken a lot of my time that I previously used for development, and learning.</p>
<p>The past few months have also seen my University Graduation 3 days after my Daughters Birth, Family Visits, Job Applications, Job Interviews, and finally Permanency in my Servers Position.</p>
<p>Aside from that I have been working with some friends on converting the old TA Server to the C# .Net/Python version (PyTA). I have also been busy in mapping out my development goals and objectives for the coming months and years.</p>
<p><span id="more-252"></span></p>
<div class="wp-caption alignright" style="width: 84px"><a href="http://www.amazon.com/dp/0142000280?tag=dwgp-20&amp;camp=213381&amp;creative=390973&amp;linkCode=as4&amp;creativeASIN=0142000280&amp;adid=0VNZXPFS9EAVTH6R7JM5&amp;"><img title="David Allens Getting Things Done" src="http://rcm-images.amazon.com/images/I/4104N6ME70L._SL110_.jpg" alt="David Allens Getting Things Done" width="74" height="110" /></a><p class="wp-caption-text">David Allens Getting Things Done</p></div>
<p>In order to better manage my time and my priorities I have been implementing and reviewing <a href="http://www.davidco.com/">David Allen&#8217;s</a> &#8220;Getting Things Done&#8221;, and have been operating my own install of GTD-PHP. I have been using this to manage all aspects of my life, from professional to personal projects. This has allowed me a lot greater control of my personal and professional life and allowed me to manage my time far more effectively than ever before. Currently in this system I am managing 100 Active Projects, 44 Someday/Maybe Projects, and within those I have currently 147 Actions within those. I am still in the process of determining Next actions for some of these projects, but at least having visibility of all these things I need to do has given me greater control of managing the most important of these. Most of the projects without next actions are someday/maybe projects, and the others that are not could be put in someday/maybe until such time as I have time to process their next actions. I definitely encourage anybody to try this method of organisation, time management, prioritisation because it has helped me to lower my stress and be able to switch off from work when I get home. Just note that it does tend to increase the likelihood of adding more projects to your list than you started out doing <img src='http://www.dwarfsoft.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Aside from this I have been attempting to build an Application Audit script at work that will pull the NAL objects from our system through LDAP. I have started coding this type of script now as a class which is in a .vbs file and then for implementing its use I have started using .wsf files to include and execute the required code. This adds to the usability of my existing code and makes my code far more acccessible for reuse in other applications. I had already started writing these types of classes before for my Ini File Handler, but previously I had been including the VBScript files internally using a manual Include function:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Function</span> Include<span style="color: #000000;">&#40;</span>vbsFile<span style="color: #000000;">&#41;</span>
   <span style="color: #FF8000;">Set</span> fso <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
   <span style="color: #0600FF;">If</span> fso.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>vbsFile<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
      <span style="color: #FF8000;">Set</span> f <span style="color: #008000;">=</span> fso.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>vbsFile<span style="color: #000000;">&#41;</span>
      s <span style="color: #008000;">=</span> f.<span style="color: #0000FF;">ReadAll</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
      f.<span style="color: #0600FF;">Close</span>
      ExecuteGlobal s
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></div></div>

<p>The .wsf include method is so much cleaner:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">language</span>=<span style="color: #ff0000;">&quot;VBScript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;Applications.vbs&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>When I have managed to get my projects and actions further under control I will have to provide updates. I have some plans for the XNA in a Day series which I started with breakout, but that is some way off. I am also planning on overhauling some of my previous projects and actually actioning them. </p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2009/07/20/back-behind-the-keyboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preoccupied</title>
		<link>http://www.dwarfsoft.com/blog/2009/04/11/preoccupied/</link>
		<comments>http://www.dwarfsoft.com/blog/2009/04/11/preoccupied/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 13:52:23 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Home]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[Baby]]></category>
		<category><![CDATA[Busy]]></category>
		<category><![CDATA[Job]]></category>
		<category><![CDATA[Time]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/2009/04/11/preoccupied/</guid>
		<description><![CDATA[I have been a little preoccupied of late, and this is due to some of the most hectic things requiring my attention, and therefore interrupting my development attempts. First, I have been travelling a fair bit for my wife, as we are getting many scans and specialist appointments. The pregnancy has not been going as [...]]]></description>
			<content:encoded><![CDATA[<p>I have been a little preoccupied of late, and this is due to some of the most hectic things requiring my attention, and therefore interrupting my development attempts.</p>
<p>First, I have been travelling a fair bit for my wife, as we are getting many scans and specialist appointments. The pregnancy has not been going as well as it could have been, but at least things are looking positive now. Understandably the requirement to have enough &#8220;stuff&#8221; set up for baby, who should be here very soon, has taken much of my time.</p>
<p>Secondly, the job in which I am currently sitting has been advertised for Permanency. This of course requires my time for writing the application. Hopefully the fact that I sit in the position currently will put me in a good position, especially considering in the current economic climate that there might be the newly skilled unemployed seeking to get into my role.</p>
<p><span id="more-250"></span></p>
<p>Those are the two major time sinks that I have at the moment, although there are a few other smaller sinks. Bare with me while I push to get back on track with development <img src='http://www.dwarfsoft.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2009/04/11/preoccupied/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ini File Handler for VBScript</title>
		<link>http://www.dwarfsoft.com/blog/2009/02/27/ini-file-handler-for-vbscript/</link>
		<comments>http://www.dwarfsoft.com/blog/2009/02/27/ini-file-handler-for-vbscript/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 23:16:02 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Chris]]></category>
		<category><![CDATA[Concept]]></category>
		<category><![CDATA[INI]]></category>
		<category><![CDATA[Initiative]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=175</guid>
		<description><![CDATA[I was recently working on an issue to do with managing .ini files in VBScript. I know what you are all going to say now: Why would you use an INI file when the registry is available for use?! Well, there is one instance that you may wish to use another form of configuration or [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently working on an issue to do with managing .ini files in VBScript. I know what you are all going to say now: Why would you use an INI file when the registry is available for use?! Well, there is one instance that you may wish to use another form of configuration or information passing. In this instance we have an initiation of the Ghost Store method for the System Volume. To achieve a store on the system volume we require the PC to be rebooted and it then boots up into a BartPE environment to run the Ghost Store, and perform a few custom tasks. Therefore, the System Volumes Registry is not present (or requires mounting then reading, which has proven somewhat unreliable for me in the past).</p>
<p>So, the reason it came to developing the Ini file handler class is due to the need to provide some more controlled smarts into the store/restore system. Clusters, such as the one I work within, can be more proactive in their maintenance, and therefore require more advanced features than the corporate stock-standard release is likely to contain. As such the area in which I work is constantly involved in working towards a very automated maintenance process. My skills, lying within scripting, programming, and automation in particular, come in handy in this regard. I regularly disassemble the corporate releases to ensure that they will not break when released out into the wild of our corporate machines.</p>
<p><span id="more-175"></span></p>
<p>The store/restore process was one that I had previously tackled and modified due to the limitations of the corporate model. Unfortunately this modification was temporary, as the updated software that was released from corporate changed the model under which the store/restore process was to operate, and caused the modifications we had made locally to break.</p>
<p>The easiest way of reading Ini files in Windows is to use the Word.Application Object (as gathered quickly for demonstration from <a href="http://www.developersdex.com/asp/message.asp?p=1825&#038;ID=%3C3844526a-169c-4bea-8a18-19595e475487%40n1g2000prb.googlegroups.com%3E">here</a>):</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #FF8000;">Set</span> objWord <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Word.application&quot;</span><span style="color: #000000;">&#41;</span>
WinDir <span style="color: #008000;">=</span> objWord.<span style="color: #0000FF;">System</span>.<span style="color: #0000FF;">PrivateProfileString</span><span style="color: #000000;">&#40;</span>FileName , Section , Key<span style="color: #000000;">&#41;</span></pre></div></div>

</p>
<p>This, however, does not work in BartPE. Instead, I have developed a class that can be added into a VBScript and used very easily. It utilizes Dictionaries to keep the settings organised. This means that if it reads two settings in the same section with the same name, the value will reflect the last one (the one closest to the end of the file).</p>
<p>The full source of the IniFile handler are as follows:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Class</span> IniFile
   <span style="color: #FF8000;">Private</span> mIniFile
   <span style="color: #008080; font-style: italic;">'</span>
   <span style="color: #008080; font-style: italic;">'----------------------- Sub Load -------------------------------</span>
   <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> Load<span style="color: #000000;">&#40;</span>Filename<span style="color: #000000;">&#41;</span>
      LoadIni FileName,<span style="color: #0600FF;">False</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
   <span style="color: #008080; font-style: italic;">'-------------------- End of Sub Load ---------------------------</span>
&nbsp;
   <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Sub</span> LoadIni<span style="color: #000000;">&#40;</span>Filename,JustDefaults<span style="color: #000000;">&#41;</span>
     <span style="color: #0600FF;">Dim</span> objFSO, objDictionary, objSubDictionary, <span style="color: #008000;">file</span>, ini, arr, <span style="color: #0600FF;">line</span>, splitline, tmpsplit  
     <span style="color: #FF8000;">Set</span> objFSO <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
     <span style="color: #FF8000;">Set</span> objDictionary <span style="color: #008000;">=</span> mIniFile
     <span style="color: #FF8000;">Set</span> objDictionary <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.Dictionary&quot;</span><span style="color: #000000;">&#41;</span>
     <span style="color: #FF8000;">Set</span> objSubDictionary <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
     <span style="color: #FF8000;">Set</span> mIniFile <span style="color: #008000;">=</span> objDictionary
     <span style="color: #0600FF;">If</span> JustDefaults <span style="color: #FF8000;">Then</span>
        Read <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
     <span style="color: #FF8000;">Else</span>
        Read <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
     <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
     <span style="color: #0600FF;">If</span> objFSO.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>Filename<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
        <span style="color: #FF8000;">Set</span> <span style="color: #008000;">file</span> <span style="color: #008000;">=</span> objFSO.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>Filename<span style="color: #000000;">&#41;</span>
        ini <span style="color: #008000;">=</span> <span style="color: #008000;">file</span>.<span style="color: #0000FF;">ReadAll</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #008000;">file</span>.<span style="color: #0600FF;">Close</span> 
&nbsp;
        arr <span style="color: #008000;">=</span> <span style="color: #0600FF;">Split</span><span style="color: #000000;">&#40;</span>ini,vbCrLf<span style="color: #000000;">&#41;</span>
        <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> <span style="color: #0600FF;">line</span> in arr
           <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">line</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;##STARTDEFAULT&quot;</span> <span style="color: #FF8000;">Then</span>
              Read <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
           <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
           <span style="color: #0600FF;">If</span> Read <span style="color: #FF8000;">Then</span>
              <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Line</span><span style="color: #000000;">&#41;</span>,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;[&quot;</span> <span style="color: #804040;">And</span> <span style="color: #0600FF;">Right</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Line</span><span style="color: #000000;">&#41;</span>,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;]&quot;</span> <span style="color: #FF8000;">Then</span>
                 <span style="color: #0600FF;">line</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">line</span>,<span style="color: #808080;">&quot;[&quot;</span>,<span style="color: #808080;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>,<span style="color: #808080;">&quot;]&quot;</span>,<span style="color: #808080;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
                 <span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> <span style="color: #0600FF;">IsEmpty</span><span style="color: #000000;">&#40;</span>objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">line</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
                    <span style="color: #FF8000;">Set</span> objSubDictionary <span style="color: #008000;">=</span> objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">line</span><span style="color: #000000;">&#41;</span>
                 <span style="color: #FF8000;">Else</span>
&nbsp;
                    <span style="color: #FF8000;">Set</span> objSubDictionary <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.Dictionary&quot;</span><span style="color: #000000;">&#41;</span>
                    <span style="color: #008080; font-style: italic;">'objDictionary.Add line, objSubDictionary</span>
                    <span style="color: #FF8000;">set</span> objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">line</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> objSubDictionary
                 <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
              <span style="color: #FF8000;">Else</span>
                 <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">TypeName</span><span style="color: #000000;">&#40;</span>objSubDictionary<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Nothing&quot;</span> or <span style="color: #0600FF;">IsEmpty</span><span style="color: #000000;">&#40;</span>objSubDictionary<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
                    <span style="color: #FF8000;">Set</span> objSubDictionary <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.Dictionary&quot;</span><span style="color: #000000;">&#41;</span>
                    objDictionary.<span style="color: #0000FF;">Add</span> <span style="color: #808080;">&quot;[]&quot;</span>,objSubDictionary
                    <span style="color: #FF8000;">Set</span> objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;[]&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> objSubDictionary
                 <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
                 <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">line</span><span style="color: #000000;">&#41;</span>,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;#&quot;</span> <span style="color: #FF8000;">Then</span>
                    objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span> <span style="color: #808080;">&quot;[&quot;</span> <span style="color: #008000;">&amp;</span> objSubDictionary.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;]&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">line</span><span style="color: #000000;">&#41;</span>
                 <span style="color: #FF8000;">Else</span>
                    splitline <span style="color: #008000;">=</span> <span style="color: #0600FF;">split</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">line</span><span style="color: #000000;">&#41;</span>,<span style="color: #808080;">&quot;=&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
                    <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">TypeName</span><span style="color: #000000;">&#40;</span>splitline<span style="color: #000000;">&#41;</span> &lt;&gt; <span style="color: #808080;">&quot;Nothing&quot;</span> <span style="color: #FF8000;">Then</span>
                       <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">UBound</span><span style="color: #000000;">&#40;</span>splitline<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span> <span style="color: #FF8000;">Then</span>
                          tmpsplit <span style="color: #008000;">=</span> <span style="color: #0600FF;">split</span><span style="color: #000000;">&#40;</span>splitline<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>, <span style="color: #808080;">&quot;#&quot;</span><span style="color: #000000;">&#41;</span>
                          <span style="color: #008080; font-style: italic;">' Resolve a &lt;value&gt;=&lt;blank&gt; error</span>
                          <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">UBound</span><span style="color: #000000;">&#40;</span>tmpsplit<span style="color: #000000;">&#41;</span> &gt;<span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
                             objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span>splitline<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span>tmpsplit<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> 
                          <span style="color: #FF8000;">Else</span>
                             objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span>splitline<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
                          <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
                       <span style="color: #FF8000;">Else</span>
                         <span style="color: #008080; font-style: italic;">'Error</span>
                       <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
                    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
                 <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
              <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
              <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">line</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;##ENDDEFAULT&quot;</span> <span style="color: #804040;">And</span> JustDefaults <span style="color: #FF8000;">Then</span>
            <span style="color: #0600FF;">MsgBox</span> <span style="color: #808080;">&quot;End Default&quot;</span>
                 Read <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
                 <span style="color: #0600FF;">Exit</span> <span style="color: #0600FF;">Sub</span>
              <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
           <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
        <span style="color: #FF8000;">Next</span>
     <span style="color: #FF8000;">Else</span> 
       <span style="color: #0600FF;">Exit</span> <span style="color: #0600FF;">Sub</span>
     <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
   <span style="color: #008080; font-style: italic;">'------------------- End of Sub LoadIni -------------------------</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">'----------------------- Function GetValue -------------------------------</span>
   <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> GetValue<span style="color: #000000;">&#40;</span>Section, Value<span style="color: #000000;">&#41;</span>
      <span style="color: #FF8000;">Set</span> objDictionary <span style="color: #008000;">=</span> mIniFile
      <span style="color: #0600FF;">If</span> IsSection<span style="color: #000000;">&#40;</span>Section<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
         <span style="color: #FF8000;">Set</span> objSubDictionary <span style="color: #008000;">=</span> objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>Section<span style="color: #000000;">&#41;</span>
         <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">IsEmpty</span><span style="color: #000000;">&#40;</span>objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>Value<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            objSubDictionary.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span>Value<span style="color: #000000;">&#41;</span>
         <span style="color: #FF8000;">Else</span>
            GetValue <span style="color: #008000;">=</span> objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>Value<span style="color: #000000;">&#41;</span>
         <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
      <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
   <span style="color: #008080; font-style: italic;">'-------------------- End of Function GetValue ---------------------------</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">'----------------------- Function IsSection ------------------------------</span>
   <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> IsSection<span style="color: #000000;">&#40;</span>Section<span style="color: #000000;">&#41;</span>
      <span style="color: #FF8000;">Set</span> objDictionary <span style="color: #008000;">=</span> mIniFile
      <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">IsEmpty</span><span style="color: #000000;">&#40;</span>objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>Section<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
         objDictionary.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span>Section<span style="color: #000000;">&#41;</span>
         IsSection <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
      <span style="color: #FF8000;">Else</span>
        IsSection <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
      <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
   <span style="color: #008080; font-style: italic;">'-------------------- End of Function IsSection --------------------------</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">'----------------------- Function IsSection ------------------------------</span>
   <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> Save<span style="color: #000000;">&#40;</span>FileName<span style="color: #000000;">&#41;</span>
      <span style="color: #FF8000;">Set</span> objDictionary <span style="color: #008000;">=</span> mIniFile
      <span style="color: #FF8000;">Set</span> objFSO <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.FileSystemObject&quot;</span><span style="color: #000000;">&#41;</span>
      <span style="color: #FF8000;">Set</span> Outfile <span style="color: #008000;">=</span> objFSO.<span style="color: #0000FF;">CreateTextFile</span><span style="color: #000000;">&#40;</span>FileName<span style="color: #000000;">&#41;</span>
      <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">TypeName</span><span style="color: #000000;">&#40;</span>objDictionary<span style="color: #000000;">&#41;</span> &lt;&gt; <span style="color: #808080;">&quot;Nothing&quot;</span> <span style="color: #FF8000;">Then</span>
         <span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> <span style="color: #0600FF;">IsEmpty</span><span style="color: #000000;">&#40;</span>objDictionary.<span style="color: #0000FF;">Keys</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> Key in objDictionary.<span style="color: #0000FF;">Keys</span>
               <span style="color: #0600FF;">If</span> Key <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;[]&quot;</span> <span style="color: #FF8000;">Then</span>
               <span style="color: #FF8000;">ElseIf</span> Key <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span> <span style="color: #FF8000;">Then</span>
               <span style="color: #FF8000;">Else</span>
                  Outfile.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;[&quot;</span> <span style="color: #008000;">&amp;</span> Key <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;]&quot;</span><span style="color: #000000;">&#41;</span>
               <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
               <span style="color: #FF8000;">Set</span> objSubDictionary <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
               <span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> <span style="color: #0600FF;">IsEmpty</span><span style="color: #000000;">&#40;</span>objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>Key<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
                  <span style="color: #FF8000;">Set</span> objSubDictionary <span style="color: #008000;">=</span> objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>Key<span style="color: #000000;">&#41;</span>
               <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
               <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">TypeName</span><span style="color: #000000;">&#40;</span>objSubDictionary<span style="color: #000000;">&#41;</span> &lt;&gt; <span style="color: #808080;">&quot;Nothing&quot;</span> <span style="color: #FF8000;">Then</span>
                  <span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> <span style="color: #0600FF;">IsEmpty</span><span style="color: #000000;">&#40;</span>objSubDictionary.<span style="color: #0000FF;">Keys</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
                     <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> subKey in objSubDictionary.<span style="color: #0000FF;">Keys</span>
                        <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">Left</span><span style="color: #000000;">&#40;</span>subKey,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;[&quot;</span> <span style="color: #FF8000;">Then</span>
                           OutFile.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span>objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>subKey<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
                        <span style="color: #FF8000;">Else</span>
                           OutFile.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span>subKey <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;=&quot;</span> <span style="color: #008000;">&amp;</span> objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>subKey<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
                        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
                     <span style="color: #FF8000;">Next</span>
                  <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
               <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
               OutFile.<span style="color: #0000FF;">WriteLine</span>
            <span style="color: #FF8000;">Next</span>
         <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
      <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
   <span style="color: #008080; font-style: italic;">'-------------------- End of Function IsSection --------------------------</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">'--------------------- Function AddNextNumeric ---------------------------</span>
   <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> AddNextNumeric<span style="color: #000000;">&#40;</span>Section,Value<span style="color: #000000;">&#41;</span>
      <span style="color: #FF8000;">Set</span> objDictionary <span style="color: #008000;">=</span> mIniFile
      <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">IsEmpty</span><span style="color: #000000;">&#40;</span>objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>Section<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
         <span style="color: #FF8000;">Set</span> objSubDictionary <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Scripting.Dictionary&quot;</span><span style="color: #000000;">&#41;</span>
         <span style="color: #FF8000;">Set</span> objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>Section<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> objSubDictionary
         objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;1&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> Value
         AddNextNumeric <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
      <span style="color: #FF8000;">Else</span>
        <span style="color: #FF8000;">Set</span> objSubDictionary <span style="color: #008000;">=</span> objDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span>Section<span style="color: #000000;">&#41;</span>
        Number <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
        <span style="color: #0600FF;">Do</span> <span style="color: #0600FF;">While</span> <span style="color: #0600FF;">IsEmpty</span><span style="color: #000000;">&#40;</span>objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&quot;</span> <span style="color: #008000;">&amp;</span> Number<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> 
          Number <span style="color: #008000;">=</span> Number <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span>
        <span style="color: #0600FF;">Loop</span>
        objSubDictionary.<span style="color: #0000FF;">Item</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;&quot;</span> <span style="color: #008000;">&amp;</span> Number<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> Value
        AddNextNumeric <span style="color: #008000;">=</span> Number
      <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
   <span style="color: #008080; font-style: italic;">'------------------ End of Function AddNextNumeric -----------------------</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">'--------------------------- CONSTRUCTOR ---------------------------------</span>
   <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> Class_Initialize
      <span style="color: #008080; font-style: italic;">' Calss Constructor</span>
      <span style="color: #008080; font-style: italic;">' Initialization goes here</span>
      <span style="color: #FF8000;">Set</span> mIniFile <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
<span style="color: #008080; font-style: italic;">' MsgBox TypeName(mIniFile)</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
   <span style="color: #008080; font-style: italic;">'------------------------- END CONSTRUCTOR -------------------------------</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">'---------------------------- DESTRUCTOR ---------------------------------</span>
   <span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Sub</span> Class_Terminate
      <span style="color: #008080; font-style: italic;">' Calss Destructor</span>
      <span style="color: #008080; font-style: italic;">' Cleanup goes here</span>
<span style="color: #008080; font-style: italic;">' MsgBox TypeName(mIniFile)</span>
      <span style="color: #FF8000;">Set</span> mIniFile <span style="color: #008000;">=</span> <span style="color: #FF8000;">Nothing</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
   <span style="color: #008080; font-style: italic;">'-------------------------- END DESTRUCTOR -------------------------------</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></pre></div></div>

</p>
<p>Usage of the class for reading Ini files is as follows:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #FF8000;">set</span> ifile <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> IniFile
ifile.<span style="color: #0000FF;">Load</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;filename.ini&quot;</span><span style="color: #000000;">&#41;</span>
Variable <span style="color: #008000;">=</span> ifile.<span style="color: #0000FF;">GetValue</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Section&quot;</span>,<span style="color: #808080;">&quot;Variable&quot;</span><span style="color: #000000;">&#41;</span></pre></div></div>

</p>
<p>There are obviously functions in the class that allow for writing out the Ini File and modifying the values. Feel free to play with the code, but please remember to link back to here. I do love my popularity, so any of you who want to link here, please do so.</p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2009/02/27/ini-file-handler-for-vbscript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Becoming a Published Author</title>
		<link>http://www.dwarfsoft.com/blog/2009/02/25/becoming-a-published-author/</link>
		<comments>http://www.dwarfsoft.com/blog/2009/02/25/becoming-a-published-author/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 05:49:13 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Book Reviews]]></category>
		<category><![CDATA[Novell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=128</guid>
		<description><![CDATA[Well, as some of you may know, I was involved in writing a series of articles that started back in 2001 and continued until 2004 on some simple programming concepts using C++. An Introduction to Pointers, Structures and Linked Lists has now made a home for itself inside the new GameDev.Net book; Beginning Game Programming: [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_134" class="wp-caption alignleft" style="width: 99px"><a href="https://www.amazon.com/dp/159863805X?tag=dwgp-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=159863805X&amp;adid=0AFKAWV5QRH9QPX6MWFF&amp;"><img class="size-full wp-image-134" title="Beginning Game Programming: A GameDev.Net Collection" src="http://www.dwarfsoft.com/blog/wp-content/uploads/2009/02/beginninggameprogramming.jpg" alt="Beginning Game Programming: A GameDev.Net Collection" width="89" height="110" align="aligncenter" /></a><p class="wp-caption-text">Beginning Game Programming: A GameDev.Net Collection</p></div>
<p>Well, as some of you may know, I was involved in writing a series of articles that started back in 2001 and continued until 2004 on some simple programming concepts using C++. An Introduction to Pointers, Structures and Linked Lists has now made a home for itself inside the new <a title="GameDev.Net - For all your Game Development Needs" href="http://www.gamedev.net/" target="_blank">GameDev.Net</a> book; <a title="Buy &quot;Beginning Game Programming: A GameDev.Net Collection&quot; from Amazon" href="https://www.amazon.com/dp/159863805X?tag=dwgp-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=159863805X&amp;adid=0AFKAWV5QRH9QPX6MWFF&amp;" target="_blank">Beginning Game Programming: A GameDev.Net Collection</a>. This book is a collection of edited articles that have been posted to <a title="GameDev.Net - For all your Game Development Needs" href="http://www.gamedev.net/" target="_blank">GameDev.Net</a> over a period of years.</p>
<p><span id="more-128"></span></p>
<p>This has brought me some inspiration to actually progressing towards some other Authoring ideas. Whether I can get the time to actually develop some of them is questionable, but considering I have a lot of experience working with scripting inside both Active Directory/Exchange shops, to Novell/Groupwise shops, some of the ideas and tools I have had to develop within these environments could lead to some interesting uses. There are many scripting sites out there but I find that to get information on this type of scripting in one location is nigh on impossible. So, there is one idea.</p>
<p>Another idea would be headed back towards the Game Development realms. Again, there are many books and sites that contain a lot of information on how to go about entering into these kinds of pursuits. My main problem with the information is tying it all together, as well as considering the planning implications from starting a Game Development project, until you have completed it. For those who know me well I am an avid procrastinator when it comes to my Game Development pursuits, so this is the least likely idea to succeed. It is, however, an idea I would like to start pursuing.</p>
<p>On a side note, there are a few unpublished articles from the &#8220;Introduction to&#8230;&#8221; series that start to get into some more Advanced ground. I will attempt, first, to complete these so that I can get my head clear of what I need to do to move forward.</p>
<p>I should also say: please buy the book. The proceeds of which, however, do not go to me. So feel free to follow <a title="Buy &quot;Beginning Game Programming: A GameDev.Net Collection&quot; from Amazon" href="https://www.amazon.com/dp/159863805X?tag=dwgp-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=159863805X&amp;adid=0AFKAWV5QRH9QPX6MWFF&amp;" target="_blank">this link </a>to purchase the book through my Amazon Affiliates account. That way I can get a bit more scratch to start working on some of these other projects.</p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2009/02/25/becoming-a-published-author/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

