Node Webkit not running files that run in terminal

Get help using Construct 2

Post » Mon Aug 04, 2014 5:40 pm

@Noncentz705", please more light on this, i got this error log in my console. Thanks
Error executing Javascript:
ReferenceError {stack: (...), message: "require is not defined"}
message: "require is not defined"
stack: (...)
get stack: function () { [native code] }
set stack: function () { [native code] }
__proto__: Error
Browser_plugin.js:609
0

Noncentz705 wrote:Create two bat files :
File1.bat
start C:\Users\%username%\Desktop\project_folder\File2.bat
rem Notice I didn't use %cd%\File2.bat because preview runs from a temp folder;

File2.bat
echo CMD STARTED

Now in your project back in construct
- add the browser plugin to your project
- create a variable named cd and set it's value to the path of your first bat file with \\ 's

To launch cmd Browser Execute Javascript :
"require('child_process').execFile('"&cd&"');"

With that said there's probably a way easier way to do this :lol:
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Mon Aug 04, 2014 5:41 pm

Noncentz705 wrote:Create two bat files :
File1.bat
start C:\Users\%username%\Desktop\project_folder\File2.bat
rem Notice I didn't use %cd%\File2.bat because preview runs from a temp folder;

File2.bat
echo CMD STARTED

Now in your project back in construct
- add the browser plugin to your project
- create a variable named cd and set it's value to the path of your first bat file with \\ 's

To launch cmd Browser Execute Javascript :
"require('child_process').execFile('"&cd&"');"

With that said there's probably a way easier way to do this :lol:
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Mon Aug 04, 2014 9:46 pm

I've written a plugin that pipes to cmd directly, and returns the shell response, but I won't release it.
The double batch trick works fine. Make sure you've defined a global variable named cd and that you are previewing with node-webkit.

Global text c:/users/bob/desktop/foo.bat
On some event browser execute JS "require('child_process').execFile('"&cd&"');"
B
10
S
2
G
1
Posts: 202
Reputation: 1,555

Post » Tue Aug 05, 2014 11:36 am

@Noncentz705, i finally got it to work, thanks.
I have a couple of questions though.
1) how do i specify the directory to run a file in the app folder, this backward and forward slash things are causing problems?
2) The same file i want to run with node-webkit, i would like to request it with ajax request url, for ajax request url, it just needs to be in the same folder with the executable, how can i work around this?
Noncentz705 wrote:I've written a plugin that pipes to cmd directly, and returns the shell response, but I won't release it.
The double batch trick works fine. Make sure you've defined a global variable named cd and that you are previewing with node-webkit.

Global text c:/users/bob/desktop/foo.bat
On some event browser execute JS "require('child_process').execFile('"&cd&"');"
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Tue Aug 05, 2014 4:42 pm

fixed most of the issues i had. thanks
B
15
S
4
Posts: 138
Reputation: 2,003

Previous

Return to How do I....?

Who is online

Users browsing this forum: alex3770, jasontoups, OddConfection and 1 guest