homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

JS file running from CMD and document.write
external JS files triggered by Batch process

5+ Year Member

Msg#: 4435323 posted 5:13 pm on Mar 30, 2012 (gmt 0)

here is my script:

var LOCALPATH = ".\\";

var REMOTEPATH = "/";

var FILE = "winscp421.exe";

var SESSION = "test@";

var WINSCP = "c:\\program files\\winscp

function pad(n, len)
var s = n.toString();
while (s.length < len)
s = '0' + s;
return s;

var date = new Date();

// format timestamp
var stamp =pad(date.getFullYear(), 4) + pad(date.getMonth(), 2) + pad(date.getDate(), 2);

document.write("Date Job:" +stamp);

This script should be triggered by batch process(bat file from Microsoft scheduler).
At this point all what I need is to confirm that date get written into variable stamp.
Result is error:


C:\>cscript c:\test.js
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

c:\test.js(28, 1) Microsoft JScript runtime error: 'document' is undefined

Why and how I can fix this. Normally all my JS files works fine but here I hit brick wall....



WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

Msg#: 4435323 posted 5:54 pm on Mar 30, 2012 (gmt 0)

There is no "document" object in the context of Windows Script Host. Replace document.write with WScript.Echo, and I think that will give you what you want.


5+ Year Member

Msg#: 4435323 posted 3:03 pm on May 10, 2012 (gmt 0)

I solved it.
It was a permission issue for the user running batch job in scheduler on all folders involved into this job.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved