Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-05-2014, 01:58 AM
krillik krillik is offline
Registered User
 
Join Date: May 2013
Posts: 13
Dynamic HTA

Hello guys, I'm am trying to figure out how to create an HTA from within vbscript (like the ie example) then take input from that and use it to run commands with crt.screen.send. I know it can be dome because some guys at IT have done it, the problem is they built the scripts with object oriented programming. I am not able to trace through all the scripts to determine how it's done. Guys at IT were no help. Basically it want each script to have the HTA info then pass it on to the main script to build the UI. Anyone done that here? I tried to search but "HTA" is too short. Thanks!
Reply With Quote
  #2  
Old 05-05-2014, 11:45 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi krillik,

We don't have any experience with building HTA, but there might be others who have (your IT team, for example ). If anyone in the general forum community has any expertise in this area, feel free to chime in.

You can use Google technology to search the forums for terms that are smaller than the forum search will allow. For example, site:forums.vandyke.com HTA
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 05-05-2014, 11:52 AM
krillik krillik is offline
Registered User
 
Join Date: May 2013
Posts: 13
rtb, I appreciate your reply. I tried to google so many things on the internet in general and I could not find anything the way I wanted to do it. So I got the bright idea to google a certain piece of the code, the mshta process that runs htas.

I found this link http://gallery.technet.microsoft.com...cript-36122f57 and it does EXACTLY what I want.

I think its a better way to do things than to use the IE object hack as it doesnt run into the security restrictions. The code needs to be modified to work with SecureCRT but I was able to do that fairly quickly(wsh.sleep <to> crt.sleep, etc.). I hope that helps people who have also been trying to do that!
Reply With Quote
  #4  
Old 05-05-2014, 12:03 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi krillik,

I am glad to hear that you found a solution. Thanks for posting a reference.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #5  
Old 05-08-2014, 10:50 AM
dluther dluther is offline
Registered User
 
Join Date: Feb 2013
Posts: 4
Quote:
Originally Posted by krillik View Post
rtb, I appreciate your reply. I tried to google so many things on the internet in general and I could not find anything the way I wanted to do it. So I got the bright idea to google a certain piece of the code, the mshta process that runs htas.

I found this link http://gallery.technet.microsoft.com...cript-36122f57 and it does EXACTLY what I want.

I think its a better way to do things than to use the IE object hack as it doesnt run into the security restrictions. The code needs to be modified to work with SecureCRT but I was able to do that fairly quickly(wsh.sleep <to> crt.sleep, etc.). I hope that helps people who have also been trying to do that!
Would you mind pasting your example code here so people like me could possibly convert existing scripts?

My latest update to SecureCRT does not work at all with the latest IE...
Reply With Quote
  #6  
Old 05-08-2014, 01:56 PM
krillik krillik is offline
Registered User
 
Join Date: May 2013
Posts: 13
Code

As requested here is the code I modified, I am no expert but it does not seem to thrown any errors or anything when I run it.

Code:
sMessage = "<font color=red><b>This is your important message</b></font>"
sControl = "<input type=button id=Btn1 value=OK onclick='done.value=""clicked""'>"
sHTMLCode = sMessage & "<hr>" & sControl
'
with HTABox("lightgrey", 125, 300, 400, 500)
  .document.title = "My Message Box"
  .msg.innerHTML = sHTMLCode
  Timeout = 3000 ' milliseconds
  do until .done.value = "clicked" or (n > TimeOut): crt.sleep 50 : n=n+50 : loop
  if .done.value = "clicked" then 
    crt.Dialog.Messagebox("User pressed button")
  else
    crt.Dialog.Messagebox("Timed out")
  end if
  .done.value = true
  .close
end with
'
' Author Tom Lavedas, June 2010
Function HTABox(sBgColor, h, w, l, t)
Dim IE, HTA

  randomize : nRnd = Int(1000000 * rnd)
  sCmd = "mshta.exe ""javascript:{new " _
       & "ActiveXObject(""InternetExplorer.Application"")" _
       & ".PutProperty('" & nRnd & "',window);" _
       & "window.resizeTo(" & w & "," & h & ");" _
       & "window.moveTo(" & l & "," & t & ")}"""
'
  with CreateObject("WScript.Shell")
    .Run sCmd, 1, False
    do until .AppActivate("javascript:{new ") : crt.sleep 10 : loop
  end with ' WSHShell
'
  For Each IE In CreateObject("Shell.Application").windows
    If IsObject(IE.GetProperty(nRnd)) Then
      set HTABox = IE.GetProperty(nRnd)
      IE.Quit
      HTABox.document.title = "HTABox"
      HTABox.document.write _
               "<HTA:Application contextMenu=no border=thin " _
             & "minimizebutton=no maximizebutton=no sysmenu=yes />" _
             & "<body scroll=no style='background-color:" _
             & sBgColor & ";font:normal 10pt Arial;" _
             & "border-Style:outset;border-Width:3px'" _
             & "onbeforeunload='vbscript:if not done.value then " _
             & "window.event.cancelBubble=true:" _
             & "window.event.returnValue=false:" _
             & "done.value=true:end if'>" _
             & "<input type=hidden id=done value=false>" _
             & "<center><span id=msg>&nbsp;</span><center></body>"
      Exit Function
    End If
  Next
'
' I can't imagine how this line can be reached, but just in case
  MsgBox "HTA window not found."
End Function

Last edited by krillik; 05-08-2014 at 02:03 PM. Reason: Made a mistake in code, removed it
Reply With Quote
Reply

Tags
dialog , hta


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 07:23 AM.