473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

help with hta programing

Hi,
I am sorry if this is not the most appropriate group to ask this in
(if not, please
point me in the right direction). I am following examples from this page,
http://www.vbwm.com/articles/2002/abarfield/hta01/

I have a some questions about Figure 5 (below). This hta file will view a
text file when a button is pushed.

1. Why do the paths require double '\' ? like
F:\documents\random text\realpongfaq.txt needs to be
F:\\documents\\random text\\realpongfaq.txt

2. How would i store the path as a variable instead
of putting it directly in the BUTTON tag

<BUTTON style= "border: 1px outset; width:100px"
onClick="ReadFile('c:\\autoexec.bat');">
Read File
</BUTTON>

instead do something like (which doesn't work)
var filePath = 'F:\\documents\\random text\\realpongfaq.txt'

<BUTTON style= "border: 1px outset; width:100px"
onClick="ReadFile(filePath);">
Read File
</BUTTON>

3. How can I creat a File Field form to select the file instead
of hard coding the path? similar to this to select the file.
http://largebuttons.com/fileupload.htm

Thanks,
Chuck


Figure 5

<HTML>

<HEAD>
<TITLE>Read File</TITLE>
<HTA:APPLICATION
ID = "oApp"
APPLICATIONNAME = "My HTA App 2001"
BORDER = "thick"
CAPTION = "yes"
ICON = "app.ico"
SHOWINTASKBAR = "yes"
SINGLEINSTANCE = "yes"
SYSMENU = "yes"
WINDOWSTATE = "normal"
SCROLL = "yes"
SCROLLFLAT = "yes"
VERSION = "1.0">
<SCRIPT Language="JScript">

function ReadFile(filename)
{
var fso, f;
var ForReading = 1;
fso = new ActiveXObject(
"Scripting.FileSystemObject");

f = fso.OpenTextFile(filename,
ForReading);
txtbox.innerText = f.ReadAll();
}

</SCRIPT>

</HEAD>

<BODY scroll="no" style=
"background:buttonface; color:buttontext;
border:0px; padding:0px; margin:0px">

<table cellspacing=0 cellpadding=0
border=0 width=100% height=100%>

<tr>
<td height=4></td>
</tr>

<tr>
<td height=20>
<BUTTON style=
"border: 1px outset;
width:100px"
onClick="ReadFile(
'c:\\autoexec.bat');">
Read File</BUTTON>
</td>
</tr>
<tr>
<td height=4></td>
</tr>
<tr>
<td>
<div id="txtbox" style=
"overflow:scroll;
background:window;
border: 1px inset;
font: 8pt Arial; width:100%;
height:100%"></div>
</td>
</tr>

</table>

<OBJECT ID="oShell" CLASSID=
"clsid:13709620-C279-11CE-
A49E-444553540000">
</OBJECT>

</BODY>

</HTML>
Jul 20 '05 #1
8 7424
In article <cE*******************@fe2.texas.rr.com>, chuck@no-
spam.mail.utexas.edu enlightened us with...

1. Why do the paths require double '\' ? like
F:\documents\random text\realpongfaq.txt needs to be
F:\\documents\\random text\\realpongfaq.txt

The computer eats a slash as a special character. Putting another slash
in front escapes it so it doesn't get eaten.
2. How would i store the path as a variable instead
of putting it directly in the BUTTON tag

I had a real problem with this.
The solution was convoluted and had to do with some obscure issue I
don't quite remember.

Searching the archives, I found my old post.

--------
vbscript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Run Executable HTA</TITLE>
</HEAD>
<body bgcolor=#565656>
<script language="VBScript" type="text/vbscript">
set oShell = CreateObject("WScript.Shell")
oShell.run """C:\Program Files\Microsoft Office\Office\Excel.exe""",1
window.close
</script>
</BODY>
</HTML>
This worked with javascript.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Run Executable HTA</TITLE>
</HEAD>
<body bgcolor=#565656>
<script language="javascript" type="text/javascript">
var oShell = new ActiveXObject("WScript.Shell");
var prog = "C:\\Program Files\\Microsoft Office\\Office\\Excel.exe";
oShell.run ('"'+prog+'"',1);
window.close();
</script>
</BODY>
</HTML>

---------------------
3. How can I creat a File Field form to select the file instead
of hard coding the path? similar to this to select the file.
http://largebuttons.com/fileupload.htm


Dunno. :)
Don't use HTAs enough.

If you don't mind using vbscript or know how to convert it to JScript,
this group is pretty good.
microsoft.public.scripting.vbscript
--
--
~kaeli~
Kill one man and you are a murderer. Kill millions and you
are a conqueror. Kill everyone and you are God.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2

"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <cE*******************@fe2.texas.rr.com>, chuck@no-
spam.mail.utexas.edu enlightened us with...

1. Why do the paths require double '\' ? like
F:\documents\random text\realpongfaq.txt needs to be
F:\\documents\\random text\\realpongfaq.txt


The computer eats a slash as a special character. Putting another slash
in front escapes it so it doesn't get eaten.


This is true within a JavaScript.
Not true within a VBScript.
Both Scripting languages can coexist within the same HTA and can call each others subs(vb) and
functions(vb/js).

The following utilizes the VB MsgBox to capture a result of a keypress.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<HTA:APPLICATION ID="oHTA"
APPLICATIONNAME="AltDialog"
CAPTION="yes"
SYSMENU="yes"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
SHOWINTASKBAR="no"
SINGLEINSTANCE="yes"
SCROLL="NO"
BORDER="thin"
BORDERSTYLE="dialog"
VERSION="1.0"
WINDOWSTATE="normal"
ICON="time.ico">
<SCRIPT LANGUAGE="VBSCRIPT">

option Explicit

Public Function Getmsgbox(msgIN)
Select Case( msgbox( msgIN ,vbYesNoCancel))
Case vbYes
Getmsgbox="YES"
Case vbNo
Getmsgbox="NO"
case else
Getmsgbox="Cancel"
end select
End Function
</SCRIPT>
<SCRIPT language="jscript">
<!-- Begin Author Info For HTA

function ClickMe(strIN)
{
var result=GetMsgbox(strIN);
alert(result + ' was pressed');

}
// End -->
</Script>
</HEAD>
<body bgcolor=#BBBBBB >
<input type="text" id="txtMsg" length="40">
<input type="button" value="Click" onclick="ClickMe(txtMsg.value)">
</BODY>
</HTML>


2. How would i store the path as a variable instead
of putting it directly in the BUTTON tag


I had a real problem with this.
The solution was convoluted and had to do with some obscure issue I
don't quite remember.

Searching the archives, I found my old post.

--------
vbscript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Run Executable HTA</TITLE>
</HEAD>
<body bgcolor=#565656>
<script language="VBScript" type="text/vbscript">
set oShell = CreateObject("WScript.Shell")
oShell.run """C:\Program Files\Microsoft Office\Office\Excel.exe""",1
window.close
</script>
</BODY>
</HTML>
This worked with javascript.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Run Executable HTA</TITLE>
</HEAD>
<body bgcolor=#565656>
<script language="javascript" type="text/javascript">
var oShell = new ActiveXObject("WScript.Shell");
var prog = "C:\\Program Files\\Microsoft Office\\Office\\Excel.exe";
oShell.run ('"'+prog+'"',1);
window.close();
</script>
</BODY>
</HTML>

---------------------

3. How can I creat a File Field form to select the file instead
of hard coding the path? similar to this to select the file.
http://largebuttons.com/fileupload.htm


Dunno. :)
Don't use HTAs enough.

If you don't mind using vbscript or know how to convert it to JScript,
this group is pretty good.
microsoft.public.scripting.vbscript
--
--
~kaeli~
Kill one man and you are a murderer. Kill millions and you
are a conqueror. Kill everyone and you are God.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #3
> > > 1. Why do the paths require double '\' ? like
F:\documents\random text\realpongfaq.txt needs to be
F:\\documents\\random text\\realpongfaq.txt
The computer eats a slash as a special character. Putting another slash
in front escapes it so it doesn't get eaten.
This is true within a JavaScript.
Not true within a VBScript.
Both Scripting languages can coexist within the same HTA and can call each others subs(vb) and functions(vb/js).


To be clear here: The Windows File System (which both JScript and VBScript can
access) uses single backslashes to partition pathnames.

JScript (like all C-family languages) uses backslash as an escape character in
strings. Backslash was chosen for this purpose because it is rarely used.
Unfortunately, Paul Allen made a horrendously bad choice when he chose \ for the
pathname partition character for MS-DOS. This, like many other inexcusable
design errors, was carried forward into Windows.

The JScript compiler sees the source text

"F:\documents\random text\realpongfaq.txt"

as containing the escape sequences

\d \r \r

To avoid that wrong interpretation, the backslashes themselves must be escaped.

"F:\\documents\\random text\\realpongfaq.txt"

Strings that come from the DOM or from the user do not need to be escaped.

http://www.crockford.com/javascript/javascript.html
Jul 20 '05 #4
In article <s5********************@comcast.com>, "MikeB"
<m.byerleyATVerizonDottieNettie> enlightened us with...


The computer eats a slash as a special character. Putting another slash
in front escapes it so it doesn't get eaten.


This is true within a JavaScript.
Not true within a VBScript.


No, in vbscript, it eats double quotes. :)
--
--
~kaeli~
A man needs a mistress... just to break the monogamy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #5

"Douglas Crockford" <no****@covad.net> wrote in message
news:cf***************************@msgid.meganewss ervers.com...
> 1. Why do the paths require double '\' ? like
> F:\documents\random text\realpongfaq.txt needs to be
> F:\\documents\\random text\\realpongfaq.txt The computer eats a slash as a special character. Putting another slash
in front escapes it so it doesn't get eaten.
This is true within a JavaScript.
Not true within a VBScript.
Both Scripting languages can coexist within the same HTA and can call each

others subs(vb) and
functions(vb/js).


To be clear here: The Windows File System (which both JScript and VBScript can
access) uses single backslashes to partition pathnames.

JScript (like all C-family languages) uses backslash as an escape character in
strings. Backslash was chosen for this purpose because it is rarely used.
Unfortunately, Paul Allen made a horrendously bad choice when he chose \ for the
pathname partition character for MS-DOS. This, like many other inexcusable
design errors, was carried forward into Windows.


Well, going from Dos 1.0, which had no directory structure (progs and data all in the root of the
boot drive) to dos 2.0 which had directories, I would guess they fancied themselves pretty smart
cookies at the time.. :^)
The JScript compiler sees the source text

"F:\documents\random text\realpongfaq.txt"

as containing the escape sequences

\d \r \r

To avoid that wrong interpretation, the backslashes themselves must be escaped.

"F:\\documents\\random text\\realpongfaq.txt"

Strings that come from the DOM or from the user do not need to be escaped.

http://www.crockford.com/javascript/javascript.html

Jul 20 '05 #6
kaeli <ti******@NOSPAM.comcast.net> wrote:
In article <cE*******************@fe2.texas.rr.com>, chuck@no-
spam.mail.utexas.edu enlightened us with...
<snip />
3. How can I creat a File Field form to select the file instead
of hard coding the path? similar to this to select the file.
http://largebuttons.com/fileupload.htm


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Run Executable HTA</TITLE>
<script language="javascript" type="text/javascript">
function RunCmd(cmdLine)
{
var oShell = new ActiveXObject("WScript.Shell");
oShell.Run ('"' + cmdLine + '"',1);
}
</script>
</HEAD>
<body>
<form>
<input name="SelectFile" type=file></input>
<br/>
<button onclick="RunCmd(this.form.SelectFile.value)">Run</button>
</form>
</BODY>
</HTML>

Regards,
Steve
Jul 20 '05 #7

"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <cE*******************@fe2.texas.rr.com>, chuck@no-
spam.mail.utexas.edu enlightened us with...

1. Why do the paths require double '\' ? like
F:\documents\random text\realpongfaq.txt needs to be
F:\\documents\\random text\\realpongfaq.txt

The computer eats a slash as a special character. Putting another slash
in front escapes it so it doesn't get eaten.
2. How would i store the path as a variable instead
of putting it directly in the BUTTON tag


I had a real problem with this.
The solution was convoluted and had to do with some obscure issue I
don't quite remember.

Searching the archives, I found my old post.

--------
vbscript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Run Executable HTA</TITLE>
</HEAD>
<body bgcolor=#565656>
<script language="VBScript" type="text/vbscript">
set oShell = CreateObject("WScript.Shell")
oShell.run """C:\Program Files\Microsoft Office\Office\Excel.exe""",1
window.close
</script>
</BODY>
</HTML>
This worked with javascript.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Run Executable HTA</TITLE>
</HEAD>
<body bgcolor=#565656>
<script language="javascript" type="text/javascript">
var oShell = new ActiveXObject("WScript.Shell");
var prog = "C:\\Program Files\\Microsoft Office\\Office\\Excel.exe";
oShell.run ('"'+prog+'"',1);
window.close();
</script>
</BODY>
</HTML>

---------------------

3. How can I creat a File Field form to select the file instead
of hard coding the path? similar to this to select the file.
http://largebuttons.com/fileupload.htm


Also, if you have VB, you could write a wrapper ActiveX around the MsComDlg control and have an
actual File Open dialog box. There are many freebies of this on the web, but most people wouldn't
trust a 3rd party control and it is little work to roll your own. It adds a nice touch on your in
house app and of course could be reused many times...


Dunno. :)
Don't use HTAs enough.

If you don't mind using vbscript or know how to convert it to JScript,
this group is pretty good.
microsoft.public.scripting.vbscript
--
--
~kaeli~
Kill one man and you are a murderer. Kill millions and you
are a conqueror. Kill everyone and you are God.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #8
On Thu, 15 Jan 2004 10:39:08 -0800, "Douglas Crockford"
<no****@covad.net> wrote:
To be clear here: The Windows File System (which both JScript and VBScript can
access) uses single backslashes to partition pathnames.


One thing to note is that the FSO (aswell as many windows
applications/components) allow you to use / as an alternative to \ so
you can do:

fso=new ActiveXObject("Scripting.fileSystemObject");
alert(fso.fileExists("C:/windows/fonts/arial.ttf"));

This may not be all windows O/S's so test on your own machine of
course!

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Vlado | last post by:
I have db2 7.2 on Win 2000, programing MS VB6.0 I update 1 field on 600 records - successfully, but if i update more then 600 records then i have err. mesage SQL0952N Processing was cancelled...
2
by: cyshao | last post by:
How to reset Router by programing? For some resean, we need usually reset our Router. Now, we have to Reset Router manually(shot down and reopen). Are there any method to control and reset...
2
by: continium | last post by:
I have been learning python during the past weeks and I have been able to program some interesting things. Python is my first and only programing language from which I wish to enter the programing...
13
by: Xah Lee | last post by:
there's this one i can't figure out. I'm trying to kick out image.google.com's top frame when it goes to my page. If you go to http://images.google.com/images?q=milk+tits click on the page...
12
by: Xah Lee | last post by:
Frameset Infinity! http://xahlee.org/js/frame2/frameset.html HTML Frame tutorial + Infinity! http://xahlee.org/js/frame/0.html Xah xah@xahlee.org ∑ http://xahlee.org/
3
by: warhero721 | last post by:
HI. First i like to point out i suck at programing. All i realy whant to know is how do i git my site orginized.I whant to know how to do somthing like this Chatroom fourm sighn up event...
12
by: Xah Lee | last post by:
Of Interest: Introduction to 3D Graphics Programing http://xahlee.org/3d/index.html Currently, this introduction introduces you to the graphics format of Mathematica, and two Java Applet...
8
by: SanjaiGandhi | last post by:
Hi ...i am new to programing....pls help to overcome this program.. The Program is..: if a = 557..using for loop or while or dowhile ..we have to get the answer for 5+5+7..that is what ever...
15
by: Xah Lee | last post by:
On Java's Interface Xah Lee, 20050223 In Java the language, there's this a keyword “interface”. In a functional language, a function can be specified by its name and parameter specs....
2
by: sengpg345 | last post by:
hi everybody. i have a project in colage for messanger but i haven't idea of socket programing in c#.net . so plz give me the guidence i socket programing. if u have row matirial or tutorial then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.