1 Reply Latest reply on May 16, 2007 4:25 PM by Grizzly9279

    Windows Script Generation Problems

      I am generating a WSF for use on my servers, but the method I'm using comes up with a strange problem.

      I am using CFFile to write and append to a file on my webserver which is pretty elementary. The problem is that when I execute the WSF with CScript.exe, it complains about improper tag matching. If I open the file in notepad, make no changes, then save the file, the script will execute just fine.

      I have tried pushing the file to the browser using the:
      <cfcontent type="text/scriptlet">
      <cfheader name="Content-Disposition" value="attachment; filename=#Filename#.wsf">
      <cffile action="read" file="#OSPath#\TempWSF\#Filename#.wsf" variable="WSFContent">

      and I've used both mime types: text/scriptlet and text/plain with the same results as the file created on the web server.

      Any ideas how I can prevent having to open each WSF with notepad and resaving them all?

        • 1. Windows Script Generation Problems
          Grizzly9279 Level 1
          I've done quite a bit of work with WSF's (using VBScript mostly), and ColdFusion, so I'm hoping I can help here.

          The behavior you're describing is pretty odd, and all I can tell you is that it "smells" like a new-line related issue. I noticed you're using the "fixnewline" attribute, is there a specific reason for this? I would first try removing that attribute (or set it to "no"), and see if the problem persists.

          Secondly, have you tried buffering your output? Building a file in the way that you are (write, append, append, append, append...) isn't the most efficient way to approach it, and I've experienced some quirky issues with ColdFusion in the past, where multiple cffile (or cflog) in a row can result in some unreliable results. (lines written to the file in the wrong order for example)

          I would prefer you built the entire file-contents into a single string var, and then write that string to disk in one round trip, like so: