<?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>teamzone.ch &#187; VB-Script</title>
	<atom:link href="http://teamzone.ch/tag/vb-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://teamzone.ch</link>
	<description>Welcome to the Joint-Venture Blog from Fabio Cortesi and Stefan Jäger.</description>
	<lastBuildDate>Wed, 01 Jun 2011 22:43:46 +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>Deleting a folder structure with all files and subfolders using VB Script</title>
		<link>http://teamzone.ch/2009/05/11/wise-msi-script-deleting-a-folder-structure-with-all-files-and-subfolders-using-vb-script/</link>
		<comments>http://teamzone.ch/2009/05/11/wise-msi-script-deleting-a-folder-structure-with-all-files-and-subfolders-using-vb-script/#comments</comments>
		<pubDate>Mon, 11 May 2009 08:51:00 +0000</pubDate>
		<dc:creator>Fabio Cortesi</dc:creator>
				<category><![CDATA[MSI]]></category>
		<category><![CDATA[WISE Package Studio]]></category>
		<category><![CDATA[VB-Script]]></category>

		<guid isPermaLink="false">http://teamzone.ch/2009/05/11/wise-msi-script-deleting-a-folder-structure-with-all-files-and-subfolders-using-vb-script/</guid>
		<description><![CDATA[By default WISE can’t delete a folder structure with all files and subfolders. The technologie of MSI is designed to delete only these components by uninstalling, which were installed. &#160; With the following VB-Script can do just that. It makes sense, that the script uses a property of the directory-table. The example uses the “JUNIPER” [...]]]></description>
			<content:encoded><![CDATA[<p>By default WISE can’t delete a folder structure with all files and subfolders. The technologie of MSI is designed to delete only these components by uninstalling, which were installed.</p>
<p>&#160;</p>
<p>With the following VB-Script can do just that. It makes sense, that the script uses a property of the directory-table. The example uses the “JUNIPER” directory, which will be deleted by the script.</p>
<p><a href="http://teamzone.ch/wp-content/uploads/2009/05/snap21.jpg"  rel="lightbox" rel="lightbox[roadtrip]"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Snap2" border="0" alt="Snap2" src="http://teamzone.ch/wp-content/uploads/2009/05/snap2-thumb1.jpg" width="564" height="37" /></a> </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Option</span> <span style="color: #E56717; font-weight: bold;">Explicit</span> 
<span style="color: #151B8D; font-weight: bold;">Dim</span> WshShell,SystemFolder,Fso,strFolder, strFile, ret
&nbsp;
<span style="color: #008000;">' Set the property
</span>strFolder = GetAProperty(<span style="color: #800000;">&quot;JUNIPER&quot;</span>)
&nbsp;
<span style="color: #008000;">' Delete the last character at the end of the string 
</span><span style="color: #008000;">' -&gt; example: C:\Programm Files\Test&quot;\&quot;
</span><span style="color: #008000;">' For a correct deleting of a directory-property, 
</span><span style="color: #008000;">' the backslash at the end has to be deleted
</span>strFolder = Left(strFolder,Len(strFolder)-1)
&nbsp;
<span style="color: #008000;">' Environment variable reading 
</span><span style="color: #151B8D; font-weight: bold;">set</span> WshShell = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;WScript.Shell&quot;</span>) 
<span style="color: #151B8D; font-weight: bold;">set</span> Fso=<span style="color: #E56717; font-weight: bold;">createobject</span>(<span style="color: #800000;">&quot;scripting.filesystemobject&quot;</span>) 
&nbsp;
<span style="color: #008000;">' Delete the folder
</span><span style="color: #8D38C9; font-weight: bold;">If</span> Fso.FolderExists(strFolder) <span style="color: #8D38C9; font-weight: bold;">Then</span> 
ret = Fso.DeleteFolder (strFolder,<span style="color: #00C2FF; font-weight: bold;">True</span>) 
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">If</span>
&nbsp;
<span style="color: #151B8D; font-weight: bold;">Set</span> WshShell = <span style="color: #00C2FF; font-weight: bold;">Nothing</span> 
<span style="color: #151B8D; font-weight: bold;">Set</span> fso = <span style="color: #00C2FF; font-weight: bold;">Nothing</span> 
&nbsp;
<span style="color: #008000;">' Getting a property
</span><span style="color: #E56717; font-weight: bold;">Function</span> GetAProperty (PROPERTYNAME)
<span style="color: #151B8D; font-weight: bold;">dim</span> szStringVal
szStringVal = Session.<span style="color: #151B8D; font-weight: bold;">Property</span>(PROPERTYNAME)
GetAProperty = szStringVal
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></td></tr></table></div>

<p><span id="more-343"></span></p>
<p>The script must be implemented in the “immediate” section of the MSI-Script. In my example it has to be on the latest position – immediately before the completion of the installation.</p>
<p><a href="http://teamzone.ch/wp-content/uploads/2009/05/snap1.jpg"  rel="lightbox" rel="lightbox[roadtrip]"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Snap1" border="0" alt="Snap1" src="http://teamzone.ch/wp-content/uploads/2009/05/snap1-thumb.jpg" width="296" height="107" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://teamzone.ch/2009/05/11/wise-msi-script-deleting-a-folder-structure-with-all-files-and-subfolders-using-vb-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

