<?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>Developers, Developers, Developers! &#187; VBScript</title>
	<atom:link href="http://maksim.sorokin.dk/it/tag/vbscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://maksim.sorokin.dk/it</link>
	<description>Maksim Sorokin IT Blog</description>
	<lastBuildDate>Sun, 05 Feb 2012 19:37:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Replacing Parameters in Files with VBScript</title>
		<link>http://maksim.sorokin.dk/it/2010/06/30/replacing-parameters-in-files-with-vbscript/</link>
		<comments>http://maksim.sorokin.dk/it/2010/06/30/replacing-parameters-in-files-with-vbscript/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 14:28:13 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=260</guid>
		<description><![CDATA[Here is a small VBScript that replaces parameters in a file. For example you have file1 with: Hello, my name is ${name}. I am from ${place}. Using this VBScript replacer, you can replace those parameters and write all the contents to another file file2: replacer.vbs file_with_parameters file_to_write key1 value1 key2 value2 .. And here is [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a small VBScript that replaces parameters in a file. For example you have <code>file1</code> with:</p>
<pre class="brush: plain; title: ;">
Hello, my name is ${name}. I am from ${place}.
</pre>
<p>Using this VBScript replacer, you can replace those parameters and write all the contents to another file <code>file2</code>:</p>
<pre class="brush: plain; title: ;">
replacer.vbs file_with_parameters file_to_write key1 value1 key2 value2 ..
</pre>
<p>And here is replacer itself:<span id="more-260"></span></p>
<pre class="brush: vb; title: ;">
Set args = WScript.Arguments
Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFile = objFSO.OpenTextFile(args.item(0), 1)

Set writeToFile = objFSO.CreateTextFile(args.item(1), true)

Set params = CreateObject(&quot;Scripting.Dictionary&quot;)
For i = 2 To args.Count-1 Step 2
	params.Add args.item(i), args.item(i+1)
Next

Dim arrFileLines()
i = 0
Do Until objFile.AtEndOfStream
  Redim Preserve arrFileLines(i)
  arrFileLines(i) = objFile.ReadLine
  i = i + 1
Loop
objFile.Close

For Each strLine in arrFileLines
	For Each key In params
		strLine = Replace(strLine, &quot;${&quot; &amp; key &amp; &quot;}&quot;, params.Item(key))
	Next

  writeToFile.WriteLine(strLine)
Next
writeToFile.Close
</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/06/30/replacing-parameters-in-files-with-vbscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Locating Startup Folder in Diffirent Windows Versions</title>
		<link>http://maksim.sorokin.dk/it/2010/06/02/locating-startup-folder-in-diffirent-windows-versions/</link>
		<comments>http://maksim.sorokin.dk/it/2010/06/02/locating-startup-folder-in-diffirent-windows-versions/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 16:55:30 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=225</guid>
		<description><![CDATA[Startup folder lets you to launch applications automatically after user logged in. Sometimes one would like to use such functionality and add own startup scripts. But the problem is that this startup folder has different locations in different Windows versions. For example, in Windows XP: %USERPROFILE%\Start Menu\Programs\Startup But in Windows 7: %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup It is [...]]]></description>
			<content:encoded><![CDATA[<p>Startup folder lets you to launch applications automatically after user logged in. Sometimes one would like to use such functionality and add own startup scripts. But the problem is that this startup folder has different locations in different Windows versions.<br />
For example, in Windows XP:<span id="more-225"></span></p>
<pre class="brush: plain; title: ;">%USERPROFILE%\Start Menu\Programs\Startup</pre>
<p>But in Windows 7:</p>
<pre class="brush: plain; title: ;">%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup</pre>
<p>It is possible to determine this Startup folder through registry. Location of record in the registry is:</p>
<pre class="brush: plain; title: ;">HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Startup</pre>
<p>And we can write a VBScript, which would read this registry record and create a bat file in Startup folder:</p>
<pre class="brush: vb; title: ;">
Set oShell = CreateObject(&quot;WScript.Shell&quot;)
value = oShell.RegRead(&quot;HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Startup&quot;)

oShell.run(&quot;cmd /c echo echo hello!!1 &gt; &quot;&quot;&quot; &amp;  oShell.ExpandEnvironmentStrings(value) &amp; &quot;&quot;&quot;\hello.bat&quot;)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/06/02/locating-startup-folder-in-diffirent-windows-versions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extracting ZIP Files with VBScript</title>
		<link>http://maksim.sorokin.dk/it/2010/05/24/extracting-zip-files-with-vbscript/</link>
		<comments>http://maksim.sorokin.dk/it/2010/05/24/extracting-zip-files-with-vbscript/#comments</comments>
		<pubDate>Mon, 24 May 2010 18:50:14 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[ZIP]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=209</guid>
		<description><![CDATA[The following VBScript awaits two parameters -- the source ZIP file and target extract location: Set args = WScript.Arguments 'The location of the zip file. ZipFile=args.item(0) 'The folder the contents should be extracted to. ExtractTo=args.item(1) 'If the extraction location does not exist create it. Set fso = CreateObject(&#34;Scripting.FileSystemObject&#34;) If NOT fso.FolderExists(ExtractTo) Then fso.CreateFolder(ExtractTo) End If [...]]]></description>
			<content:encoded><![CDATA[<p>The following VBScript awaits two parameters -- the source ZIP file and target extract location:</p>
<pre class="brush: vb; title: ;">
Set args = WScript.Arguments

'The location of the zip file.
ZipFile=args.item(0)
'The folder the contents should be extracted to.
ExtractTo=args.item(1)

'If the extraction location does not exist create it.
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
If NOT fso.FolderExists(ExtractTo) Then
   fso.CreateFolder(ExtractTo)
End If

'Extract the contants of the zip file.
set objShell = CreateObject(&quot;Shell.Application&quot;)
set FilesInZip=objShell.NameSpace(ZipFile).items
objShell.NameSpace(ExtractTo).CopyHere(FilesInZip)
Set fso = Nothing
Set objShell = Nothing
</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/05/24/extracting-zip-files-with-vbscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

