Developers, Developers, Developers! Maksim Sorokin IT Blog

30Jun/10Off

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:

2Jun/10Off

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:

24May/10Off

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.
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("Scripting.FileSystemObject")
If NOT fso.FolderExists(ExtractTo) Then
   fso.CreateFolder(ExtractTo)
End If

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