Solved

HTA Application Desktop

Posted on 2009-06-28
2
878 Views
Last Modified: 2013-11-17
I am trying to write my first HTA application.  

I want it to do a very simple task, open the window and have a close/exit button.
When the user click the button, it writes the word "FINISHED" to a local text file on the
hard drive and close the program.   I know this is very simple, but I have never written a HTA application before.


<html> 

<head> 

<title>Modal Example</title>

<HTA:APPLICATION

     Sysmenu="no" 

     APPLICATIONNAME="MainModal">

</head>
 

<script language="VBScript"> 
 

Sub ExitProgram

  Dim fso

  Set fso = CreateObject("scripting.filesystemobject")

  Dim txtFile as String

  Dim txtstr as TextStream

  txtFile = "C:\TheAutomoator\HotFile.txt"

  Set txtstr = fso.CreateTextFile(txtFile,True)

  txtstr.writeline "Finished"

  txtstr.Close

  window.close()

End Sub

</script> 

<body> 

<input id=runbutton type="button" Value="Exit when Finished" onClick="ExitProgram">

</body> 

</html>

Open in new window

0
Comment
Question by:begarrison
2 Comments
 
LVL 3

Accepted Solution

by:
astroviper earned 125 total points
ID: 24733012
"VBScript is a typeless language. This means that variables cannot be restricted to a single data type. VBScript does not allow you to specify in advance that a particular variable can hold only a particular kind of data. Instead, VBScript uses a single kind of variable, known as a variant, which can store any kind of data."
http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_eves.mspx?mfr=true

Line 14 and 15 should read:
  Dim txtFile
  Dim txtstr

Also ensure that the folder where you are going to save your text file already exists.
0
 

Author Closing Comment

by:begarrison
ID: 31597748
The response was very helpful and solved the problem.  I have been a member for some time and finally used the service.  i know why I joined.
Thanks.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now