Source language: Translate to:

Execute a EXE and redirects to a variable

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Execute a EXE and redirects to a variable

Postby Apoleo » Mon Feb 09, 2009 5:43 pm

Hi. I've tried to run a EXE (console application) and to redirect the result in a variable which I send to Neobook. I've been looking for information but I've no success.

What I do:
Code: Select all
Function F1()
    dim oWs
    Set oWs = CreateObject("WScript.Shell")

    strCommand = oWs.Run ("[PubDir]app.exe",1,True)
    Set objExecObject = objShell.Exec(strCommand)
    Set objStdOut = objWshScriptExec.StdOut
    F1 = objStdOut
End Function

publication.nbSetVar "[%1]", F1()

Anyone knows how to do it? Thanks!

Saludos.
User avatar
Apoleo
 
Posts: 88
Joined: Sat May 14, 2005 1:17 pm
Location: Sevilla, España

Postby Neosoft Support » Mon Feb 09, 2009 5:47 pm

You might try the Exec method instead. Here's some info:

http://msdn.microsoft.com/en-us/library/ateytk4a(VS.85).aspx
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby aguilar955 » Thu May 21, 2009 6:29 am

Apoleo
¿Al final conseguiste que funcionara?
After all that work?
I am interested in the function to capture the text or the text output from the Shell.

Salu2
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am

Postby Apoleo » Thu May 21, 2009 8:11 am

Hi, I did this code and it works. However the Windows command shell is shown for a little while. I don't know if there are any way to hide the shell completely.

Code: Select all
{NeoBook Function}
Version=5,60
Language=VBScript
Param=[%1]|FileName|Exe File
Param=[%2]|Mixed|Params
Param=[%3]|Variable|Store In...
{End}
Function ExeRun()
    Set oWs = CreateObject("WScript.Shell")
    Set objScriptExec = oWs.Exec("[%1] [%2]")
    strRes = objScriptExec.StdOut.ReadAll
    ExeRun = strRes
End Function

publication.nbSetVar "[%3]", ExeRun()


Saludos
User avatar
Apoleo
 
Posts: 88
Joined: Sat May 14, 2005 1:17 pm
Location: Sevilla, España

Postby aguilar955 » Thu May 21, 2009 8:30 am

Thank you very much.

Salu2
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am

Postby aguilar955 » Mon Jun 01, 2009 6:06 pm

Apoleo Can not get it to work I always throw error can give an example.pub

Salu2
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am

Postby Apoleo » Tue Jun 02, 2009 4:01 am

Yeah, here the example:

:arrow: http://www.box.net/shared/igcm10695g

Must say the VBScript function only works with Win32 Console Applications.

Saludos
User avatar
Apoleo
 
Posts: 88
Joined: Sat May 14, 2005 1:17 pm
Location: Sevilla, España

Postby aguilar955 » Fri Jun 12, 2009 4:47 pm

Thank you very much Apoleo I got it to work, you are undoubtedly a master.
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am

Postby aguilar955 » Mon Apr 26, 2010 1:21 am

Run "cmd" "/c [#34][CurrentDir]wget.exe[#34] -c http://archivo.exe > lista.txt 2>&1" "Wait+Hidden" "" ""
Run "cmd" "/c [#34][CurrentDir]wget.exe[#34] -c http://archivo.exe 2> lista2.txt" "Wait+Hidden" "" ""

lista.txt and lista2.txt, Ok.

Salu2
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am

Postby aguilar955 » Wed Jun 02, 2010 6:25 am

Run "cmd" "/c wget.exe -c -O [#34][CurrentDir]\file.xxx[#34] [#34]http://file.xxx[#34] 2> out.txt" "Hidden" "" ""
Run "cmd" "/c wget.exe -c -O [#34][CurrentDir]\file.xxx[#34] [#34]http://file.xxx[#34] > out.txt 2>&1" "Hidden" "" ""

stdin, stdout and stderr

Code: Select all
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am

Postby Neosoft Support » Wed Jun 02, 2010 11:06 am

I think you have a typo. Both commands are attempting to write to the same file at the same time.

Run "cmd" "/c wget.exe -c -O [#34][CurrentDir]\file.xxx[#34] [#34]http://file.xxx[#34] 2> out.txt" "Hidden" "" ""
Run "cmd" "/c wget.exe -c -O [#34][CurrentDir]\file.xxx[#34] [#34]http://file.xxx[#34] > out.txt 2>&1" "Hidden" "" ""
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby aguilar955 » Wed Jun 02, 2010 1:01 pm

Neosoft Support wrote:I think you have a typo. Both commands are attempting to write to the same file at the same time.

Run "cmd" "/c wget.exe -c -O [#34][CurrentDir]\file.xxx[#34] [#34]http://file.xxx[#34] 2> out.txt" "Hidden" "" ""
Run "cmd" "/c wget.exe -c -O [#34][CurrentDir]\file.xxx[#34] [#34]http://file.xxx[#34] > out.txt 2>&1" "Hidden" "" ""


ImageImageImage

There are two options for the same function.

Choose the one that but like it or agree.

Regards
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am

pub

Postby naglieri » Thu Jun 03, 2010 12:11 am

Is possible have all your pub as example?
Thanks



aguilar955 wrote:
Neosoft Support wrote:I think you have a typo. Both commands are attempting to write to the same file at the same time.

Run "cmd" "/c wget.exe -c -O [#34][CurrentDir]\file.xxx[#34] [#34]http://file.xxx[#34] 2> out.txt" "Hidden" "" ""
Run "cmd" "/c wget.exe -c -O [#34][CurrentDir]\file.xxx[#34] [#34]http://file.xxx[#34] > out.txt 2>&1" "Hidden" "" ""


ImageImageImage

There are two options for the same function.

Choose the one that but like it or agree.

Regards
Naglieri Marco
Information Technology
Tel +39-0721-433352 Fax +39-0721-400924
Renco S.p.A - 61100 Pesaro - Italy
www.renco.it
User avatar
naglieri
 
Posts: 49
Joined: Thu Mar 31, 2005 11:31 pm

Postby aguilar955 » Thu Jun 03, 2010 6:17 am

Test Cmd

Code: Select all
http://www.megaupload.com/?d=G13FUKWG


Test Wget.exe

Code: Select all
http://www.megaupload.com/?d=Q8PI766N


Saludos
aguilar955
 
Posts: 85
Joined: Sat Jan 17, 2009 10:50 am


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests