Discussion:
Running a program with variables value from vbscript
(too old to reply)
alvyn
2004-04-10 08:36:04 UTC
Permalink
Dear Sir

But I have tried all possibilities and is still unsucessful

I am trying to run a program which can supports command line switches
Eg ; run.exe %var1% %var2% result.txt -

In Batch, I create this and it work fine like this
SET VAR1
SET VAR2
SET /P VAR1=Enter Value 1
SET /P VAR2=Enter Value 2
run.exe %var1% %var2% result.txt -
(This takes user input, store user input in variable and run the program with the variable, generate output to a text file
Note : -s switch means start automatically

I am using WSH, and trying to run a vb script to get user type in the input from Windows and run the program(run.exe) with the input. How can I accomplish this ? Please advise. Thanks

Also, I would like to seek your advise whether can I create a scrollable display box using WSH to run vb script
Eg, in the script below
Dim Strin
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objTextFile = objFSO.OpenTextFile("List.txt",1
Do Until objTextFile.AtEndOfStrea
strComputer = objTextFile.Readal
Wscript.Echo "Server name: " & strComputer
Loo
Set objTextFile = objFSO.OpenTextFile("List.txt",1
String = objTextFile.Readal
echo = "& string

It reads all text in the text files and displays everything. Thus making all text below becomes invisible when the display box exceeds the windows screen
I am trying to make it scrollable after it display, let say maybe 50 lines. Is that possible with WSH. Can you advise an example

Thanks & Regard

Alvy
Marty List
2004-04-10 15:35:36 UTC
Permalink
Dear Sir,
But I have tried all possibilities and is still unsucessful.
I am trying to run a program which can supports command line switches.
Eg ; run.exe %var1% %var2% result.txt -s
SET VAR1=
SET VAR2=
run.exe %var1% %var2% result.txt -s
(This takes user input, store user input in variable and run the program
with the variable, generate output to a text file)
Note : -s switch means start automatically.
I am using WSH, and trying to run a vb script to get user type in the
input from Windows and run the program(run.exe) with the input. How can I
accomplish this ? Please advise. Thanks
Also, I would like to seek your advise whether can I create a scrollable
display box using WSH to run vb script ?
Dim String
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("List.txt",1)
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.Readall
Wscript.Echo "Server name: " & strComputer
Loop
Set objTextFile = objFSO.OpenTextFile("List.txt",1)
String = objTextFile.Readall
echo = "& string"
It reads all text in the text files and displays everything. Thus making
all text below becomes invisible when the display box exceeds the windows
screen.
I am trying to make it scrollable after it display, let say maybe 50
lines. Is that possible with WSH. Can you advise an example ?
Thanks & Regards
Alvyn
Regarding your second question, WSH is mostly script based, no forms or
controls without using ActiveX controls. The only user interface options in
WSH are PopUp (message box) and InputBox. Notepad.exe will display your
list with a scrollbar.

Regarding your first question, try this:

Option Explicit

Dim VAR1, VAR2
Dim oShell
Dim sCmdline

VAR1 = InputBox("Enter Value 1:")
VAR2 = InputBox("Enter Value 2:")

sCmdline = "run.exe " & VAR1 & " " & VAR2 & " result.txt -s"
WScript.Echo "Launching '" & sCmdline & "'"

Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run(sCmdline)

Continue reading on narkive:
Loading...