Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


HTA Question

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,31659
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> HTA Question
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 HTA Question - 2/28/2006 3:44:30 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Hey guys,

Here is a question that I am sure someone has done or knows how to do and I would love some help.

I would like to make a HTA that lists a number of Batch files with a tick box or some such selectable option beside each and something like a run button at the bottom that runs the selected Batch files.

Can this be done, and anyone have any examples of how this was done.

Thanks again for any help you guys can provide.


Tim
 
 
Post #: 1
 
 RE: HTA Question - 2/28/2006 7:22:50 PM   
  ginolard


Posts: 1024
Score: 21
Joined: 8/10/2005
Status: offline
Yes it can be done and an HTA is ideal for it.

You could use tickboxes or a dropdown listbox for the batch files.  I would recommend getting hold of the HTA Helpomatic from the MS script center.  It can create simple blocks of HTML/script code for you

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to Navarre)
 
 
Post #: 2
 
 RE: HTA Question - 2/28/2006 9:09:30 PM   
  rOOs


Posts: 63
Score: 0
Joined: 2/28/2006
From: Switzerland
Status: offline
The HTML:
<input type='checkbox' name='test'> Select this one...

<input type='button' name='OKButton' value=' Test this out . . . ' onclick="DoIt">

the Code:

Sub DoIt
If document.All.Item("test").Checked Then
   'do it
End If
End Sub

Each input its own name, and each if checked refernces to that name...

something like this?

(in reply to ginolard)
 
 
Post #: 3
 
 RE: HTA Question - 3/1/2006 11:06:05 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Thanks for that I got the test working just fine.

Though I was trying to put in a piece of code to test another of my scripts and I think I am not doing this right.  Because I when I click the button to do it, I am getting the following - on line 10 char 2 Object required 'Wscript'.  Now this script works fine by itself but am I doing something when it goes into here.

This is how I had it looking -

<html>
<head>
  <hta:application id = "mcomms" />
   <title>Test Checkbox</title>
   <meta http-equiv = "content-script-type" content = "text/vbscript"/>
   <script language = "VBScript" type = "text/vbscript" >
sub doit
If document.All.Item("test").Checked Then
strComputer = "."
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"   
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Visible = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = inputbox("Please input the directory you wish to display")
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
   Wscript.Echo objFile.Name
   strHTML = strHTML & objFile.Name & "<BR>"
Next
objExplorer.Document.Body.InnerHTML = strHTML
End If
End Sub
  </script>
</head>
<IMAGE SRC = "C:\Pictures\World.jpg" align = "center">
<h1 align="center"> Pagan Inc</h1>
<body>
<input type='checkbox' name='test'> Select this one...
<input type='button' name='OKButton' value=' Test this out . . . ' onclick="DoIt">
  <o:p>&nbsp;</o:p></p>
      <input type = "BUTTON" value = " Exit " onclick ="self.close()">
</button></body>
</html>




(in reply to rOOs)
 
 
Post #: 4
 
 RE: HTA Question - 3/1/2006 6:40:49 PM   
  ginolard


Posts: 1024
Score: 21
Joined: 8/10/2005
Status: offline
You don't need the Wscript.Createobject, just CreateObject will do.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to Navarre)
 
 
Post #: 5
 
 RE: HTA Question - 3/1/2006 8:13:34 PM   
  rOOs


Posts: 63
Score: 0
Joined: 2/28/2006
From: Switzerland
Status: offline
quote:

ORIGINAL: ginolard

You don't need the Wscript.Createobject, just CreateObject will do.


This is because of the context it is run under... the hta doesn't run in the wscript context. so wscript.sleep won't work either...

btw: Wscript.sleep can be emulated with a timer...

(in reply to ginolard)
 
 
Post #: 6
 
 RE: HTA Question - 3/1/2006 8:15:30 PM   
  rOOs


Posts: 63
Score: 0
Joined: 2/28/2006
From: Switzerland
Status: offline
quote:

<IMAGE SRC = "C:\Pictures\World.jpg" align = "center">


Try to make relative paths for the images such as ".\pic\World.jpg"

better for distribution... :-)

(in reply to Navarre)
 
 
Post #: 7
 
 RE: HTA Question - 3/2/2006 8:50:46 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Thanks for the help guys, I know to put in the relative path but at this stage it really does not need I just wanted to put in something for my testing.

I took out the other wscript line further down and it works just fine.

Now I am not sure how to do this nex small bit, if I wanted to added another script do I just out it in as another sub or do I have to do something different. 

< Message edited by Navarre -- 3/2/2006 8:59:04 AM >

(in reply to rOOs)
 
 
Post #: 8
 
 RE: HTA Question - 3/2/2006 6:53:29 PM   
  rOOs


Posts: 63
Score: 0
Joined: 2/28/2006
From: Switzerland
Status: offline
Every portion of Script you have to run seperately you put in a seperate sub with a seperate unique name that shows what the sub makes..

repeatly used tasks you also put into a sub, so you can call it when you need it.


is this what you asked for?
sorry for my bad english (i am swiss)

(in reply to Navarre)
 
 
Post #: 9
 
 RE: HTA Question - 3/5/2006 9:01:06 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
So here is a question, if I wanted to put in bat file what is the command to make one of the options run a batch file.

Or would it be a better (at least to me) to make it more modular and make each a call to an external script.

So I wanted to go that way, do I have to make each tick box button call an external script or batch file.

(in reply to rOOs)
 
 
Post #: 10
 
 RE: HTA Question - 3/6/2006 12:51:25 AM   
  Country73


Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
When a particular option is selected it should run a certain Sub (or function) for that option.
Inside the option you could just put in:

oShell.Run <batch / script path>,0,True


oShell is just what I normally have setup in my scripts: Set oShell = CreateObject("Wscript.Shell")

0, True in that line: 0 = run minimized (you will not see the DOS window); True = Wait until finished before moving on.

(in reply to Navarre)
 
 
Post #: 11
 
 RE: HTA Question - 3/6/2006 8:32:32 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Thanks for that.

(in reply to Country73)
 
 
Post #: 12
 
 RE: HTA Question - 3/6/2006 2:56:02 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
I would like to thank everyone for their help, hopefully this is the last in this process.

Here is where I have my script at the moment, but what I need to do is make the 'OK' button execute all the checked boxes.  Can anyone tell me how to change the code to complete this.  I am trying to modulate as much as possible so that I do not have to wade through masses of code when I want to make changes.

Again any help would be high appreciated.

Script -

<html>
<head>
<hta:application id = "mcomms" />
  <title>Test Checkbox</title>
  <meta http-equiv = "content-script-type" content = "text/vbscript"/>
  <script language = "VBScript" type = "text/vbscript" >
Sub doit1
   Set oShell = CreateObject("Wscript.Shell")
   oShell.Run "J:\comms\MoveCommsOut-Nz.bat",0,True
End Sub
Sub doit2
Set oShell = CreateObject("WScript.Shell")
oShell.Run "J:\Comms\MoveCommsInOz-Monday.bat",0,True
End Sub
</script>
</head>
<IMAGE SRC = ".\network.jpg" align = "center">
<h1 align="center"> Run Comms Processes</h1>
<body>
<input type='checkbox' name='test'> Select this one...
<input type='checkbox' name='test2'> Select this one as well...
<input type='button' name='OKButton' value=' Test this out . . . ' onclick="DoIt1">
<o:p>&nbsp;</o:p></p>
     <input type = "BUTTON" value = " Exit " onclick ="self.close()">
</button></body>
</html>

(in reply to Navarre)
 
 
Post #: 13
 
 RE: HTA Question - 3/8/2006 1:08:47 AM   
  rOOs


Posts: 63
Score: 0
Joined: 2/28/2006
From: Switzerland
Status: offline
the trick is to create a sub to check whats checked (extremely well written sentence :-) ) and to run the relative sub then... or not...

<html>
<head>
<hta:application id = "mcomms" />
<title>Test Checkbox</title>
<meta http-equiv = "content-script-type" content = "text/vbscript"/>
<script language = "VBScript" type = "text/vbscript" >
Sub DoSelected
If test.checked = True Then
doit1
End If
If test2.checked = True Then
doit2
End If
End Sub
Sub doit1
  Set oShell = CreateObject("Wscript.Shell")
  oShell.Run "J:\comms\MoveCommsOut-Nz.bat",0,True
End Sub
Sub doit2
Set oShell = CreateObject("WScript.Shell")
oShell.Run "J:\Comms\MoveCommsInOz-Monday.bat",0,True
End Sub
</script>
</head>
<IMAGE SRC = ".\network.jpg" align = "center">
<h1 align="center"> Run Comms Processes</h1>
<body>
<input type='checkbox' name='test'> Select this one...
<input type='checkbox' name='test2'> Select this one as well...
<input type='button' name='OKButton' value=' Test this out . . . ' onclick="DoSelected">
<o:p>&nbsp;</o:p></p>
    <input type = "BUTTON" value = " Exit " onclick ="self.close()">
</button></body>
</html>


(in reply to Navarre)
 
 
Post #: 14
 
 RE: HTA Question - 3/8/2006 8:28:45 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Thank you for that, works perfectly.

(in reply to rOOs)
 
 
Post #: 15
 
 RE: HTA Question - 3/8/2006 6:26:30 PM   
  rOOs


Posts: 63
Score: 0
Joined: 2/28/2006
From: Switzerland
Status: offline
Dont' forget to change the name of the chockboxes and subroutines so that it makes sense... 'test' ist never a good name...

(in reply to Navarre)
 
 
Post #: 16
 
 RE: HTA Question - 3/9/2006 8:56:03 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
When I was completing the changes to add in the other bits I put in their correct names, now I just need to work out the extra bits to do everything that I wanted to do.

Here is where I have it at the moment.


      

(in reply to rOOs)
 
 
Post #: 17
 
 RE: HTA Question - 3/9/2006 9:17:48 AM   
  rOOs


Posts: 63
Score: 0
Joined: 2/28/2006
From: Switzerland
Status: offline
If you asked the whole question first i would have given you this:


      

This is a solution if you only want to run it for one day a time...

if you want to preselect the day you need to use the weekday function and you have to use the DOM of DHTML to change the index of the select, so it would jump to the right day.... (if have this at work not a home... so i can't easily post it here)

if you only would do the right thing on the right day and schedule it, you need to convert it back to vbscript and schedule with windows scheduled task, make the case thing and use the weekday to set a variable that tell the select case which it has to do...

do you still understand me? :-)

(in reply to Navarre)
 
 
Post #: 18
 
 RE: HTA Question - 3/9/2006 9:24:54 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
The problem is that this still needs to be essentially a manual process, because we have to check whether all the required files are there.  This is manily due to the fact that our stores have their files increment on a daily basis.

So normally one could predict what will be the next file, but if the process on their end did not go off there will be no files for them.  The other problem with the store files that we are moving around is when the file gets to 99 it then goes around to 00 and starts back to 1.

(in reply to rOOs)
 
 
Post #: 19
 
 RE: HTA Question - 3/9/2006 9:41:40 AM   
  rOOs


Posts: 63
Score: 0
Joined: 2/28/2006
From: Switzerland
Status: offline
That you could solve with a for ... next statement, that checks wheter a file exist or not...

the above posted is still manual... is only a bit faster, and better code...

(in reply to Navarre)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> HTA Question Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts