<?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>My Scripts and Tips &#187; vbs</title>
	<atom:link href="http://www.tipsandscripts.net/archives/category/vbs/feed" rel="self" type="application/rss+xml" />
	<link>http://www.tipsandscripts.net</link>
	<description>Various things I&#039;ve found useful in my travels</description>
	<lastBuildDate>Mon, 22 Aug 2011 07:28:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to tell if another instance of a VBS script is running</title>
		<link>http://www.tipsandscripts.net/archives/20</link>
		<comments>http://www.tipsandscripts.net/archives/20#comments</comments>
		<pubDate>Mon, 07 Jul 2008 02:30:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://www.tipsandscripts.net/archives/20</guid>
		<description><![CDATA[The following VBS function will allow you to check if another instance of your script is running. Note, I have only tested this for one user. ?View Code VBSFunction OtherInstances() ' This function determines if there are other instances of this script running. If other instances are running it returns TRUE, otherwise it returnes FALSE [...]]]></description>
			<content:encoded><![CDATA[<p>The following VBS function will allow you to check if another instance of your script is running. Note, I have only tested this for one user.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p20code2'); return false;">View Code</a> VBS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p202"><td class="code" id="p20code2"><pre class="vbs" style="font-family:monospace;">Function OtherInstances()
  ' This function determines if there are other instances of this script running. If other instances are running it returns TRUE, otherwise it returnes FALSE
&nbsp;
  Dim strComputer, objWMIService, colItems, objItem, Count
&nbsp;
  strComputer = &quot;.&quot;
  Count = 0
  Set objWMIService = GetObject(&quot;winmgmts:&quot; _
      &amp; &quot;{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\cimv2&quot;)
  Set colItems = objWMIService.ExecQuery _
      (&quot;Select * from Win32_Process Where Name = 'cscript.exe'&quot; &amp; _
          &quot; OR Name = 'wscript.exe'&quot;)
  For Each objItem in colItems
      If InStr(1, LCase(objItem.CommandLine), LCase(Wscript.ScriptName)) &gt; 0 Then
        Count = Count + 1	
	  End If
  Next
&nbsp;
  If Count &gt; 1 Then
    OtherInstances = TRUE
  Else
    OtherInstances = FALSE 
  End If
End Function</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tipsandscripts.net/archives/20/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

