JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 14.11.2017, 15:39
torrero007
Guest
 
Posts: n/a
Default Run external program with Event Scripter

Hi, I would like to run an .exe after a download finishes, for example putty, but this code does not work in Event Scripter. What I am doing wrong:

var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "C:\\putty.exe";
oShell.ShellExecute(commandtoRun, "", "", "open", "1");

Error: ActiveXobject is not defined

Thanks
Reply With Quote
  #2  
Old 14.11.2017, 15:53
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

You've got to use the callAsync method
Code:
/* Example: */callAsync(function(exitCode,stdOut,errOut){ alert("Closed Notepad");},"notepad.exe",JD_HOME+"\\license.txt");
See more examples here, https://board.jdownloader.org/showthread.php?t=70525
Syntax is Javascript but you don't have access to full browser environment!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #3  
Old 14.11.2017, 16:32
torrero007
Guest
 
Posts: n/a
Default

Thank you Jiaz! What if I want to run it with attributes? For example

c:\\putty.exe -load “my_session”
Reply With Quote
  #4  
Old 14.11.2017, 16:40
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

from example above
Code:
callAsync(function(exitCode,stdOut,errOut){ alert("Closedotepad");},"c:\\putty.exe","-load","my_session");
__________________
JD-Dev & Server-Admin
Reply With Quote
  #5  
Old 14.11.2017, 17:17
torrero007
Guest
 
Posts: n/a
Default

Works great! Thank you very much
Reply With Quote
  #6  
Old 14.11.2017, 17:24
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

You're welcome
__________________
JD-Dev & Server-Admin
Reply With Quote
  #7  
Old 13.03.2018, 00:56
kiwi9 kiwi9 is offline
Modem User
 
Join Date: Mar 2018
Posts: 1
Default

Thanks Jiaz, torrero007,

I was struggling with a similar question: how to upload a completed file to my headless server. So for anyone using linux here's my version, triggered on Package finished.

Code:
callAsync(function(exitCode, stdOut, errOut) {
    // alert("Upload Finished !");
}, "/home/your_name/.upload.py");

The file must be executable ( chmod +x filesname ) and have an appropriate hashbang ( #!/usr/bin/python3 ).

Last edited by kiwi9; 13.03.2018 at 02:33.
Reply With Quote
  #8  
Old 13.03.2018, 09:29
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@kiwi9: no params? how does your script knows where to look for the files?
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 17:16.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.