Solved

HTA Submit Application

Posted on 2009-07-09
5
452 Views
Last Modified: 2012-05-07
I have an hta that I built that works great however I want to change the button type to radio, and make it so that only one can be selected, as soon as I do what is needed for that I get script errors. I will past the codes for the working, and none working versions below.
Working Code:
<html>
<head>
<title>Help Desk Interface</title>
<HTA:APPLICATION 
     ID="objTest" 
     APPLICATIONNAME="HTATest"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
>
</head>
<body STYLE="font:14 pt arial; color:white;
 filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#000000', EndColorStr='#3399ff')">
 
 
<style type="text/css">
.myclass {color:charcoal; font-family:arial; font-size:70%}
.myheader {color:charcoal; font-family:arial;font-weight:bold; font-size:100%}
</style>
<SCRIPT LANGUAGE="VBScript">
 
Sub Window_OnLoad
	intHeight = 380
	intWidth = 600
	Me.ResizeTo intWidth, intHeight
	Me.MoveTo (screen.width / 2) - (intWidth / 2), (screen.height / 2) - (intHeight / 2)
	Set objNetwork = CreateObject("WScript.Network")
	Set WshShell = CreateObject("WScript.Shell")
End Sub
 
    Sub TestSub
	Set WshShell = CreateObject("WScript.Shell")    
        If Checkbox1.Checked Then
            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckdrahd.bat"
        End If
        If Checkbox2.Checked Then
            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckremedyhd.bat"
        End If
        If Checkbox3.Checked Then
            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\OUTLOOKHD.bat"        
        End If
        If Checkbox4.Checked Then
            WshShell.Run "http://141arwsharepoint/sites/help/Help%20Desk%20Training/Forms/AllItems.aspx"       
        End If
	window.Close   
    End Sub  
 
</SCRIPT>
 
<body>
 
    <br>
 
    <input type="checkbox" name="Checkbox1"> Launch DRA<br>
    <input type="checkbox" name="Checkbox2"> Launch Remedy<br>
    <input type="checkbox" name="Checkbox3"> Launch Outlook<br>
    <input type="checkbox" name="Checkbox4"> Launch Help Desk Tasks Outline<p>
    <input id=runbutton  class="button" type="button" value="Run" name="run_button" onClick="TestSub">
 
</body>
 
Non-Working Code:
<html>
<head>
<title>Help Desk Interface</title>
<HTA:APPLICATION 
     ID="objTest" 
     APPLICATIONNAME="HTATest"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
>
</head>
<body STYLE="font:14 pt arial; color:white;
 filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#000000', EndColorStr='#3399ff')">
 
 
<style type="text/css">
.myclass {color:charcoal; font-family:arial; font-size:70%}
.myheader {color:charcoal; font-family:arial;font-weight:bold; font-size:100%}
</style>
<SCRIPT LANGUAGE="VBScript">
 
Sub Window_OnLoad
	intHeight = 380
	intWidth = 600
	Me.ResizeTo intWidth, intHeight
	Me.MoveTo (screen.width / 2) - (intWidth / 2), (screen.height / 2) - (intHeight / 2)
	Set objNetwork = CreateObject("WScript.Network")
	Set WshShell = CreateObject("WScript.Shell")
End Sub
 
    Sub TestSub
	Set WshShell = CreateObject("WScript.Shell")    
        If Check1.Checked Then
            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckdrahd.bat"
        End If
        If Check2.Checked Then
            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckremedyhd.bat"
        End If
	window.Close   
    End Sub  
 
</SCRIPT>
 
<body>
 
    <br>
 
    <input type="radio" name="Check1" value="Check1"> Launch DRA<br>
    <input type="radio" name="Check1" value="Check2"> Launch Remedy<br>
    <br>
    <input id=runbutton  class="button" type="button" value="Run" name="run_button" onClick="TestSub">
 
</body>

Open in new window

0
Comment
Question by:141ANG
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 24820861
You have two radios. You gave them different VALUES and you test the values instead of their names.

I do not normally do VB script, but the radio is now a collection and you need to check it possibly like this:
    Sub TestSub
        Set WshShell = CreateObject("WScript.Shell")    
        If Check1(0).Checked Then
            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckdrahd.bat"
        End If
        If Check1(1).Checked Then
            WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckremedyhd.bat"
        End If
        window.Close  
    End Sub  


0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24820880
But why click twice???

And why create a shell twice?

<html>
<head>
<title>Help Desk Interface</title>
<HTA:APPLICATION 
     ID="objTest" 
     APPLICATIONNAME="HTATest"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
>
</head>
<body STYLE="font:14 pt arial; color:white;
 filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#000000', EndColorStr='#3399ff')">
 
 
<style type="text/css">
.myclass {color:charcoal; font-family:arial; font-size:70%}
.myheader {color:charcoal; font-family:arial;font-weight:bold; font-size:100%}
</style>
<SCRIPT LANGUAGE="VBScript">
 
Sub Window_OnLoad
        intHeight = 380
        intWidth = 600
        Me.ResizeTo intWidth, intHeight
        Me.MoveTo (screen.width / 2) - (intWidth / 2), (screen.height / 2) - (intHeight / 2)
        Set objNetwork = CreateObject("WScript.Network")
        Set WshShell = CreateObject("WScript.Shell")
End Sub
Sub TestSub1
  WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckdrahd.bat"
  window.Close   
End Sub  
Sub TestSub2
  WshShell.Run "c:\windows\system32\cmd.exe /c \\141arw-ap-01\app-installs\automation\launchcheckremedyhd.bat"
  window.Close   
End Sub  
 
</SCRIPT>
 
<body>
 
 
    <input class="button" type="button" name="run_button" onClick="TestSub1" value="Launch DRA">
    <input class="button" type="button" name="run_button" onClick="TestSub2" value="Launch Remedy">
 
</body>

Open in new window

0
 
LVL 1

Author Comment

by:141ANG
ID: 24823692
this last script looked promising but it returns an error on click

Line: 29
Char: 3
Error: Object required: 'WshShell'
Code: 0
URL: file:///K:/Automation/LoginType.hta
0
 
LVL 1

Author Closing Comment

by:141ANG
ID: 31601755
This was exactly what I needed
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24824624
Then make WshShell global in scope
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question