<?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>Jeff Harbert&#039;s Blog &#187; How I Do IT</title>
	<atom:link href="http://blog.jeffharbert.com/index.php/category/how-i-do-it/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jeffharbert.com</link>
	<description>computers.books.philanthropy.privacy</description>
	<lastBuildDate>Wed, 19 Oct 2011 19:42:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Turning off User Account Control, or You&#8217;re Damned Right I&#8217;m an Expert</title>
		<link>http://blog.jeffharbert.com/index.php/2009/12/turning-off-user-account-control-or-youre-damned-right-im-an-expert/</link>
		<comments>http://blog.jeffharbert.com/index.php/2009/12/turning-off-user-account-control-or-youre-damned-right-im-an-expert/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 13:30:00 +0000</pubDate>
		<dc:creator>Jeff Harbert</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How I Do IT]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://blog.jeffharbert.com/index.php/2009/12/turning-off-user-account-control-or-youre-damned-right-im-an-expert/</guid>
		<description><![CDATA[My biggest gripe about Windows 7 is the impact User Account Control has on the command line. Unless you turn UAC completely off, every time you run something on the command line that Microsoft has deemed requiring your password – &#8230; <a href="http://blog.jeffharbert.com/index.php/2009/12/turning-off-user-account-control-or-youre-damned-right-im-an-expert/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffharbert.com%2Findex.php%2F2009%2F12%2Fturning-off-user-account-control-or-youre-damned-right-im-an-expert%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffharbert.com%2Findex.php%2F2009%2F12%2Fturning-off-user-account-control-or-youre-damned-right-im-an-expert%2F&amp;source=JeffHarbert&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>My biggest gripe about Windows 7 is the impact User Account Control has on the command line. Unless you turn UAC completely off, every time you run something on the command line that Microsoft has deemed requiring your password – even if you’re in the local Administrators group – you get an Access Denied error.</p>
<p>Screw. This. Noise.</p>
<p>This is the “ZOMG!!! If you run things as root you’ll destroy the planet!” Linux model.&#160; I don’t like it in Linux, and I definitely don’t like it here. Which mean, yes, when I’m working in Linux I log in as root. Why? One reason is that I want to be able to break things, software-wise.&#160; I want to understand why something has broken, how to avoid breaking it again in the future, and how to fix it. Knowing these things makes me a better admin.</p>
<p>The SU/SUDO model doesn’t really stop admins from breaking things, it just gets in their way.&#160; Ordinary users need the protection of SU/SUDO, not experienced administrators.&#160; It also gets in the way of doing certain things on the command line.</p>
<p>Which brings me back to Windows 7.</p>
<p>Microsoft made UAC much, much better in 7 than it was in Vista.&#160; Still, even on its lowest setting, it’s getting in my way.&#160; For example, I have a batch file on my computer.&#160; Been using it for years.&#160; The name of the file is DC.bat and it contains a single line: “defrag c:”.&#160; That’s it.&#160; In Windows XP, any time I want to defrag the hard drive I hit Windows + R, type “dc” and hit the Enter key.&#160; Boom, done.&#160; UAC prevents me from doing this in Windows 7, along with a lot of other things on the command line.</p>
<p>Forgive me while I repeat myself: Screw. This. Noise.</p>
<p>I completely understand the need to lock things down on a company network to protect the network from users who don’t know how to not break things, but this is a standalone computer with a single user &#8211; me.&#160; Also, to toot my own horn, I’m a freaking expert when it comes to Windows.&#160; I, and people like me, don’t need to be hamstrung by UAC.</p>
<p>So, finally, I turned it off completely.&#160; My computer is now in the undocumented “You’re damned right I’m an expert” mode.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffharbert.com/index.php/2009/12/turning-off-user-account-control-or-youre-damned-right-im-an-expert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert Unicode Files to ASCII</title>
		<link>http://blog.jeffharbert.com/index.php/2009/03/convert-unicode-files-to-ascii/</link>
		<comments>http://blog.jeffharbert.com/index.php/2009/03/convert-unicode-files-to-ascii/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 22:00:00 +0000</pubDate>
		<dc:creator>Jeff Harbert</dc:creator>
				<category><![CDATA[ASCII]]></category>
		<category><![CDATA[How I Do IT]]></category>
		<category><![CDATA[Unicode]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://blog.jeffharbert.com/?p=23</guid>
		<description><![CDATA[I had a situation at work recently where I needed to mine some Unicode-formatted HL7 files for data.  For my purposes, I really needed the files in plain text format.  Here&#8217;s the VBScript I used to convert the HL7 files &#8230; <a href="http://blog.jeffharbert.com/index.php/2009/03/convert-unicode-files-to-ascii/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffharbert.com%2Findex.php%2F2009%2F03%2Fconvert-unicode-files-to-ascii%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffharbert.com%2Findex.php%2F2009%2F03%2Fconvert-unicode-files-to-ascii%2F&amp;source=JeffHarbert&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I had a situation at work recently where I needed to mine some Unicode-formatted HL7 files for data.  For my purposes, I really needed the files in plain text format.  Here&#8217;s the VBScript I used to convert the HL7 files to plain text.  I hope you find it useful.</p>
<blockquote><p>Const ForReading = 1<br />
Const ForWriting = 2</p>
<p>&#8216;&#8212; The possible values for TriStateTrue are 0, -1, and -2.  -2 is the setting I needed in this case.<br />
Const TriStateTrue = -2</p>
<p>Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br />
Set objFile = objFSO.OpenTextFile(&#8220;C:\HL7Archive\000001.hl7&#8243;, ForReading,False,TriStateTrue)</p>
<p>strText = objFile.ReadAll<br />
&#8216;&#8212; In my case I needed to replace the linefeed character, chr(13), with VbCrLf.<br />
&#8216;&#8212; Otherwise the entire file would have ended up on one single line.<br />
strLine = Replace(strText, chr(13), VbCrLf)<br />
objFile.Close</p>
<p>&#8216;&#8212; Now we have the properly formatted file in memory.  Let&#8217;s write it to a new text file.<br />
Set objNewFile = objFSO.CreateTextFile(&#8220;C:\Documents and Settings\jharbert\Desktop\HL7Testing\gpa000000.txt&#8221;, True)<br />
objNewFile.WriteLine strLine<br />
objNewFile.Close</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffharbert.com/index.php/2009/03/convert-unicode-files-to-ascii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Taskkill to End Remote Processes</title>
		<link>http://blog.jeffharbert.com/index.php/2009/03/using-taskkill-to-end-remote-processes/</link>
		<comments>http://blog.jeffharbert.com/index.php/2009/03/using-taskkill-to-end-remote-processes/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 13:08:17 +0000</pubDate>
		<dc:creator>Jeff Harbert</dc:creator>
				<category><![CDATA[How I Do IT]]></category>

		<guid isPermaLink="false">http://blog.jeffharbert.com/?p=18</guid>
		<description><![CDATA[You can kill processes on a remote computer by using the taskkill command. Run ‘taskkill /?’ on a command line to see all the options. We use SpySweeper on all our workstations at work. It occasionally hangs during a scan, &#8230; <a href="http://blog.jeffharbert.com/index.php/2009/03/using-taskkill-to-end-remote-processes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffharbert.com%2Findex.php%2F2009%2F03%2Fusing-taskkill-to-end-remote-processes%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffharbert.com%2Findex.php%2F2009%2F03%2Fusing-taskkill-to-end-remote-processes%2F&amp;source=JeffHarbert&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>You can kill processes on a remote computer by using the taskkill command. Run ‘taskkill /?’ on a command line to see all the options.</p>
<p>We use SpySweeper on all our workstations at work. It occasionally hangs during a scan, severely slowing down that particular PC. Here’s the command I use to kill it remotely:</p>
<blockquote><p>taskkill /s computername /im spysweep* /f /t</p></blockquote>
<p>/s lets you designate a remote PC, in this case ‘computername’.<br />
/im lets you specify a process by application name. This lets you kill a process without knowing the PID<br />
/f forces a process to close<br />
/t also kills any child processes</p>
<p>I’ve actually made a batch file on my workstation called ks.bat. ‘ks’ = kill SpySweeper. Here it is:</p>
<blockquote><p>taskkill /s %1 /im spysweep* /f /t</p></blockquote>
<p>I simply open a Run dialog box, enter ‘ks computername’ and it kills SpySweeper on whatever workstation I specify.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffharbert.com/index.php/2009/03/using-taskkill-to-end-remote-processes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A VBScript &#8216;Wake on LAN&#8217; Project</title>
		<link>http://blog.jeffharbert.com/index.php/2009/03/a-vbscript-wake-on-lan-project/</link>
		<comments>http://blog.jeffharbert.com/index.php/2009/03/a-vbscript-wake-on-lan-project/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 10:00:00 +0000</pubDate>
		<dc:creator>Jeff Harbert</dc:creator>
				<category><![CDATA[How I Do IT]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://blog.jeffharbert.com/?p=17</guid>
		<description><![CDATA[Note: WordPress does weird things to punctuation, so don&#8217;t copy and paste the scripts in this post. For your convenience I&#8217;ve packaged the three scripts as plain text VBS files in a ZIP file, which you can download here: VBScript &#8230; <a href="http://blog.jeffharbert.com/index.php/2009/03/a-vbscript-wake-on-lan-project/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffharbert.com%2Findex.php%2F2009%2F03%2Fa-vbscript-wake-on-lan-project%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffharbert.com%2Findex.php%2F2009%2F03%2Fa-vbscript-wake-on-lan-project%2F&amp;source=JeffHarbert&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Note</strong>: WordPress does weird things to punctuation, so don&#8217;t copy and paste the scripts in this post. For your convenience I&#8217;ve packaged the three scripts as plain text VBS files in a ZIP file, which you can download here: <a title="VBScript Wake On Lan ZIP File" href="http://dl.dropbox.com/u/569310/WakeOnLan.zip">VBScript Wake On Lan ZIP File</a></p>
<p>I was working at home one weekend recently, performing some scheduled server maintenance. We have mostly HP servers where I work, and they have this nice feature built into them called Remote Insight. It&#8217;s a card that&#8217;s plugged into the motherboard of the server. This card has an ethernet port on it. You can connect to the RI card over this ethernet port and use it as a sort of virtual KVM. It&#8217;s a fantastic feature, letting you control a server remotely, shutting down or restarting if you need to, and, since it&#8217;s essentially attached to the console, you can even get into the BIOS should the need arise.</p>
<p>That is, when it works.</p>
<p>The RI cards are pretty reliable, but every once in a while they&#8217;ll disconnect you and make you wait a 30 minute timout period before it resets the connection. Not a big deal if you&#8217;re in the building, but a much bigger problem if you&#8217;re offsite, as I was this particular weekend.</p>
<p>Anyway, I had to shut down a server briefly, and that server&#8217;s RI card decided that right then would be a good time to drop its connection. I had to drive in to work on a Sunday just so I could press the power button on the server. I was good and annoyed, let me tell you.</p>
<p>The next work day, I decided to give myself a backup method of turning on a server. My tool of choice? A wonderful piece of technology called Wake on LAN. I use a tiny application called WOL.EXE for this. Open a command prompt, type &#8220;wol 112233445566? (that last part being a MAC address) and WOL.EXE sends out what&#8217;s called the magic packet to wake up the computer (or server) with the correct MAC address. This would have suited my needs perfectly, if only I&#8217;d had the MAC address of the server in question.</p>
<p>Hmm, I feel some scripting coming on.</p>
<p>Let&#8217;s not limit this to servers. Let&#8217;s cover all the computers in an entire domain, ok? Ok.</p>
<p>The first thing to do is gather all the computer names from your Active Directory domain. I found the perfect script over at Microsoft&#8217;s Script Center Repository. Their website doesn&#8217;t support direct hyperlinking, so I can&#8217;t link to the script. I&#8217;ll just give it to you here:</p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">On Error Resume Next</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Const ADS_SCOPE_SUBTREE = 2</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Set objConnection = CreateObject(&#8220;ADODB.Connection&#8221;)<br />
Set objCommand = CreateObject(&#8220;ADODB.Command&#8221;)<br />
objConnection.Provider = &#8220;ADsDSOObject&#8221;<br />
objConnection.Open &#8220;Active Directory Provider&#8221;<br />
Set objCommand.ActiveConnection = objConnection</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">objCommand.Properties(&#8220;Page Size&#8221;) = 1000<br />
objCommand.Properties(&#8220;Searchscope&#8221;) = ADS_SCOPE_SUBTREE</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">objCommand.CommandText = _<br />
&#8220;SELECT Name FROM ‘LDAP://dc=fabrikam,dc=com&#8217; WHERE objectCategory=&#8217;computer&#8217;&#8221;<br />
Set objRecordSet = objCommand.Execute</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">objRecordSet.MoveFirst<br />
Do Until objRecordSet.EOF<br />
Wscript.Echo objRecordSet.Fields(&#8220;Name&#8221;).Value<br />
objRecordSet.MoveNext<br />
Loop</span></p>
<p>Quick side note: The script references an example AD domain as ‘LDAP://dc=fabrikam,dc=com&#8217;. The AD domain where I work is actually a subdomain of our public domain name, so I have to add to the DC path above. Like so: ‘LDAP://dc=subdomain,dc=fabrikam,dc=com&#8217;. Note how I added a third DC section. That&#8217;s how you can reference a subdomain name in an LDAP path.</p>
<p>The script as-is will output the information it gathers to the console, but I wanted to capture it in a text file. The easiest way to do this without modifying the script is to run the script from within Microsoft&#8217;s Scriptomatic tool, with Scriptomatic set to display the results in a text file. Boom, nice and easy. I use Scriptomatic a lot this way.</p>
<p>Paste the script into Scriptomatic, change the LDAP path in the script to your own AD domain, and click Run. After a second or two you&#8217;ll see a text file pop open with a list of all the computers and servers in your domain. Save this text file somewhere safe. I saved mine with the name workstations.txt.</p>
<p>Now we need to fetch all the MAC addresses of the computers listed in that text file we just saved. We&#8217;ll use another script to do that, using the text file we just saved as the input for the script.</p>
<p>Here&#8217;s the script:</p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Let&#8217;s Dim our variables</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Dim strComputer, objFSO</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211;Set some constants used for manipulating text files</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Const ForReading = 1<br />
Const ForAppending = 8</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Let&#8217;s open the list of workstations we grabbed from Active Directory<br />
</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br />
Set objFile = objFSO.OpenTextFile(&#8220;C:\scripts\Fetch MAC Addresses\workstations.txt&#8221;, ForReading)</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; We want to loop through the text file line by line</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; grabbing MAC addresses as we go —</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Do Until objFile.AtEndOfStream<br />
strComputer = objFile.ReadLine</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Let&#8217;s see if we can ping the workstation</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Set WshShell = CreateObject(&#8220;WScript.Shell&#8221;)<br />
PINGFlag = Not CBool(WshShell.run(&#8220;ping -n 2 -w 250 &#8221; &amp; strComputer,0,True))</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; If we can ping the workstation, grab the MAC address and save it in a text file<br />
</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">If PINGFlag = True Then<br />
wScript.Echo strComputer &amp; &#8221; pings&#8221;<br />
Dim objShell,objExec<br />
Set objShell=CreateObject(&#8220;wscript.shell&#8221;)<br />
strCommand=&#8221;nbtstat -a &#8221; &amp; strComputer<br />
Set objExec=objShell.Exec(strCommand)<br />
Do While objExec.StdOut.AtEndOfStream True<br />
strLine=objExec.StdOut.ReadLine<br />
If InStr(strLine,&#8221;MAC Address&#8221;) Then<br />
arrFields = Split(strLine, &#8221; &#8220;)<br />
strMAC1 = arrFields(7)<br />
strMACAddress = Replace(strMAC1, &#8220;-&#8221;, &#8220;&#8221;)<br />
strCompEntry = strComputer &amp; &#8220;,&#8221; &amp; strMACAddress<br />
Set objFile2 = objFSO.OpenTextFile(&#8220;C:\scripts\Fetch MAC Addresses\MAC_Addresses.txt&#8221;, ForAppending)<br />
objFile2.WriteLine strCompEntry<br />
objFile2.close<br />
End If<br />
Loop<br />
Else</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211;If we can&#8217;t ping the workstation, let&#8217;s log that so we</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; can get the MAC address later</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Set objFile3 = objFSO.OpenTextFile(&#8220;C:\scripts\Fetch MAC Addresses\cannot_ping.txt&#8221;, ForAppending)<br />
objFile3.WriteLine strComputer<br />
objFile3.close</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">End If</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Loop</span></p>
<p>The script reads the first workstation name, sees if the workstation responds to ping, runs the nbtstat command against the workstation, grabs the MAC address by monitoring the stdout of the nbtstat command, then saves the workstation name and MAC address (sans hyphens) to a second text file. Also, if the workstation does not respond to ping, it saves that workstation name to a third text file. We can use this third text file at a later date as the input file of this same script so that, over time, we can gather all the MAC addresses in our domain.</p>
<p>There you have it, all the MAC addresses in your domain. For myself, I now have all the information I need to wake up any workstation or server on my domain, but let&#8217;s not stop here. Let&#8217;s make it easy to use the MAC addresses we just gathered.</p>
<p>Here&#8217;s a script that prompts you for a workstation name, searches for the MAC address in the second text file, then automatically sends the WOL packet to wake up the workstation.</p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Let&#8217;s dim our variables<br />
dim fname, objFSO, objFile</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; This opens an input box into which we&#8217;ll enter our workstation name<br />
</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">fname=InputBox(&#8220;Which computer do you want to wake up?&#8221;)<br />
fname = UCase(fname)</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Some tracking integers<br />
</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">i = 0<br />
y = 0</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Const ForReading = 1</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Open the text file of MAC addresses and read the<br />
&#8216;&#8211; entire thing into memory at once<br />
</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<br />
Set objFile = objFSO.OpenTextFile_<br />
(&#8220;C:\scripts\Fetch MAC Addresses\Copy of MAC_Addresses.txt&#8221;, ForReading)<br />
strFile = objFile.ReadAll<br />
objFile.Close</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">strList = Replace(strFile, vbCrLf, &#8220;,&#8221;)<br />
wScript.Echo strList</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Split the file into an array, using the comma delimiter<br />
</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">arrFields = Split(strList, &#8220;,&#8221;)</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; When we find a match we&#8217;ll increment Y by 1, but<br />
&#8216;&#8211; we want the script to keep looping until otherwise<br />
</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Do While y=0</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Whatever array field has the workstation name, the MAC address<br />
&#8216;&#8211; will be in the next field</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">strPC=arrFields(i)<br />
strMAC=arrFields(i+1)</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Let&#8217;s see if we have a match between the workstation name taken<br />
&#8216;&#8211; from the text file and the input box</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">If strPC = fname Then</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; If we do, let&#8217;s grab the MAC address and send the WOL signal</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Dim objShell,objExec<br />
Set objShell=CreateObject(&#8220;wscript.shell&#8221;)<br />
strCommand=&#8221;C:\scripts\wol.exe &#8221; &amp; strMAC<br />
Set objExec=objShell.Exec(strCommand)<br />
&#8216;&#8211; Let&#8217;s get a visual confirmation that we sent the WOL signal</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">wscript.echo &#8220;Wake on lan command sent to MAC address &#8221; &amp; strMAC</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; Since we found a match, let&#8217;s increment Y<br />
y=1<br />
End If</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; If we didn&#8217;t find a match, let&#8217;s look at the next workstation name<br />
&#8216;&#8211; which will always be two array segments away</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">i=i+2</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">&#8216;&#8211; The loop will terminate here once Y=1, otherwise it&#8217;ll keep going</span></p>
<p style="padding-left: 30px;"><span style="font-family: Courier New; font-size: small;">Loop</span></p>
<p>And there you have it. I hope you find this helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffharbert.com/index.php/2009/03/a-vbscript-wake-on-lan-project/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

