<?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>Bohack &#187; VBScript</title>
	<atom:link href="http://www.bohack.com/tag/vbscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bohack.com</link>
	<description>Check In and Tune Out!</description>
	<lastBuildDate>Wed, 24 Feb 2010 18:55:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Query and Parse XML from VBScript</title>
		<link>http://www.bohack.com/2009/02/query-and-parse-xml-from-vbscript/</link>
		<comments>http://www.bohack.com/2009/02/query-and-parse-xml-from-vbscript/#comments</comments>
		<pubDate>Sat, 14 Feb 2009 19:19:17 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=298</guid>
		<description><![CDATA[Toying around I needed to query XML from VBScript and parse it out for only the elements I needed. So I wrote a VBScript and figured I would share it. Many posts out there just load a file rather than a URL, this script will do both and I simplified it a bit. The script [...]]]></description>
			<content:encoded><![CDATA[<p>Toying around I needed to query XML from VBScript and parse it out for only the elements I needed. So I wrote a VBScript and figured I would share it. Many posts out there just load a file rather than a URL, this script will do both and I simplified it a bit.</p>
<p><span id="more-298"></span>The script here will basically query the URL and parse it our for the element name of description. Find a sitemap for a site and change the URL line like (http://somewhere.com/gsitemap.xml) and then change the xmltag to &#8220;loc&#8221;.</p>
<pre>url = "http://news.google.com/news?hl=en&amp;tab=wn&amp;ned=us&amp;q=test&amp;ie=UTF-8&amp;nolr=1&amp;output=rss"
xmltag = "description"

set xmlDoc = createobject("Microsoft.XMLDOM")
xmlDoc.async = "false"
xmlDoc.load (url)

set xmlCol = xmldoc.getElementsByTagName(xmltag)

For Each Elem In xmlCol
 wscript.Echo(Elem.firstChild.nodeValue)
Next

WScript.Echo "XML Element Count :" &amp; xmlCol.length

Set xmlCol = Nothing
Set xmlDoc = Nothing</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2009/02/query-and-parse-xml-from-vbscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple VBScript to Display a Web Page</title>
		<link>http://www.bohack.com/2009/02/simple-vbscript-to-display-a-web-page/</link>
		<comments>http://www.bohack.com/2009/02/simple-vbscript-to-display-a-web-page/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 17:27:47 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=279</guid>
		<description><![CDATA[I was currently working on a VBScript to pull some information from a web page. So decided to build a function for it, so that it can be reused over and over again in other scripts. It uses the XMLHTTP library to query a URL and return the elements, I just ask for the responsetext [...]]]></description>
			<content:encoded><![CDATA[<p>I was currently working on a VBScript to pull some information from a web page. So decided to build a function for it, so that it can be reused over and over again in other scripts. It uses the XMLHTTP library to query a URL and return the elements, I just ask for the responsetext and return it.</p>
<p><span id="more-279"></span></p>
<pre>Function GetHTML (url)
dim http
set http = createobject("msxml2.xmlhttp.3.0")
http.open "get", url, False
http.send

GetHTML = http.responsetext

set http = Nothing
End Function

WScript.echo GetHTML ("http://www.bohack.com")
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2009/02/simple-vbscript-to-display-a-web-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automated Installation Framework</title>
		<link>http://www.bohack.com/2008/11/automated-installation-framework/</link>
		<comments>http://www.bohack.com/2008/11/automated-installation-framework/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 16:20:29 +0000</pubDate>
		<dc:creator>Bohack</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.bohack.com/?p=29</guid>
		<description><![CDATA[Mass software installation is generally done with imaging of machines. The process is simple: a reference image is created and then software is installed onto it. Along the way we test the software, QC check the software installation against our environment, then regression test the software against accounts that will be used by our users. [...]]]></description>
			<content:encoded><![CDATA[<p>Mass software installation is generally done with imaging of machines. The process is simple: a reference image is created and then software is installed onto it. Along the way we test the software, QC check the software installation against our environment, then regression test the software against accounts that will be used by our users. Finally â€˜sysprep the imageâ€™ and then push out a gigantic image to the all the PCâ€™s in the field and cross our fingers.</p>
<p>Some software just does not want to be imaged, so we find ourselves reverse engineering the software to make it work; licensing is usually to blame. This can sometime take weeks because it breaks other functionality. Many times we simply donâ€™t have the time to image a PC and go through the entire process or it may be something thatâ€™s just not worth the time. Bohackâ€™s rule of thumb is: less than 40 PCâ€™s in the same location just sit down and manually install!</p>
<p>However that doesnâ€™t mean we need to give up on automation. So I wrote what I call the â€˜Automated Installation Frameworkâ€™. Itâ€™s a simple VBScript with common subroutines and often just saves time behind the keyboard. It uses a VB command called sendkeys and saves us from clicking next, next, nextâ€¦</p>
<p>To use it I recommend using a â€˜Vanillaâ€™ install of your current environment; so use the image in place you will be installing to. Virtualization undo disks help speed this process up, because you will find that you will be installing over and over again for the perfect rollout. Next start practice installing the program, as you write the keystrokes down required moving the install through its steps. Keep track of the time it takes and estimate the time for the slowest computer you have. Next create a domain account that is a local administrator or domain admin for the machines you need to install to. Create a simple profile for the user and drop the finished VBScript into the profileâ€™s startup section (base of the profile\Start Menu\Programs\Startup). Now all you need to do is login as that user and as the profile loads and the startup section runs, your install will begin. Cross your fingers and watch the install!</p>
<p><span id="more-29"></span><br />
Just copy and paste the script below into notepad and save it as &#8220;rollout.vbs&#8221;</p>
<pre>
'rollout.vbs - Bohack 2008i
'main

'everything below main to wscript.quit can be deleted and is only included for example only.

'this will run the install program
run """\\server\share\program to install\install.exe"""
'this will let the install program start
sleep 5
'now lets send some keys to walk thru the install
send "n"
send "a"
send "~"
send "o"
send "~"
'lets wait 5 minutes for the install to complete
wait 15
send "t"
send "f"
'lets delete a folder that is created during install.
DeleteFolder "C:\Documents and Settings\All Users\Start Menu\Programs\some lame program"
'lets delete some registry keys
DeleteRegKey "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon"
DeleteRegKey "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword"
DeleteRegKey "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName"
'lets wait 5 seconds
sleep 5
'then shutdown
shutdown
'of course be kind and quit
wscript.quit

'----------------------------------------------------------------
'Quotes Inside of Quotes ex run """\\ral\apps\Unreal Tournament 2004\UT2004install.exe"""
'DeleteFolder - Deletes a folder and contents ex DeleteFolder "C:\junk"
'Sleep - Sleeps in seconds ex sleep 5
'Wait - waits in minutes ex wait 2
'LogOff - LogsOff session ex LogOff
'Shutdown - Shutsdown machine ex Shutdown
'Reboot - Reboots Machine ex Reboot
'Send - Sends a keystroke and waits 1 Second ex SendKey "T"
'Run - Runs a program but still processes ex Run "\\windows\system32\calc.exe"
'RunWait - Runs a program and waits for the process to end ex RunWait "\\windows\system32\calc.exe"
'RestartService - Restarts a service ex RestartService "wuauserv"
'StopService - Stops a service ex StopService "wuauserv"
'StartService - Starts a service ex StartService "wuauserv"
'FileExists - Checks to see if file exists ex If FileExists "c:\windows\test.txt" then something
'CreateFile - Creates a file ex CreateFile "c:\windows\test.txt"
'DeleteRegKey - Deletes a registry key ex DeleteRegKey ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\PingID")
'----------------------------------------------------------------

Function Sleep (intSec)

intMSec = intSec * 1000
wscript.sleep intMSec

End Function

Function Wait (intMin)

intMSec = intMin * 60000
wscript.sleep intMSec

End Function

Function Run (strPath)

Set objShell = CreateObject("WScript.Shell")
objShell.Run strPath
Set objShell = Nothing

End Function

Function RunWait (strPath)

Set objShell = CreateObject("WScript.Shell")
objShell.Run strPath, 8, 1
Set objShell = Nothing

End Function

Function LogOff

Set objShell = CreateObject("WScript.Shell")
objShell.Run "C:\WINDOWS\system32\logoff.exe"
Set objShell = Nothing

End Function

Function Shutdown

Set objShell = CreateObject("WScript.Shell")
objShell.Run "C:\WINDOWS\system32\shutdown.exe -s -f -t 0"
Set objShell = Nothing

End Function

Function Reboot

Set objShell = CreateObject("WScript.Shell")
objShell.Run "C:\WINDOWS\system32\shutdown.exe -r -f -t 0"
Set objShell = Nothing

End Function

Function Send (strKey)

Set objShell = CreateObject("WScript.Shell")
objShell.SendKeys strKey
Set objShell = Nothing
sleep 1

End Function

Function DeleteFolder (strPath)

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strPath) Then
objFSO.DeleteFolder strPath, 1
End If
Set objFSO = Nothing

End Function

Function RestartService(strService)

set objShell = CreateObject("Shell.Application")

If objShell.IsServiceRunning(strService) Then
objShell.ServiceStop strService, True
wscript.sleep 2000
objShell.ServiceStart strService, true
wscript.sleep 2000
End If

set objShell = Nothing

End Function

Function StopService(strService)

set objShell = CreateObject("Shell.Application")

If objShell.IsServiceRunning(strService) Then
objShell.ServiceStop strService, True
wscript.sleep 2000
End If

set objShell = Nothing

End Function

Function StartService(strService)

set objShell = CreateObject("Shell.Application")

If not objShell.IsServiceRunning(strService) Then
objShell.ServiceStart strService, True
wscript.sleep 2000
End If

set objShell = Nothing

End Function

Function FileExists(strFileName)

Set objFSO = CreateObject("Scripting.FileSystemObject")
FileExists = objFSO.FileExists(strFileName)
Set objFSO = Nothing

End Function

Function CreateFile(strFileName)

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CreateTextFile(strFileName)
Set objFSO = Nothing

End Function

Function  DeleteRegKey(strRegKey)

On Error Resume Next
Set objShell = CreateObject("WScript.Shell")
objShell.RegDelete(strRegKey)
Set objShell = Nothing

End Function</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bohack.com/2008/11/automated-installation-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
