<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: VBS-Battle: command line for output</title>
	<link>http://bka-bonn.de/wordpress/index.php/2008/12/10/vbs/</link>
	<description>This is C++, we all have our segfaults.</description>
	<pubDate>Sun, 05 Feb 2012 07:10:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Ken Knicker</title>
		<link>http://bka-bonn.de/wordpress/index.php/2008/12/10/vbs/#comment-89</link>
		<dc:creator>Ken Knicker</dc:creator>
		<pubDate>Wed, 05 Aug 2009 22:21:11 +0000</pubDate>
		<guid>http://bka-bonn.de/wordpress/index.php/2008/12/10/vbs/#comment-89</guid>
		<description>Thanks for posting this. I needed this functionality for a logon script and explicitly do not want another command window popping up. Below is a modified version of your subroutine which ensures the CScript window stays hidden:


'/////////////////////////////////////////////////////////////////////////////'
Sub CheckStartMode
' Ensure script is launched in CScript.
'/////////////////////////////////////////////////////////////////////////////'

	' Returns the running executable as lowercase from the last \ symbol
	Dim strStartExe
	strStartExe = LCase(Mid(WScript.FullName, _
		InStrRev(WScript.FullName, "\") + 1 ) )

	If Not strStartExe = LCase("CScript.exe") Then
		Const HIDDEN_WINDOW = 0

		Dim strComputer
		Dim intProcessID
		Dim objWMIService, objStartup, objConfig, objProcess

		strComputer = "."

		Set objWMIService = GetObject("winmgmts:\\" &#38; strComputer &#38; "\root\cimv2")
		Set objStartup = objWMIService.Get("Win32_ProcessStartup")
		Set objConfig = objStartup.SpawnInstance_

		objConfig.ShowWindow = HIDDEN_WINDOW
	
		Set objProcess = GetObject("winmgmts:\\" &#38; strComputer &#38; _
			"\root\cimv2:Win32_Process")

		objProcess.Create "CScript.exe """ &#38; _
 			WScript.ScriptFullName &#38; """", null, objConfig, intProcessID

	End If

End Sub
'/////////////////////////////////////////////////////////////////////////////'</description>
		<content:encoded><![CDATA[<p>Thanks for posting this. I needed this functionality for a logon script and explicitly do not want another command window popping up. Below is a modified version of your subroutine which ensures the CScript window stays hidden:</p>
<p>&#8216;/////////////////////////////////////////////////////////////////////////////&#8217;<br />
Sub CheckStartMode<br />
&#8216; Ensure script is launched in CScript.<br />
&#8216;/////////////////////////////////////////////////////////////////////////////&#8217;</p>
<p>	&#8216; Returns the running executable as lowercase from the last \ symbol<br />
	Dim strStartExe<br />
	strStartExe = LCase(Mid(WScript.FullName, _<br />
		InStrRev(WScript.FullName, &#8220;\&#8221;) + 1 ) )</p>
<p>	If Not strStartExe = LCase(&#8221;CScript.exe&#8221;) Then<br />
		Const HIDDEN_WINDOW = 0</p>
<p>		Dim strComputer<br />
		Dim intProcessID<br />
		Dim objWMIService, objStartup, objConfig, objProcess</p>
<p>		strComputer = &#8220;.&#8221;</p>
<p>		Set objWMIService = GetObject(&#8221;winmgmts:\\&#8221; &amp; strComputer &amp; &#8220;\root\cimv2&#8243;)<br />
		Set objStartup = objWMIService.Get(&#8221;Win32_ProcessStartup&#8221;)<br />
		Set objConfig = objStartup.SpawnInstance_</p>
<p>		objConfig.ShowWindow = HIDDEN_WINDOW</p>
<p>		Set objProcess = GetObject(&#8221;winmgmts:\\&#8221; &amp; strComputer &amp; _<br />
			&#8220;\root\cimv2:Win32_Process&#8221;)</p>
<p>		objProcess.Create &#8220;CScript.exe &#8220;&#8221;" &amp; _<br />
 			WScript.ScriptFullName &amp; &#8220;&#8221;"&#8221;, null, objConfig, intProcessID</p>
<p>	End If</p>
<p>End Sub<br />
&#8216;/////////////////////////////////////////////////////////////////////////////&#8217;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

