<?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>Savory Ape &#187; MidSOUTH</title>
	<atom:link href="http://savoryape.com/topic/projects/ms-ualr/feed/" rel="self" type="application/rss+xml" />
	<link>http://savoryape.com</link>
	<description>Progressive Internet Solutions</description>
	<lastBuildDate>Tue, 09 Mar 2010 13:44:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Force Command-Line for VBScripts</title>
		<link>http://savoryape.com/2009/06/force-cmdline-vbs/</link>
		<comments>http://savoryape.com/2009/06/force-cmdline-vbs/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 17:05:55 +0000</pubDate>
		<dc:creator>chrishota</dc:creator>
				<category><![CDATA[MidSOUTH]]></category>
		<category><![CDATA[Command-line interface]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://savoryape.com/?p=34</guid>
		<description><![CDATA[Say you have a script—like the previous CIM Repository Listing script—that outputs hundreds of rows of text via WScript.Echo. On the command line, this is fine; the text will go scrolling by, and can be piped to the more command or grep (yes, really), or logged to a file. But if you make the mistake [...]]]></description>
			<content:encoded><![CDATA[<p>Say you have a script—like the previous <a href="http://savoryape.com/2009/06/list-win32-cimv2/">CIM Repository Listing</a> script—that outputs hundreds of rows of text via WScript.Echo.  On the command line, this is fine; the text will go scrolling by, and can be piped to the more command or grep (yes, really), or logged to a file.  But if you make the mistake of executing a script like this by double-clicking, you&#8217;ll get modal popup messages that prevent the rest of the script from running until you hit &#8220;OK&#8221; for each line.</p>
<p>You could change the default scripting environment to always be the command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CScript <span style="color: #000000; font-weight: bold;">//</span>H:CScript <span style="color: #000000; font-weight: bold;">//</span>NoLogo <span style="color: #000000; font-weight: bold;">//</span>S</pre></div></div>

<p>But then you have to treat the GUI-based scripts differently, and launch them from the command line with wscript.  Oh, bother.</p>
<p>It&#8217;s always been possible to just go ahead and launch vbscripts from the command line with the cscript command, but having to open a command prompt and type out the path to the script every time is a pain.  Why not have the script auto-detect how it was launched, and if it wasn&#8217;t launched from the command line, relaunch itself correctly?  Well, <a href="http://tek-tips.com/viewthread.cfm?qid=1175727">Tek-Tips user tsuji</a> has figured out how to do it.</p>
<p>By including this subroutine in your VBScript and putting a call to it at the top of the script, it will do just that.</p>
<p>The edits to this script from tsuji&#8217;s version are that instead of keeping the command window open after execution with the &#8220;/k&#8221; switch, I continue to use the &#8220;/c&#8221; (close command after completion) but chain the &#8220;pause&#8221; command at the end of the command.  This is a little-known (in the DOS/Windows world, anyway) way of doing multiple things at once:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">command1 <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> command2</pre></div></div>

<p>On *NIX, this will execute command2 after command1 completes, if it completes successfully (return code 0).  On Windows, however, command2 will always be run, no matter the outcome of command1.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> force_cmdline
	<span style="color: #000080;">Dim</span> args : args=<span style="color: #800000;">&quot;&quot;</span>
	<span style="color: #000080;">Dim</span> i, wshshell
	<span style="color: #000080;">If</span> right(lCase(wscript.fullname),11)= <span style="color: #800000;">&quot;wscript.exe&quot;</span> <span style="color: #000080;">then</span>
		<span style="color: #000080;">For</span> i=0 <span style="color: #000080;">to</span> wscript.arguments.count-1
			args = args &amp; wscript.arguments(i) &amp; <span style="color: #800000;">&quot; &quot;</span>
		<span style="color: #000080;">Next</span>
		<span style="color: #000080;">Set</span> wshshell = createobject(<span style="color: #800000;">&quot;wscript.shell&quot;</span>)
		wshshell.Run wshshell.ExpandEnvironmentStrings(<span style="color: #800000;">&quot;%comspec%&quot;</span>) &amp; <span style="color: #800000;">&quot; /c cscript.exe //nologo &quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; wscript.scriptfullname &amp; <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;&quot;</span> &amp; args &amp; <span style="color: #800000;">&quot; &amp;&amp; pause&quot;</span>
		<span style="color: #000080;">set</span> wshshell = <span style="color: #000080;">Nothing</span>
		WScript.Quit
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://savoryape.com/2009/06/force-cmdline-vbs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Listing All Win32 CIMv2 Providers</title>
		<link>http://savoryape.com/2009/06/list-win32-cimv2/</link>
		<comments>http://savoryape.com/2009/06/list-win32-cimv2/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 17:00:53 +0000</pubDate>
		<dc:creator>chrishota</dc:creator>
				<category><![CDATA[MidSOUTH]]></category>
		<category><![CDATA[cim]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[wbem]]></category>
		<category><![CDATA[wim]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://savoryape.com/?p=16</guid>
		<description><![CDATA[When starting to troubleshoot a Windows Server problem, the best place to look is the Windows Management Instrumentation (WMI); this little enclave of information—on every Windows machine—acts like a datastore representing the configuration of every nook and cranny of a system. But knowing what to look for is half the battle. Recently, I was faced [...]]]></description>
			<content:encoded><![CDATA[<p>When starting to troubleshoot a Windows Server problem, the best place to look is the Windows Management Instrumentation (WMI); this little enclave of information—on every Windows machine—acts like a datastore representing the configuration of every nook and cranny of a system.  But knowing what to look for is half the battle.</p>
<p>Recently, I was faced with diagnosing slow replication times for Branch Office Distributed File System Replication under Windows Server 2003.  I had no idea where to look, so I referenced the following script, pointed the two instances of strComputer to our DFS-enabled file server, and looked for DFS-specific properties and methods:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">cscript <span style="color: #ff0000;">&quot;List Win32 Providers.vbs&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> dfs</pre></div></div>

<p>This gave me the performance counters I could use to monitor performance, as well as how to programmatically create DFS shares and namespaces.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">strComputer = <span style="color: #800000;">&quot;.&quot;</span>
<span style="color: #000080;">Set</span> objWMIService=GetObject(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot;</span> &amp; strComputer &amp; <span style="color: #800000;">&quot;\root\cimv2&quot;</span>)
&nbsp;
<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> objclass <span style="color: #000080;">in</span> objWMIService.SubclassesOf()
    intCounter=0
    <span style="color: #000080;">If</span> Left(objClass.Path_.Class,5) = <span style="color: #800000;">&quot;Win32&quot;</span> <span style="color: #000080;">Then</span>
        <span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> Qualifier <span style="color: #000080;">in</span> objClass.Qualifiers_
            <span style="color: #000080;">If</span> UCase(Trim(Qualifier.Name)) = <span style="color: #800000;">&quot;ASSOCIATION&quot;</span> <span style="color: #000080;">Then</span>
                intCounter = 1
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
        <span style="color: #000080;">Next</span>
        <span style="color: #000080;">If</span> x = 0 <span style="color: #000080;">Then</span>
            strComputer = <span style="color: #800000;">&quot;.&quot;</span>
            <span style="color: #000080;">Set</span> objWMIService = GetObject _
                (<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot;</span> &amp; _
                    strComputer &amp; <span style="color: #800000;">&quot;\root\cimv2&quot;</span>)
            <span style="color: #000080;">Set</span> strClass = objWMIService.<span style="color: #000080;">Get</span>(objClass.Path_.Class)
            Wscript.Echo <span style="color: #800000;">&quot;PROPERTIES:&quot;</span>
            <span style="color: #000080;">For</span> <span style="color: #000080;">each</span> strItem <span style="color: #000080;">in</span> strClass.properties_
                Wscript.Echo objClass.Path_.Class &amp; vbTab &amp; strItem.name 
            <span style="color: #000080;">Next</span>
            Wscript.Echo <span style="color: #800000;">&quot;METHODS:&quot;</span>
            <span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> strItem <span style="color: #000080;">in</span> strClass.methods_
                Wscript.Echo objClass.Path_.Class &amp; vbTab &amp; strItem.name 
            <span style="color: #000080;">Next</span>
        <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">Next</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://savoryape.com/2009/06/list-win32-cimv2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
