Developers, Developers, Developers! Maksim Sorokin IT Blog


Replacing Parameters in Files with VBScript

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 replacer itself:


Locating Startup Folder in Diffirent Windows Versions

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:


Extracting ZIP Files with VBScript

The following VBScript awaits two parameters -- the source ZIP file and target extract location:

Set args = WScript.Arguments

'The location of the zip file.
'The folder the contents should be extracted to.

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

'Extract the contants of the zip file.
set objShell = CreateObject("Shell.Application")
set FilesInZip=objShell.NameSpace(ZipFile).items
Set fso = Nothing
Set objShell = Nothing
Tagged as: , Comments Off