Microsoft
Software
Hardware
Network
Question : Adding Environment Variable to pass from a batch file to a VB Script
I need to pass two extra variables from a batch file and to the following vbscript.
BATCH FILE:
cscript EE26314082.vbs //NOLOGO input.txt H1A 2010-07-08 >output.txt
VB SCRIPT:
' Make sure the input file name is specified on the command line and get it
If (WScript.Arguments.Count > 0) Then
filename = WScript.Arguments(0)
Else
WScript.Echo "No input filename specified."
WScript.Quit
End If
' Read entire input file into a single string variable
Set fso = CreateObject("Scripting.Fi
leSystemOb
ject")
Set input = fso.OpenTextFile(filename)
data = input.ReadAll
input.Close
Set input = Nothing
' Create dictionary object to ellininate duplicates
Set dict = CreateObject("Scripting.Di
ctionary")
' Create regular expression template to locae the order numbers
Set re = New RegExp
re.Pattern = "OrderNum=[0-9][0-9][0-9][
0-9][0-9][
0-9][0-9]&
"
re.IgnoreCase = True
re.Global = True
' Loop through each match, grap order number, and if not already found add to dictionary
for Each hit In re.Execute(data)
order=Mid(hit.Value, 10, 7)
If Not dict.Exists(order) Then
dict.Add order, 0
End If
Next
' Output list of unique order numbers now
For Each o In dict
Wscript.Echo o
Next
CURRENT OUTPUT:
5134190
5085589
5122733
EXPECTED OUTPUT:
5134190,H1A,2010-07-08
5085589,H1A,2010-07-08
5122733,H1A,2010-07-08
Please note that the numbers included in the "expected output" are the parsing result of the file "input.txt" by the current VB Script.
PS: Thanks to billprew for the VS Script
Answer : Adding Environment Variable to pass from a batch file to a VB Script
No problem. You can get at them by using additional wscript.arguments(x) variables.
So the H1A would be wscript.arguments(1) and the 2010-07-08 would be wscript.arguments(2)
HTH,
exx
Random Solutions
Exchange restore using ntbackup
Put control inside of AJAX UpdatePanel, now get Type 'System.Web.UI.UpdatePanel
' does not have a public property named 'FileUpload'
Problems Replicating SYSVOL and NETLOGON on new DC WS 2008 R2 Standard in 2003 AD
Will there be a 13" Macbook with an iCore processor anytime soon? Safe to buy C2D?
How to install fonts for my website?
Backup Exec 2010 fails on VSS services
Exchange Edge Transport Issues
MS SQL count total time.
sharepoint - performance tunning
Windows player for Twonky media server