Note that there are some explanatory texts on larger screens.

plurals
  1. POCreateTextFile not working when hta is set to open as notepad by default (javascripting)
    primarykey
    data
    text
    <p>I'm getting this really weird problem when I try to create a text file using javascripting and a hta file.</p> <p>This is the code broken down to its basics:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;script&gt; alert("creating file"); var fso = new ActiveXObject("Scripting.FileSystemObject"); var s = fso.CreateTextFile("test.txt", true); s.WriteLine("it works"); s.Close(); alert("file created"); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is in a hta file called "Untitled.hta" As long as I set the Open With > Choose Default Program to "Microsoft (R) HTML Application Host" and then open the hta file the text file gets created just fine.</p> <p>But if I set Open With > Choose Default Program to "Notepad" and then Open With "Microsoft (R) HTML Application Host" the text file doesn't get created.</p> <p>Does anyone know why this is happening? It normally wouldn't matter but if a client has hta files set to open as notepad by default then my hta file wont work as intended.</p> <p>To complicate things further replace</p> <pre><code>var s = fso.CreateTextFile("test.txt", true); </code></pre> <p>with</p> <pre><code>var s = fso.CreateTextFile("TestFolder/test.txt", true); </code></pre> <p>and where the hta file is located create a folder called "TestFolder"</p> <p>If you do the same thing as you did before, having it set to Notepad as default gives the Path not found error (but it works fine if the default is set to Microsoft (R) HTML Application Host)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload