RSS

Tag Archives: hta

HTA: Adding IIS FTP Virtual Directories

I wrote this HTA script because I wanted simple GUI to handover to my 1st level support. MS IIS do come with some Vbscripts to manage iis ftp virtual directories, but it does not allow you to add ftp vdir pointing to unc paths, also in our setup, we have write access to the ftp vdir, which was not in the MS IIS script.

  • We have 3 FTP servers which we manage in TKY, HKG and SGP.
  • The script allows the user to choose which FTP server to add new VDir to.
  • Remember that you must change the SiteID for.
  • Also the server name is based on FTP<Site>, e.g. FTPHKG, you should change it based on your own naming convention

Read the rest of this entry »

 
6 Comments

Posted by on March 4, 2008 in Scripts, Windows

 

Tags: ,

HTA Scripting: displaying output

One of the most frustrating issue facing vbscripters who is moving over to HTA scripting must be the seemingly lack of ability for the form to display its output as you code runs.

The first attempt most scripter will do is to define a spanID and try to write the output to it. For example:

thisText = “Starting script now…”
Do loop
Do something….
thisText = thisText & <BR> & “doing something now… ”
SpanID.InnerHTML = thisText
if done then Exit do
Loop

One would reasonably expect the dialog window to continuously update itself with the output text. However, we would quickly realise that the output come appears only after the entire loop has completed and the subprocedure ended or you may a call to a msgbox or other output functions. From the UI, it appears that the form hangs (as it process the loop) and then outputs the entire output after the delay.

One of the MS Article, Updating the Display During Lengthy Operations, has this to say:

Let’s imagine that the script above did execute as the author intended, and the user saw the count value on the display rise from 0 to 500. In this hypothetical situation, every time the display updated, events such as onresize and onchange would be generated. Should these events be handled in script immediately? Probably not as that could have effects on the script that was running in the original function—if a global variable’s value was changed, for example. An alternative would be to queue up all the events to be processed when the original function finally executed, but this too has a number of problems and seems far from efficient. It is useful for script to be able to execute and decide how things should be on the screen and then have all updates occur simultaneously when the function completes, rather than having a gradual display change on different parts of the screen.

Found a solution which uses a hidden cmd window to force the form to update:

Set WSHShell = CreateObject(“WScript.Shell”)
thisText = “Starting script now…”
Do loop
Do something….
thisText = thisText & <BR> & “doing something now… ”
SpanID.InnerHTML = thisText
WSHShell.run “%comspec% /c “, 0, true
if done then Exit do
Loop

Tested the solution and viola! the output comes alive!

 
Leave a comment

Posted by on January 2, 2008 in Scripts, VBScripts, Windows

 

Tags:

HTA Scripting: sleep function

Okay, for all the HTA newbies, the sleep function much be one of the most searched piece of code (the other is how to write a console-like output). Having been a full-fledged vbscript scripter, we don’t think much about the wscript.sleep method until we try to use it on a HTA script.. it does not work!

The Microsoft Scripting center’s solution for this either to use the DHTML method setTimeOut. I don’t really like the solution because it doesn’t really “sleep” the application. Rather, it sets a time delay before the application runs. The sample application is too simplistic. It calls a stub which creates a timer to launch the application at the specified delay time and passes control back to the form.

But what if I have a process that needs to pause a few seconds before it continues? I don’t think that the setTimeOut method can address this well enough.

There are others out there that recommends 3rd party addon, but wanted a more native solution.

After searching for a while, I chanced upon this little workaround in Rube Goldberg Memorial Scripting Page. Its not sometime I really like because it depends on the ping command, but it presents a better workaround than the setTimeout method for what I want to do.

Msgbox now

ccSleep 15
MsgBox now

Sub ccSleep(seconds)
set oShell = CreateObject(“Wscript.Shell”)
cmd = “%COMSPEC% /c ping -n ” & 1 + seconds & ” 127.0.0.1>nul”
oShell.Run cmd,0,1
End Sub

 
Leave a comment

Posted by on January 2, 2008 in Scripts, VBScripts, Windows

 

Tags: