Passing-variable-from-vbscript-to-batch-file with arguments

I think what you’re looking for is this. shell.run “job.bat “”argfile.ext”” ” & inp However, as Ansgar Wiechers points out, this is a potentially severe security hole, as a treacherously crafted XML file could run arbitrary commands. To encapsulate your batch file arguments and prevent unintended consequences, consider switching to the Shell.Application object’s ShellExecute method. … Read more

Compare values of two arrays – classic asp

This function: Function diffArray( aA, aB ) ‘ !! http://en.wikipedia.org/wiki/Union_%28set_theory%29 ‘ The union of two sets A and B is the collection of points which are in A or ‘ in B (or in both) Dim dicU : Set dicU = CreateObject( “Scripting.Dictionary” ) ‘ !! http://en.wikipedia.org/wiki/Intersection_%28set_theory%29 ‘ the intersection of two sets A and … Read more

How to use GetObject in VBScript

VBScript GetObject documentation can be found here. Here is a VBScript sample: Set objExcelFile = GetObject(“C:\Scripts\Test.xls”) WScript.Echo objExcelFile.Name objExcelFile.Close This code will get you the Excel Workbook object contained in C:\Scripts\Test.xls. You can use TypeName() to confirm that: Set objExcelFile = GetObject(“C:\Scripts\Test.xls”) WScript.Echo objExcelFile.Name WScript.Echo TypeName(objExcelFile) objExcelFile.Close The output will be: test.xls Workbook If the … Read more

How to find the window Title of Active(foreground) window using Window Script Host

Short answer: You can’t. At least not without writing a COM wrapper for the relevant Windows API calls. Can’t you just use AppActivate and check the result? Set oShell = CreateObject(“WScript.Shell”) If oShell.AppActivate “Untitled – Notepad” Then oShell.SendKeys “Hello, world!” End If Long answer: To get the active window title, you need to call the … Read more

How to read from a text file using VBScript?

Use first the method OpenTextFile, and then… either read the file at once with the method ReadAll: Const ForReading = 1 Dim file, content Set file = fso.OpenTextFile(“C:\test.txt”, ForReading) content = file.ReadAll or line by line with the method ReadLine: Const ForReading = 1 Dim dict, file, row, line Set dict = CreateObject(“Scripting.Dictionary”) Set file … Read more

How to call Run() with parameters

Within a literal string, a single double-quote character is represented by two double-quote characters. So try the following instead: Set objShell = WScript.CreateObject(“WScript.Shell”) objShell.Run “””C:\Program Files\Sandboxie\Start.exe”” /box:NetBeans /wait “”C:\Program Files\NetBeans 7.3\bin\netbeans64.exe”””, 1, True Set objShell = Nothing