'On Error Resume Next' and 'On Error GoTo 0' work just fine inside HTA
hosted vbscript.
--
Michael Harris
Microsoft.MVP.Scripting
it is for jscript: window.onerror = function(){return true}
for vbscript, use :
On Error Resume Next
at the top of script.
Good Luck, Ayush.
--
VBScript Language Reference : http://snipurl.com/VBScript_Reference
No I've tried on error resume next. Works fine in a regular vbScript
but IE is what throws up the error (although it's a vbscript related
error). I need to try to find a way for IE to disregard the error and
continue processing the script.
I have the opposite problem. Sometimes I access a File which does not exist or a
txt1.value which is not in the page and nothing happens. No error is raised even without
On Error.
This hta changes the ForteAgent news server. When I get connected with a different
provider I run this and choose the appropriate server (the values are in the option box at
the end of the code).
If the agent.ini file is in .\data the program works fine: changes the "newsserver" line
and exits. If it doesn't find the agent.ini file, nothing happens and the program doesn'
terminate. The processing doesn't arrive to the window.close line, but no error is raised
in the fso.Movefile or fso.OpenTextFile lines.
What tells the script to hang or to continue? For what kind of errors?
Thank you.
Giovanni.
<HTML>
<HTA:APPLICATION ID="Cambia Server Free Agent"
APPLICATIONNAME="CambiaServerAgent"
SCROLL="yes" SINGLEINSTANCE="no" BORDER="thin"
BORDERSTYLE="raised" CONTEXTMENU="no"
SELECTION="no" WINDOWSTATE="normal"
CAPTION="yes" MINIMIZEBUTTON="yes"
icon="agent.exe"
MAXIMIZEBUTTON="yes" SHOWINTASKBAR="yes" SYSMENU="yes">
<HEAD>
<TITLE>Cambia Server Free Agent - Cenati Giovanni</TITLE>
<style>
BODY {
background-color: #ffcc99;
font-family: times new roman;
font-size: 9pt;
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
margin-bottom: 10px;}
</style>
<META http-equiv=Content-Type content="text/html; charset=utf-8"><script
id=clientEventHandlersVBS language=vbscript>
<!--
Sub Window_Onload
'resize parent window
self.Focus()
self.ResizeTo 400,250
self.MoveTo 50,50
End Sub
Sub Button1_onclick
'Trovo il nome della directory in cui c'è questo programma.
Percorso= left(document.location, instrrev( document.location,"/"))
Percorso=right(Percorso,len(Percorso)-8)
Percorso= replace(Percorso, "/", "\")
percorso=percorso & "Data\"
Const ForReading = 1 'Open a file for reading only. You can't write to this file
Const ForWriting = 2 'Open a file for writing
q= chr(34) 'virgolette
Set fso = CreateObject("Scripting.FileSystemObject")
on error resume next
fso.DeleteFile percorso & "AGENT.INI.BAK"
on error goto 0
fso.MoveFile percorso & "AGENT.INI",percorso & "AGENT.INI.BAK"
set source = fso.OpenTextFile(percorso & "AGENT.INI.BAK",ForReading)
set dest= fso.OpenTextFile(percorso & "AGENT.INI",ForWriting,TRUE)
Do While source.AtEndOfStream <> True
riga = source.ReadLine
if instr(1,riga,"NewsServer=")>0 then
dest.writeline "NewsServer=" & q & select1.value & q
else
dest.writeline riga
end if
Loop
source.Close
dest.close
window.close
End Sub
-->
</script>
</HEAD>
<BODY>?
Modifica News Server di Free Agent
<p><select id=SELECT1 multiple size=4 name=Server>
<option value=powernews.libero.it selected>Libero</option>
<option value=news.tin.it>Alice</option></select>
</p>
<p>
<input id=Button1 type=button value=Modifica name=Modifica></p>
(c) Cenati Giovanni 2007 - <a
href=http://digilander.libero.it/Cenati>http://digilander.libero.it/Cenati</a>
</BODY></HTML>
--
Giovanni Cenati (Aosta, Italy)
Write to user "Reventlov" and domain at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
Internet Options (inetcpl.cpl) > Advanced :
Uncheck "Disable script debugging",
Tick "Display a notification about every script error"
Click OK
Good Luck, Ayush.
--
XP-Tips [Add a Map Drive button to the toolbar] :
http://www.microsoft.com/windowsxp/using/setup/tips/advanced/mdbutton.mspx