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

msg:4435325 | 5:13 pm on Mar 30, 2012 (gmt 0) | Hello, here is my script:
var LOCALPATH = ".\\"; var REMOTEPATH = "/"; var FILE = "winscp421.exe"; var SESSION = "test@127.0.0.1"; 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:\>test.bat 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....
|
Fotiman

msg:4435348 | 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.
|
alexsts

msg:4451846 | 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. Thanks.
|
|
|