Page 1 of 1
Start program with arguments
Posted: Wed Sep 16, 2015 1:25 pm
by jacco van der Ven
I made a little program what I want to start from VBscript with some arguments.
This is the script
Dim Argument
Argument = "> out.xml"
set oShell = CreateObject("Shell.Application")
oShell.ShellExecute "D:\Program Files (x86)\HouseBot\Config\Scripts|Phone\CallLog\Calllog.exe" & " " & Argument
When I start 'Calllog.exe > out.xml' in a commandbox it is working but not from vbScript.
When I use the ExecuteProgramDevice it also did't work.
Can someone help me with this?
Regards,
Jacco
Re: Start program with arguments
Posted: Wed Sep 16, 2015 1:57 pm
by Richard Naninck
Not sure if you can use the pipe | symbol in a string like that.
Sometimes Progra~1 or something like that will work.
Or use the example from the code below.
Code: Select all
Function Get_WhoIs(Data)
Dim objShell
Dim objExec
Dim objStdOut
Dim arrContent
Dim strCountry
Dim strNetwork
Dim strOwner
Set objShell = CreateObject ("WScript.Shell")
Set objExec = objShell.Exec ("C:\Program Files\Meedio\Meedio HouseBot\Config\AutoHome\Programs\whosip.exe " & Data)
Set objStdOut = objExec.StdOut
arrContent = Split(objStdOut.ReadAll, vbLF)
strCountry = Replace(LTrim(Split(arrContent(3), ":")(1)), vbCR, "")
strNetwork = Replace(LTrim(Split(arrContent(4), ":")(1)), vbCR, "")
strOwner = Replace(LTrim(Split(arrContent(5), ":")(1)), vbCR, "")
Get_WhoIs = strOwner & " (" & strNetwork & ") - " & strCountry
Set objStdOut = Nothing
Set objExec = Nothing
Set objShell = Nothing
End Function
Re: Start program with arguments
Posted: Wed Sep 16, 2015 2:38 pm
by jacco van der Ven
Hi Richard,
I try to run my program with some arguments.
==> CallLog.exe > out.xml
If I run this in a command box, the CallLog.exe will make a file called out.xml
I tried your code, the exe will start but there is no output file..
Re: Start program with arguments
Posted: Wed Sep 16, 2015 3:38 pm
by Richard Naninck
In my example the output should be found in: objStdOut.ReadAll and parse it or save it to an .xml file from there.
Re: Start program with arguments
Posted: Wed Sep 16, 2015 4:13 pm
by jacco van der Ven
Yes, thanks it is working now...