-2

for a project I need to load and then run a JavaScript script using Batch. My JavaScript script write "Website visited" to a file on my server each time that I visit my website. What I want to do is to call "http://.../js/myscript.js" with Batch in order to run this code as if I visit the URL from the browser.

Do you know how can I do?

Thank you!

JohnClear
  • 1
  • 1
  • Possible duplicate of [Writing files in Node.js](https://stackoverflow.com/questions/2496710/writing-files-in-node-js) – Dmitry Oct 08 '17 at 21:46
  • Welcome to SO. This site is not a code-writing service and is not meant for delivering complete solutions. Users are expected to show some effort and code whilst SO is here to help you solve specific programming problems along the way. Have you tried anything already? Please read: https://stackoverflow.com/help/asking – Maciej Jureczko Oct 08 '17 at 21:54

2 Answers2

0

You could write a JS script, that you execute with node, which fetches contents of the script from the url as a string and executes it with eval().

0

maybe just do a regular start up batch. Like @echo off dir C://user/admin

start myscript.js

exit

You can also use a file that runs your js file in commnd line, it will be the same as node I'd assume