<?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; Uncategorized</title>
	<atom:link href="http://www.dwarfsoft.com/blog/category/uncategorized/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>Back in the gtd-php saddle</title>
		<link>http://www.dwarfsoft.com/blog/2011/09/06/back-in-the-gtd-php-saddle/</link>
		<comments>http://www.dwarfsoft.com/blog/2011/09/06/back-in-the-gtd-php-saddle/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 11:18:59 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Addon]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[GTD]]></category>
		<category><![CDATA[gtdphp]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=328</guid>
		<description><![CDATA[I&#8217;ve started having a look back at some of my gtd-php project ideas and made some progress since the last time I looked at them. Turns out that one of the bugs I was experiencing was a result of a funny session issue (by running a dev and prod instance from the same browser). I&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started having a look back at some of my gtd-php project ideas and made some progress since the last time I looked at them. Turns out that one of the bugs I was experiencing was a result of a funny session issue (by running a dev and prod instance from the same browser). </p>
<p>I&#8217;ll need to look into it further but it does appear that at least some of my ideas can be implemented as part of the standard addon scheme. </p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2011/09/06/back-in-the-gtd-php-saddle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript INI File Handler</title>
		<link>http://www.dwarfsoft.com/blog/2010/11/23/vbscript-ini-file-handler/</link>
		<comments>http://www.dwarfsoft.com/blog/2010/11/23/vbscript-ini-file-handler/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 23:30:22 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[INI]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=325</guid>
		<description><![CDATA[As you may know, I posted a while ago about how to handle INI files using VBScript if you can&#8217;t use the Word.Application object System.PrivateProfileString function. Over at CodeProject there has been a more recent submission which includes a VB.Net, C# and VBScript solution that is a little more elegant than mine. It uses Regular [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know, I posted a while ago about how to <a href="http://www.dwarfsoft.com/blog/2009/02/27/ini-file-handler-for-vbscript/" target="_blank">handle INI files using VBScript</a> if you can&#8217;t use the Word.Application object System.PrivateProfileString function.</p>
<p>Over at CodeProject there has been a more recent submission which includes a <a href="http://www.codeproject.com/KB/files/VB_NET_INIFile_Object.aspx" target="_blank">VB.Net, C# and VBScript solution</a> that is a little more elegant than mine. It uses Regular Expressions to parse the INI File (which I would use now if I had been building it now), but still utilises the Scripting.Dictionary object for organising sections, keys and values.</p>
<p>Enjoy,</p>
<p><span id="more-325"></span></p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2010/11/23/vbscript-ini-file-handler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSI Package Code Fun</title>
		<link>http://www.dwarfsoft.com/blog/2010/06/22/msi-package-code-fun/</link>
		<comments>http://www.dwarfsoft.com/blog/2010/06/22/msi-package-code-fun/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 07:18:08 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=321</guid>
		<description><![CDATA[I have recently been building quite a few MSI packages, and as of the end of last week I was required to go back through and rebuild a whole batch of them. Due to the way a lot of deployments work from Novell Zenworks, Product Codes are used quite frequently to stop the MSI from [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been building quite a few MSI packages, and as of the end of last week I was required to go back through and rebuild a whole batch of them. Due to the way a lot of deployments work from Novell Zenworks, Product Codes are used quite frequently to stop the MSI from installing more than once (thereby disabling multiple installs). I believe that this is due to the MSI Template that is used corporately having a few Dialogs missing for Repair/Modify. Therefore when the second install occurs the MSI dies a painful death and the user is presented with a number of errors.</p>
<p>So, rather than fix the source of the problem I work within the structure I am given. After my forays in the past couple of days I found it immensely frustrating trying to get the Product Code key to update our documentation for each MSI which had been rebuilt. This is because, up until now, I had been installing the MSI and searching for the MSI name under HKEY_CLASSES_ROOT\Installer\Product\. The code displayed under this key had confused me for quite some time until I found some information regarding a &#8220;<a href="http://www.tech-archive.net/Archive/Scripting/microsoft.public.scripting.vbscript/2005-10/msg00433.html">Packed GUID</a>&#8220;.</p>
<p><span id="more-321"></span></p>
<p>As it turns out, the code I linked to doesn&#8217;t work. It did, however, lead me to figure out HOW to make it work by making me assess each of the &#8220;chunks&#8221; in the original GUID.</p>
<p>Effectively there are 5 parts to Each GUID<br />
{11111111-2222-3333-4444-555555555555}</p>
<p>The &#8220;Packed GUID&#8221; is a regrouping of these numbers, removing the dashes and braces. So, for the first group (11111111) the order in the original GUID appears as ABCDEFGH. The order in the Packed GUID is HGFEDCBA. The Second group (2222) is appended in reverse again (from ABCD to DCBA). The third group is also appended in reverse (from ABCD to DCBA).</p>
<p>The last two groups are a little more complex. Each pair is switched such that for group four (4444) the original GUID appears as ABCD but the packed guid appears as BADC. The last group (555555555555) follows this order as well so for the order ABCDEFGHIJKL the packed GUID will be appended reordered as BADCFEHGJILK.</p>
<p>In VBScript Terms this can be expressed as the following:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Function</span> PackGUID(guid)  
   PackGUID = <span style="color: #800000;">&quot;&quot;</span>  
   <span style="color: #008000;">'*  
</span>   <span style="color: #151B8D; font-weight: bold;">Dim</span> temp  
   temp = Mid(guid,2,Len(guid)-2)  
   <span style="color: #151B8D; font-weight: bold;">Dim</span> part  
   part = Split(temp,<span style="color: #800000;">&quot;-&quot;</span>)  
   <span style="color: #151B8D; font-weight: bold;">Dim</span> pack  
   pack = <span style="color: #800000;">&quot;&quot;</span>  
   <span style="color: #151B8D; font-weight: bold;">Dim</span> i, j  
   <span style="color: #8D38C9; font-weight: bold;">For</span> i = <span style="color: #151B8D; font-weight: bold;">LBound</span>(part) <span style="color: #8D38C9; font-weight: bold;">To</span> <span style="color: #151B8D; font-weight: bold;">UBound</span>(part)
      <span style="color: #8D38C9; font-weight: bold;">Select</span> <span style="color: #8D38C9; font-weight: bold;">Case</span> i
     <span style="color: #8D38C9; font-weight: bold;">Case</span> <span style="color: #151B8D; font-weight: bold;">LBound</span>(part), <span style="color: #151B8D; font-weight: bold;">LBound</span>(part)+1, <span style="color: #151B8D; font-weight: bold;">LBound</span>(part)+2
         <span style="color: #8D38C9; font-weight: bold;">For</span> j = Len(part(i)) <span style="color: #8D38C9; font-weight: bold;">To</span> 1 <span style="color: #8D38C9; font-weight: bold;">Step</span> -1  
            pack = pack &amp; Mid(part(i),j,1)  
         <span style="color: #8D38C9; font-weight: bold;">Next</span>  
     <span style="color: #8D38C9; font-weight: bold;">Case</span> <span style="color: #8D38C9; font-weight: bold;">Else</span>
        <span style="color: #8D38C9; font-weight: bold;">For</span> j = 1 <span style="color: #8D38C9; font-weight: bold;">To</span> Len(part(i)) <span style="color: #8D38C9; font-weight: bold;">Step</span> 2  
            pack = pack &amp; Mid(part(i),j+1,1) &amp; Mid(part(i),j,1)  
         <span style="color: #8D38C9; font-weight: bold;">Next</span>  
     <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">Select</span>
   <span style="color: #8D38C9; font-weight: bold;">Next</span>  
   <span style="color: #008000;">'*  
</span>   PackGUID = pack  
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>So, this was the first step for the time saving measure of extracting the right code. The next issue was how to get the codes in the first place. I knew that there had to be an easier way than opening up InstallShield and Copying out the Codes manually. The first thing that came to mind was the Summary Information Stream of an MSI file (as you can see by right-clicking on an MSI and going to Properties, then Summary). There was a lot of information about this, particularly <a href="http://msdn.microsoft.com/en-us/library/aa369794%28VS.85%29.aspx">from MSDN</a>. This lead me to getting the Package Code:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">   <span style="color: #008000;">'create installer object
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> objDictionary = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;Scripting.Dictionary&quot;</span>)
   <span style="color: #151B8D; font-weight: bold;">Set</span> oInstaller = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;WindowsInstaller.Installer&quot;</span>)
   <span style="color: #008000;">'open msi in read-only mode
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> oDatabase = oInstaller.OpenDatabase(MSIPath, 0)
   <span style="color: #008000;">' Get Package Code from Summary Information Stream   
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> streamobj = oDatabase.SummaryInformation(0) <span style="color: #008000;">'0 = read only
</span>   objDictionary(<span style="color: #800000;">&quot;PackageCode&quot;</span>) = streamobj.<span style="color: #151B8D; font-weight: bold;">Property</span>(9)</pre></div></div>

<p>This is useful, but the Code that HKCR\Installer\Product\{Packed GUID} references comes from the MSI Product Code. So I went back to the drawing board and researched VBScript Installer Database Product Code some more and found <a href="http://www.eggheadcafe.com/forumarchives/platformsdkmsi/Jan2006/post25948124.asp">this</a>, followed by <a href="http://www.symantec.com/connect/downloads/msi-report-generator">this gem</a>. From here it was very easy to pull out GUID&#8217;s from the MSI packages, and I didn&#8217;t even need to do it on a machine with InstallShield actually Installed. The Windows Installer takes care of everything.</p>
<p>Complete code (from start to finish):</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'Created by:   Chris Bennett
</span><span style="color: #008000;">'Created Date: 22/06/2010
</span><span style="color: #008000;">'Description:
</span><span style="color: #008000;">'   Opens up MSI file(s) Passed as Arguments and returns ProductName, ProductCode,
</span><span style="color: #008000;">'   The HKCR key created from ProductCode (a Packed GUID of ProductCode), the PackageCode
</span><span style="color: #008000;">'   and the UpgradeCode of the MSI. Much quicker than getting these out of the MSI's the
</span><span style="color: #008000;">'   Manual Way.
</span>
<span style="color: #008000;">'References:
</span><span style="color: #008000;">'  http://msdn.microsoft.com/en-us/library/aa369794%28VS.85%29.aspx
</span><span style="color: #008000;">'  http://www.eggheadcafe.com/forumarchives/platformsdkmsi/Jan2006/post25948124.asp
</span>
<span style="color: #8D38C9; font-weight: bold;">For</span> <span style="color: #8D38C9; font-weight: bold;">Each</span> MSIPath <span style="color: #8D38C9; font-weight: bold;">in</span> WScript.Arguments
  <span style="color: #151B8D; font-weight: bold;">Set</span> MSIDetails = EvaluateMSI(MSIPath)
  WScript.Echo MSIPath &amp; <span style="color: #800000;">&quot;: &quot;</span>
  WScript.Echo <span style="color: #800000;">&quot;   Product Name: &quot;</span> &amp; MSIDetails(<span style="color: #800000;">&quot;ProductName&quot;</span>)
  WScript.Echo <span style="color: #800000;">&quot;   Product Code: &quot;</span> &amp; MSIDetails(<span style="color: #800000;">&quot;ProductCode&quot;</span>)
  WScript.Echo <span style="color: #800000;">&quot;   Product Key : &quot;</span> &amp; <span style="color: #800000;">&quot;HKCR\Installer\Products\&quot;</span> &amp; PackGUID(MSIDetails(<span style="color: #800000;">&quot;ProductCode&quot;</span>))
  WScript.Echo <span style="color: #800000;">&quot;   Package Code: &quot;</span> &amp; MSIDetails(<span style="color: #800000;">&quot;PackageCode&quot;</span>)
  WScript.Echo <span style="color: #800000;">&quot;   Upgrade Code: &quot;</span> &amp; MSIDetails(<span style="color: #800000;">&quot;UpgradeCode&quot;</span>)
  WScript.Echo <span style="color: #800000;">&quot;&quot;</span>
<span style="color: #8D38C9; font-weight: bold;">Next</span>
&nbsp;
<span style="color: #E56717; font-weight: bold;">Function</span> EvaluateMSI(MSIPath)
   <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: #008000;">'create installer object
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> oInstaller = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;WindowsInstaller.Installer&quot;</span>)
   <span style="color: #008000;">'open msi in read-only mode
</span>   <span style="color: #008000;">'Set oDatabase = oInstaller.OpenDatabase(&quot;d:\USERDATA\BennettCm\Desktop\EN-UNHIDE-OUTLOOK-1-01.msi&quot;, 0)
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> oDatabase = oInstaller.OpenDatabase(MSIPath, 0)
   <span style="color: #151B8D; font-weight: bold;">Set</span> objDictionary = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;Scripting.Dictionary&quot;</span>)
&nbsp;
   <span style="color: #008000;">' Get Package Code from Summary Information Stream   
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> streamobj = oDatabase.SummaryInformation(0) <span style="color: #008000;">'0 = read only
</span>   objDictionary(<span style="color: #800000;">&quot;PackageCode&quot;</span>) = streamobj.<span style="color: #151B8D; font-weight: bold;">Property</span>(9)
&nbsp;
   <span style="color: #008000;">' Get Product Name from MSI Database
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> View = oDatabase.OpenView(<span style="color: #800000;">&quot;Select `Value` From Property WHERE `Property`='ProductName'&quot;</span>)
   View.Execute
   <span style="color: #151B8D; font-weight: bold;">Set</span> ProductName = View.Fetch
   objDictionary(<span style="color: #800000;">&quot;ProductName&quot;</span>) = ProductName.StringData(1)
&nbsp;
   <span style="color: #008000;">' Get Product Code from MSI Database
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> View = oDatabase.OpenView(<span style="color: #800000;">&quot;Select `Value` From Property WHERE `Property`='ProductCode'&quot;</span>)
   View.Execute
   <span style="color: #151B8D; font-weight: bold;">Set</span> ProductCode = View.Fetch
   objDictionary(<span style="color: #800000;">&quot;ProductCode&quot;</span>) = ProductCode.StringData(1)
&nbsp;
   <span style="color: #008000;">' Get Upgrade Code from MSI Database
</span>   <span style="color: #151B8D; font-weight: bold;">Set</span> View = DB.OpenView(<span style="color: #800000;">&quot;Select `Value` From Property WHERE `Property`='UpgradeCode'&quot;</span>)
   View.Execute
   <span style="color: #151B8D; font-weight: bold;">Set</span> UpgradeCode = View.Fetch
   objDictionary(<span style="color: #800000;">&quot;UpgradeCode&quot;</span>) = UpgradeCode.StringData(1)
&nbsp;
   <span style="color: #151B8D; font-weight: bold;">Set</span> EvaluateMSI = objDictionary
   <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>
&nbsp;
<span style="color: #E56717; font-weight: bold;">Function</span> PackGUID(guid)  
   PackGUID = <span style="color: #800000;">&quot;&quot;</span>  
   <span style="color: #008000;">'*  
</span>   <span style="color: #151B8D; font-weight: bold;">Dim</span> temp  
   temp = Mid(guid,2,Len(guid)-2)  
   <span style="color: #151B8D; font-weight: bold;">Dim</span> part  
   part = Split(temp,<span style="color: #800000;">&quot;-&quot;</span>)  
   <span style="color: #151B8D; font-weight: bold;">Dim</span> pack  
   pack = <span style="color: #800000;">&quot;&quot;</span>  
   <span style="color: #151B8D; font-weight: bold;">Dim</span> i, j  
   <span style="color: #8D38C9; font-weight: bold;">For</span> i = <span style="color: #151B8D; font-weight: bold;">LBound</span>(part) <span style="color: #8D38C9; font-weight: bold;">To</span> <span style="color: #151B8D; font-weight: bold;">UBound</span>(part)
      <span style="color: #8D38C9; font-weight: bold;">Select</span> <span style="color: #8D38C9; font-weight: bold;">Case</span> i
     <span style="color: #8D38C9; font-weight: bold;">Case</span> <span style="color: #151B8D; font-weight: bold;">LBound</span>(part), <span style="color: #151B8D; font-weight: bold;">LBound</span>(part)+1, <span style="color: #151B8D; font-weight: bold;">LBound</span>(part)+2
         <span style="color: #8D38C9; font-weight: bold;">For</span> j = Len(part(i)) <span style="color: #8D38C9; font-weight: bold;">To</span> 1 <span style="color: #8D38C9; font-weight: bold;">Step</span> -1  
            pack = pack &amp; Mid(part(i),j,1)  
         <span style="color: #8D38C9; font-weight: bold;">Next</span>  
     <span style="color: #8D38C9; font-weight: bold;">Case</span> <span style="color: #8D38C9; font-weight: bold;">Else</span>
        <span style="color: #8D38C9; font-weight: bold;">For</span> j = 1 <span style="color: #8D38C9; font-weight: bold;">To</span> Len(part(i)) <span style="color: #8D38C9; font-weight: bold;">Step</span> 2  
            pack = pack &amp; Mid(part(i),j+1,1) &amp; Mid(part(i),j,1)  
         <span style="color: #8D38C9; font-weight: bold;">Next</span>  
     <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">Select</span>
   <span style="color: #8D38C9; font-weight: bold;">Next</span>  
   <span style="color: #008000;">'*  
</span>   PackGUID = pack  
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<p>Run from cscript it outputs like:</p>
<pre>P:\Folder\To\MSI\MSI Name.msi:
   Product Name: MSI Name
   Product Code: {A2961B30-4875-4535-AE36-DA064263BA50}
   Product Key : HKCR\Installer\Products\03B1692A57845354EA63AD602436AB05
   Package Code: {5F735447-A72D-4571-8C8D-AD80E2B30F22}
   Upgrade Code: {A2961B30-4875-4535-AE36-DA064263BA50}</pre>
<p>I created a Batch File that also makes use of this script to trawl through folders pulling out the information and dumping it into a Codes.txt file.</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>
REM Created <span style="color: #800080;">By</span><span style="color: #FF1010; font-weight: bold;">:   Chris Bennett</span>
REM Created Date<span style="color: #FF1010; font-weight: bold;">: 22/06/2010</span>
REM Description<span style="color: #FF1010; font-weight: bold;">:</span>
REM    Finds MSI<span style="color: #ff0000;">''</span>s under the current Directory <span style="color: #66cc66;">&#40;</span>or passed Directory<span style="color: #66cc66;">&#41;</span>
REM    Calls GetMSICodes.vbs <span style="color: #800080;">to</span> extract the MSI Package,Product and Upgrade Codes
REM    Saves these codes into Codes.txt
&nbsp;
CD <span style="color: #66cc66;">/</span>D <span style="color: #66cc66;">%~</span>dp0
<span style="color: #800080;">IF</span> <span style="color: #66cc66;">/</span>I <span style="color: #ff0000;">&quot;%~1&quot;</span> NEQ <span style="color: #ff0000;">&quot;&quot;</span> CD <span style="color: #66cc66;">/</span>D <span style="color: #66cc66;">%</span>1
<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>A <span style="color: #800080;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'DIR *.MSI /B /S'</span><span style="color: #66cc66;">&#41;</span> DO <span style="color: #66cc66;">&#40;</span>
  cscript.exe GetMSICodes.vbs <span style="color: #ff0000;">&quot;%%A&quot;</span> <span style="color: #66cc66;">//</span>Nologo <span style="color: #66cc66;">&gt;&gt;</span> Codes.txt
  <span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Hope you enjoyed, I certainly did <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/06/22/msi-package-code-fun/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Updated GTD-PHP POP3 Inbox Import</title>
		<link>http://www.dwarfsoft.com/blog/2009/08/04/updated-gtd-php-pop3-inbox-import/</link>
		<comments>http://www.dwarfsoft.com/blog/2009/08/04/updated-gtd-php-pop3-inbox-import/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 01:39:09 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Addon]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Groupwise]]></category>
		<category><![CDATA[GTD]]></category>
		<category><![CDATA[Home]]></category>
		<category><![CDATA[Import]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[POP3]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/2009/08/04/updated-gtd-php-pop3-inbox-import/</guid>
		<description><![CDATA[So I have been using the new script this morning, and testing adding new actions from the GroupWise account at work. Here is where I encountered some issues. GroupWise decides it wants to MIME Encode the email, which brings about my first problem. I need to account for multiple MIME Parts. After resolving this my [...]]]></description>
			<content:encoded><![CDATA[<p>So I have been using the new script this morning, and testing adding new actions from the GroupWise account at work. Here is where I encountered some issues.</p>
<p>GroupWise decides it wants to MIME Encode the email, which brings about my first problem. I need to account for multiple MIME Parts. After resolving this my next issue is that the corporate email gateway decides to append a massive disclaimer at the bottom of the email, bloating my item by at least 1000%. So I implemented the ability to cut out disclaimers based on a stripos call. I can have a list of different filters here and it will cut them all out.</p>
<p>After fixing this up and resolving the functional issues I <a href="https://www.hosted-projects.com/trac/toae/gtdphp/ticket/569">logged this addon as a ticket</A> in the <a href="https://www.hosted-projects.com/trac/toae/gtdphp/">GTD-PHP Trac</a> system.</p>
<p><span id="more-279"></span></p>
<p>I have a few further updates to make, including having bulk uploads, custom tags and mail filters.</p>
<p>Cheers, Chris</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2009/08/04/updated-gtd-php-pop3-inbox-import/feed/</wfw:commentRss>
		<slash:comments>0</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 from Training</title>
		<link>http://www.dwarfsoft.com/blog/2007/05/09/back-from-training/</link>
		<comments>http://www.dwarfsoft.com/blog/2007/05/09/back-from-training/#comments</comments>
		<pubDate>Wed, 09 May 2007 13:04:50 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=11</guid>
		<description><![CDATA[I have returned tonight from training in Brisbane, and the course was actually fairly interesting to go through. Fortunately the GroupWise 7 Interface allows much the same access to GroupWise 6.5, but has some of the nicer Tab features of OWA and the like. The Interface actually feels a lot more responsive than older versions, [...]]]></description>
			<content:encoded><![CDATA[<p>I have returned tonight from training in Brisbane, and the course was actually fairly interesting to go through. Fortunately the GroupWise 7 Interface allows much the same access to GroupWise 6.5, but has some of the nicer Tab features of OWA and the like. The Interface actually feels a lot more responsive than older versions, and the new features make it a lot more useful.</p>
<p>Of course, not all of the features we learned about can be applied directly to our work, and some of them can be used in outright malicious ways. I will look into some potential pranks that can be played with people around the office. I need to get some sleep now before work tomorrow so I&#8217;ll pack it in now.</p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2007/05/09/back-from-training/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome back to GPA</title>
		<link>http://www.dwarfsoft.com/blog/2007/04/30/welcome-back-to-gpa/</link>
		<comments>http://www.dwarfsoft.com/blog/2007/04/30/welcome-back-to-gpa/#comments</comments>
		<pubDate>Tue, 01 May 2007 04:53:27 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=3</guid>
		<description><![CDATA[Hello, and welcome to dwarfsoft [GPA] (Game Programming Alchemy). I have finally decided to make this site more managable in that I should be able to add ideas from work without too much hassle, which I cannot do with the old Static HTML site. It is about time that this site started being used for [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, and welcome to dwarfsoft [GPA] (Game Programming Alchemy). I have finally decided to make this site more managable in that I should be able to add ideas from work without too much hassle, which I cannot do with the old Static HTML site.</p>
<p>It is about time that this site started being used for more than just a dumping ground for my funny images and much more than just a subversion backup repository for whatever project I happen to be working on. I hope to start using this to organise my thoughts on a couple of fronts, such as Avengeance, Empyrean Gate, and NGDN.</p>
<p>In the meantime I have to get used to how WordPress works in order to get the site set up the way I like it. This learning experience will in the very least give me some idea of web technology integration which will benefit NGDN when I get around to it.</p>
<p><span id="more-3"></span></p>
<p>Cheers, Chris.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2007/04/30/welcome-back-to-gpa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

