<?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; AutoStore</title>
	<atom:link href="http://www.dwarfsoft.com/blog/tag/autostore/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>Return to GetVolumeNumber</title>
		<link>http://www.dwarfsoft.com/blog/2008/09/02/return-to-getvolumenumber/</link>
		<comments>http://www.dwarfsoft.com/blog/2008/09/02/return-to-getvolumenumber/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 13:30:47 +0000</pubDate>
		<dc:creator>dwarfsoft</dc:creator>
				<category><![CDATA[Novell]]></category>
		<category><![CDATA[Politics]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Auto Store]]></category>
		<category><![CDATA[AutoStore]]></category>
		<category><![CDATA[Mount]]></category>
		<category><![CDATA[Mount Points]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Volume]]></category>

		<guid isPermaLink="false">http://www.dwarfsoft.com/blog/?p=62</guid>
		<description><![CDATA[Since my last post I came to the realisation that I really didn&#8217;t like the way that the Diskpart box popped up on screen during the function call, so I did what I said I should have done and created the function the other way. This also cleans up the text files after completion, which [...]]]></description>
			<content:encoded><![CDATA[<p>Since my last post I came to the realisation that I really didn&#8217;t like the way that the Diskpart box popped up on screen during the function call, so I did what I said I should have done and created the function the other way. This also cleans up the text files after completion, which is something the previous function didn&#8217;t do.</p>
<p>For completeness I also made the function a little more generic, so it takes the Volume Label as the Variable, and falls back to &#8220;IMAGE&#8221; if none was passed.</p>
<p><span id="more-62"></span></p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Function</span> GetVolumeNumberHidden<span style="color: #000000;">&#40;</span>Label<span style="color: #000000;">&#41;</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;">ForWriting</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>
   <span style="color: #0600FF;">Const</span> <span style="color: #0600FF;">ForReading</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>
&nbsp;
   <span style="color: #0600FF;">If</span> Label<span style="color: #008000;">=</span><span style="color: #808080;">&quot;&quot;</span> <span style="color: #FF8000;">Then</span>
      Label<span style="color: #008000;">=</span><span style="color: #808080;">&quot;IMAGE&quot;</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
   <span style="color: #FF8000;">Set</span> oShell <span style="color: #008000;">=</span> <span style="color: #0600FF;">CreateObject</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;WScript.Shell&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
   <span style="color: #FF8000;">Set</span> oFSO <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>
   TempFile <span style="color: #008000;">=</span> oShell.<span style="color: #0000FF;">ExpandEnvironmentStrings</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;C:\Temp\dp.txt&quot;</span><span style="color: #000000;">&#41;</span>
   ListFile <span style="color: #008000;">=</span> oShell.<span style="color: #0000FF;">ExpandEnvironmentStrings</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;C:\Temp\dl.txt&quot;</span><span style="color: #000000;">&#41;</span>
   <span style="color: #FF8000;">Set</span> oFile <span style="color: #008000;">=</span> oFSO.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>TempFile,<span style="color: #0600FF;">ForWriting</span>,<span style="color: #0600FF;">True</span><span style="color: #000000;">&#41;</span>
&nbsp;
   oFile.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;LIST VOLUME&quot;</span><span style="color: #000000;">&#41;</span>
   oFile.<span style="color: #0600FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
   oShell.<span style="color: #0000FF;">Run</span> <span style="color: #808080;">&quot;%comspec% /c diskpart /s &quot;</span> <span style="color: #008000;">&amp;</span>amp; TempFile <span style="color: #008000;">&amp;</span>amp; _
      <span style="color: #808080;">&quot; &amp;gt; &quot;</span> <span style="color: #008000;">&amp;</span>amp; ListFile, <span style="color: #FF0000;">0</span>, <span style="color: #0600FF;">True</span>
&nbsp;
   Ouptut <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
   <span style="color: #0600FF;">Str</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
&nbsp;
   <span style="color: #FF8000;">Set</span> oFile <span style="color: #008000;">=</span> oFSO.<span style="color: #0000FF;">OpenTextFile</span><span style="color: #000000;">&#40;</span>ListFile,<span style="color: #0600FF;">ForReading</span><span style="color: #000000;">&#41;</span>
&nbsp;
   <span style="color: #0600FF;">Do</span> until oFile.<span style="color: #0000FF;">AtEndOfStream</span>
      <span style="color: #0600FF;">Str</span> <span style="color: #008000;">=</span> oFile.<span style="color: #0000FF;">ReadLine</span>
      <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">InStr</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Str</span>,<span style="color: #808080;">&quot;Volume&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span>gt; <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
         <span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> <span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Str</span>,<span style="color: #FF0000;">10</span>,<span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;###&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            DriveLetter <span style="color: #008000;">=</span> <span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Str</span>,<span style="color: #FF0000;">16</span>,<span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
            VolumeNumber <span style="color: #008000;">=</span> <span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Str</span>,<span style="color: #FF0000;">10</span>,<span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #0600FF;">If</span> <span style="color: #0600FF;">StrComp</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #FF8000;">Mid</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Str</span>,<span style="color: #FF0000;">20</span>,<span style="color: #FF0000;">12</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>,<span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span>Label<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">=</span><span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
               GetVolumeNumberHidden <span style="color: #008000;">=</span> VolumeNumber
&nbsp;
               oFile.<span style="color: #0600FF;">Close</span>
               <span style="color: #0600FF;">If</span> oFSO.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>TempFile<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
                  oFSO.<span style="color: #0000FF;">DeleteFile</span> TempFile, <span style="color: #0600FF;">True</span>
               <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
               <span style="color: #0600FF;">If</span> oFSO.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>ListFile<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
                  oFSO.<span style="color: #0000FF;">DeleteFile</span> ListFile, <span style="color: #0600FF;">True</span>
               <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
               <span style="color: #0600FF;">Exit</span> <span style="color: #0600FF;">Function</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;">Loop</span>
&nbsp;
   oFile.<span style="color: #0600FF;">Close</span>
   <span style="color: #0600FF;">If</span> oFSO.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>TempFile<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
      oFSO.<span style="color: #0000FF;">DeleteFile</span> TempFile, <span style="color: #0600FF;">True</span>
   <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
   <span style="color: #0600FF;">If</span> oFSO.<span style="color: #0000FF;">FileExists</span><span style="color: #000000;">&#40;</span>ListFile<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
      oFSO.<span style="color: #0000FF;">DeleteFile</span> ListFile, <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></pre></div></div>

</p>
<p>This function now makes its way into the Completed stage and now I move on to other things. I have been working very frantically on my AutoStore script. This function is used in both the Store/Restore installation, and the AutoStore script itself, in order to get the timestamp of the previously stored image files. Some of the other fun things I have been playing with involve Novell Workstation Policy Packages, and Package Schedules. In order to initiate the AutoStore process I have created an array of Package Schedules that calls my AutoImage.vbe file. I noticed that during the process of Installation, the MSI had not completed before the AutoImage.vbe file was attempted to be run. This lead to a WScript error because the target file did not exist. I modified the run information to the following:</p>

<div class="wp_syntax"><div class="code"><pre class="winbat" style="font-family:monospace;">C:\Windows\System32\cmd.exe /c &quot;if exist (
   C:\SOE\AUTOSTORE\AutoImage.vbe) (
      start wscript C:\SOE\AUTOSTORE\AutoImage.vbe Interval=14 Force )&quot;</pre></div></div>

<p>At first glance it may seem that some of this can be discarded, however it is all required. In order to first check that the file exists without requiring ANY script to have been installed onto the target machine we need to use &#8220;<strong>if exist</strong>&#8221; which requires running through cmd.exe because it is a command interpreter command, not a stand alone executable. If we do not use <strong>Start</strong> then the command screen stays open while the script runs, or while a popup box explaining to users that they need to reboot is displayed. This appears a disjointed visually and lead to me wanting to close all those blank black windows. WScript does not explicitly need to be called, but since I want to specify WScript instead of CScript I have included it for completeness sake.</p>
<p>In order that the command window does not show up for most of the background calls to the script I have ensured that it runs in the SYSTEM security space. The Unsecure System space is used only for those functions where the script requires user input or provides user feedback. This limits the interruption to the general use of the PCs.</p>
<p>I spent much of the past few days creating and modifying the scripts, and I spent all afternoon packaging the script into the MSI and creating the Policy Packages. I have also now documented the Policy Package creation process and documented the usage of the script. Hopefully I can get it all slapped together and rolled out, as we need to force a store before Monday, when an updated software package is being forced out. I have to love the communication we get prior to these things. I have had to kill myself to get the modifications done to their current point, and as yet they are untested for machines which have not received some of the custom modifications we have implemented. All will come to light tomorrow.</p>
<p>Cheers, Chris</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwarfsoft.com/blog/2008/09/02/return-to-getvolumenumber/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

