<?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>Michael Phillips Blog &#187; vbscript</title>
	<atom:link href="http://nukeitmike.com/blog/tag/vbscript/feed" rel="self" type="application/rss+xml" />
	<link>http://nukeitmike.com/blog</link>
	<description>My place to speak about things</description>
	<lastBuildDate>Fri, 03 Feb 2012 22:55:29 +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>Another Registry Script&#8230;</title>
		<link>http://nukeitmike.com/blog/2009/03/11/another-registry-script/</link>
		<comments>http://nukeitmike.com/blog/2009/03/11/another-registry-script/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 03:18:30 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://nukeitmike.com/blog/?p=111</guid>
		<description><![CDATA[I have the unfortunate need to occasionally fix things in the registry, mostly related to applications running in a Citrix environment.  I believe there are nice tools out there that are supposed to do this for you, if given the right information, but I haven&#8217;t bothered to figure out what those tools are or how [...]]]></description>
			<content:encoded><![CDATA[<p>I have the unfortunate need to occasionally fix things in the registry, mostly related to applications running in a Citrix environment.  I believe there are nice tools out there that are supposed to do this for you, if given the right information, but I haven&#8217;t bothered to figure out what those tools are or how to use them.  Instead, I torture myself with trying to muddle through VBScript and make it do what I want. </p>
<p>In that spirit, I am going to show you one of my pitiful scripts (and this one is horrible, because I didn&#8217;t bother to clean it up after I worked out how to make it accomplish the desired goal.  So&#8230; here you go:</p>
<p>&#8216;==========================================================================<br />
&#8216;<br />
&#8216; VBScript Source File &#8212; Created with SAPIEN Technologies PrimalScript 2007<br />
&#8216;<br />
&#8216; NAME: BorlandDBPathFix.vbs<br />
&#8216;<br />
&#8216; AUTHOR: Michael Phillips , Brasfield &amp; Gorrie, LLC<br />
&#8216; DATE : March 11, 2009<br />
&#8216;<br />
&#8216; COMMENT: This script is to change the value of 2 registry keys on a per<br />
&#8216; user basis. It should set the value to be the correct system<br />
&#8216; drive (c: or u:).<br />
&#8216; It should also be noted that this script isn&#8217;t very pretty.<br />
&#8216;==========================================================================<br />
&#8216;Registry stuff<br />
Const HKCU = &amp;H80000001 &#8216;This defines the Current User Hive<br />
Const HKLM = &amp;H80000002 &#8216;This defines the Local Machine Hive<br />
Const REG_SZ = 1<br />
Const REG_EXPAND_SZ = 2<br />
Const REG_BINARY = 3<br />
Const REG_DWORD = 4<br />
Const REG_MULTI_SZ = 7<br />
vDebug = 1<br />
Dim strComputer</p>
<p>strComputer = &#8220;.&#8221; &#8216;This computer is the &#8220;.&#8221;. If you want another computer, replace the .</p>
<p>Set oReg=GetObject(&#8220;winmgmts:{impersonationLevel=impersonate}!\\&#8221; &amp; _<br />
strComputer &amp; &#8220;\root\default:StdRegProv&#8221;)</p>
<p>sGetPath<br />
Sub sGetPath<br />
Set oShell = CreateObject( &#8220;WScript.Shell&#8221; )<br />
strSystemDrive = oShell.ExpandEnvironmentStrings(&#8220;%systemdrive%&#8221;)<br />
&#8216;* wscript.echo strSystemDrive<br />
fGetRegistryValues strSystemDrive<br />
End Sub</p>
<p>&#8216;*<br />
&#8216;* This is what we are looking for:<br />
&#8216;* [HKCU\Software\Borland\BDS\4.0\DBExpress]<br />
&#8216;* @=&#8221;"<br />
&#8216;* &#8220;Connection Registry File&#8221;=&#8221;C:\\Program Files\\Common Files\\Borland Shared\\DBExpress\\dbxconnections.ini&#8221;<br />
&#8216;* &#8220;Driver Registry File&#8221;=&#8221;C:\\Program Files\\Common Files\\Borland Shared\\DBExpress\\dbxdrivers.ini&#8221;<br />
Function fGetRegistryValues (vSystemDrive)<br />
&#8216;* wscript.echo vSystemDrive &amp; &#8221; is being passed as vSystemDrive&#8221;<br />
oReg.GetExpandedStringValue HKCU,&#8221;Software\Borland\BDS\4.0\DBExpress&#8221;,&#8221;Connection Registry File&#8221;,strValue1<br />
oReg.GetExpandedStringValue HKCU,&#8221;Software\Borland\BDS\4.0\DBExpress&#8221;,&#8221;Driver Registry File&#8221;,strValue2<br />
strDriveLetter1 = Left (strValue1,2)<br />
&#8216;* wscript.echo strDriveLetter1 &amp; strValue1 &amp; strSystemDrive<br />
strDriveLetter2 = Left (strValue2,2)<br />
If strDriveLetter1 = vSystemDrive Then<br />
If strDriveLetter2 = vSystemDrive Then<br />
Else<br />
fSetRegistryValues strValue1,strValue2,vSystemDrive</p>
<p>End If<br />
Else<br />
fSetRegistryValues strValue1,strValue2,vSystemDrive<br />
End If<br />
End Function<br />
Function fSetRegistryValues (fValue1,fValue2,fDriveLetter)<br />
&#8216;* wscript.echo &#8220;Bad Letter is being passed &#8221; &amp; fValue1 &amp; fValue2 &amp; fDriveLetter<br />
vLength1 = (Len (fValue1))-2<br />
vLength2 = (Len (fValue2))-2<br />
&#8216;* wscript.echo &#8220;&#8211;strValue1 &amp; vLength1&#8211; &gt;&#8221; &amp; fValue1 &amp; &#8221; &#8221; &amp; vLength1<br />
strPathNoLetter1 = Right (fValue1,vLength1)<br />
strNewKeyValue1 = fDriveLetter &amp; strPathNoLetter1<br />
fWriteStringRegistryValues &#8220;Software\Borland\BDS\4.0\DBExpress&#8221;,&#8221;Connection Registry File&#8221;,strNewKeyValue1<br />
&#8216;* wscript.echo strNewKeyValue1</p>
<p>strPathNoLetter2 = Right (fValue2,vLength2)<br />
strNewKeyValue2 = fDriveLetter &amp; strPathNoLetter2<br />
fWriteStringRegistryValues &#8220;Software\Borland\BDS\4.0\DBExpress&#8221;,&#8221;Driver Registry File&#8221;,strNewKeyValue2<br />
&#8216;* wscript.echo (fDriveLetter &amp; (Right (fValue2,vLength2)))<br />
End Function</p>
<p>Function fWriteStringRegistryValues (fvRegistryKeyPath,fvRegistryKeyName,fvRegistryKeyValue)<br />
If vDebug = 1 Then<br />
&#8216;* wscript.echo &#8220;Begining Function -fWriteStringRegistryValues-.&#8221;<br />
End If<br />
&#8216; This function takes input to write string values to the registry. Key must already exist.<br />
oReg.SetStringValue HKCU,fvRegistryKeyPath,fvRegistryKeyName,fvRegistryKeyValue<br />
End Function</p>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2009/03/11/another-registry-script//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

