<?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>theDeSilva.com&#187; vb.net</title>
	<atom:link href="http://www.thedesilva.com/tag/vb-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedesilva.com</link>
	<description>Andrew de Silva</description>
	<lastBuildDate>Wed, 10 Mar 2010 21:48:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using cmd.exe with VB.NET &#8211; Process.Start</title>
		<link>http://www.thedesilva.com/2010/01/using-cmd-exe-with-vb-net-process-start/</link>
		<comments>http://www.thedesilva.com/2010/01/using-cmd-exe-with-vb-net-process-start/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 00:04:14 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[Process.start]]></category>
		<category><![CDATA[system diagnostics]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=190</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/>Here&#8217;s a quick function to show the use of System.Diagnostic.Process which will allow you to start another application using VB.NET. The example below is used to call svnadmin to create a new repository ( Subversion ) by grabbing the repository name. The function also checks to see whether the directory exist on the file system [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//VisualStudio_small.png" width="60" height="60" alt="" title=".NET" /><br/><p>Here&#8217;s a quick function to show the use of System.Diagnostic.Process which will allow you to start another application using VB.NET. The example below is used to call svnadmin to create a new repository ( Subversion ) by grabbing the repository name. The function also checks to see whether the directory exist on the file system and if it doesn&#8217;t it will start the command prompt svnadmin to create the folder. However if the folder does exist it will nag at you.</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="vbnet" style="font-family:monospace;">&nbsp;
<span style="color: #0600FF;">Sub</span> createRepo<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">Dim</span> repoName <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> repoNameInput.<span style="color: #0000FF;">Text</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> dirExist <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
&nbsp;
        <span style="color: #0600FF;">If</span> System.<span style="color: #0000FF;">IO</span>.<span style="color: #0600FF;">Directory</span>.<span style="color: #0000FF;">Exists</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;C:\svn_repository\&quot;</span> <span style="color: #008000;">&amp;</span> repoName<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            dirExist <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
            result.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&lt;font color=&quot;</span><span style="color: #808080;">&quot;red&quot;</span><span style="color: #808080;">&quot;&gt;Repository Already Exist !&lt;/font&gt;&quot;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
        <span style="color: #0600FF;">If</span> <span style="color: #000000;">&#40;</span>repoName.<span style="color: #0000FF;">Length</span> &lt;&gt; <span style="color: #FF0000;">0</span> <span style="color: #804040;">And</span> dirExist <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span>
            <span style="color: #0600FF;">Dim</span> myProcess <span style="color: #FF8000;">As</span> Process <span style="color: #008000;">=</span> Process.<span style="color: #0000FF;">Start</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;cmd.exe&quot;</span>, <span style="color: #808080;">&quot;/k svnadmin create C:\svn_repository\&quot;</span> <span style="color: #008000;">&amp;</span> repoName<span style="color: #000000;">&#41;</span>
&nbsp;
            myProcess.<span style="color: #0000FF;">WaitForExit</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">10000</span><span style="color: #000000;">&#41;</span>
            <span style="color: #008080; font-style: italic;">' if the process doesn't complete within</span>
            <span style="color: #008080; font-style: italic;">' 10 seconds, kill it</span>
&nbsp;
            <span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> myProcess.<span style="color: #0000FF;">HasExited</span> <span style="color: #FF8000;">Then</span>
                myProcess.<span style="color: #0600FF;">Kill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
            result.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Respository Created: &quot;</span> _
                <span style="color: #008000;">&amp;</span> myProcess.<span style="color: #0000FF;">ExitTime</span> <span style="color: #008000;">&amp;</span> _
                Environment.<span style="color: #0600FF;">NewLine</span> <span style="color: #008000;">&amp;</span> _
                <span style="color: #808080;">&quot;Exit Code (Troubleshooting Purpose): &quot;</span> <span style="color: #008000;">&amp;</span> _
                myProcess.<span style="color: #0000FF;">ExitCode</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>

<p>You will have to import the following library to have the Process.Start to work.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Diagnostics</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2010/01/using-cmd-exe-with-vb-net-process-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
