HTA/VBS Noob question

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

HTA/VBS Noob question

Post by thenoob74 » Tue Aug 10, 2010 2:05 am

Hello - I've been working on a script for days now just learning the ropes. Attached is my complete hta scrip. Forgive the rude looking interface its indeed a work in progress. But looking past that I'm trying to set this up so that when we click the "Send" button it runs the code for the selected IT User or Standard User. Being we have two seperate OU's for IT users and Standard users I need to use a dropdown list. So the end result, I'm hoping, will be I select which user IT or STD and then click the send button to execute the code for which ever user was selected. I've not been able to get this to work as I am hoping. Let me know what I'm doing wrong, I just picked this up a few weeks ago and have pasted code from other examples to learn. hope I am making sense with what I'm trying to achieve. Thank you for any help!!uploads/34385/tsm_post_script.txt

User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

HTA/VBS Noob question

Post by thenoob74 » Tue Aug 10, 2010 3:09 am

Yeah sorry for the pile of extracted code for varying sources... Perhaps you can help me with a part of this then. The part that is hanging me up is how I would the code look to have a dropdownlist with 2 values let's say they're IT and STD, when I run the HTA and select IT and click the button to run that sub, if they select STD then it would run that sub. That's all I'm really looking for and I can take my mess and go from there. I do have this working with buttons, I would just rather have a dropdownlist and a GO button that kicks it all off based on what's selected. IF you have a sample of how that would look like it would be helpful to me. I've been playing with IF statements and that's not going well.

User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Tue Aug 10, 2010 3:37 am

First you can only call one event from a control.

It is pretty clear that yuo are very confused about how scripting works. YOu really should avoid HTAs until you get a handle on how script work.

Get your code working as a standard scrip function in a VBS file and I will show you how to make it work in an HTA.


User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

HTA/VBS Noob question

Post by thenoob74 » Tue Aug 10, 2010 4:46 am

uploads/34385/tsm_post_script1.txtHere are the segments of my script that have been confirmed as working. If you can help me with a basic template for the hta that would be greatly appreciated. Just looking for a drop down list that will run the IT user or STD user with a button to execute it. The Node registration would be ran by clicking another button.

User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Tue Aug 10, 2010 4:51 am

uploads/34385/tsm_post_script1.txtHere are the segments of my script that have been confirmed as working. If you can help me with a basic template for the hta that would be greatly appreciated. Just looking for a drop down list that will run the IT user or STD user with a button to execute it. The Node registration would be ran by clicking another button.



You need to make these into functions or subroutines that can be easily called from an event handler.


User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Tue Aug 10, 2010 5:16 am

Script "Function" or "Subroutine" not a script file. YOu can't easily embed a script file into an HTA.


User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Tue Aug 10, 2010 1:31 pm

Put this in an HTA file and it will do what you ask.

Code: Select all

<html>
<script> 
    Sub doit1() 
        msgbox "IT" 
    End Sub 
    Sub doit2() 
        msgbox "STD" 
    End Sub 
    Sub doit3() 
        msgbox "OPTION 3" 
    End Sub 
</script>
<body> 
<input type="radio" name="UserOption" onclick="doit1">IT 
 
<input type="radio" name="UserOption" onclick="doit2">STD 
 
<input type="radio" name="UserOption" onclick="doit3">Option 3 
 
</body> 
</html>

If this is not what you want then you will have to try and write a simle explanation of what you are trying to do. Try to write teh explanarion without talking about technology or scripting.

Example:
"I need to collect user information ito a file. The items I need are first name. last name, street ...."

Don't talk about how just describe what is needed as an outcome.

User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Wed Aug 11, 2010 12:04 am

Code: Select all

<html> 
 <script language="VBScript"> 
  
 Sub clickme() 
    If combo1.value <> "" Then 
    spanArea.innerHTML = combo1.value 
    Else  
       MsgBox "Please make a selection" 
    End if 
 End Sub 
 </script> 
<body> 
        <select id="combo1" size="2"> 
            <option value="ITUser">IT User</option> 
            <option value="StandardUser">Standard User</option> 
        </select> 
        <br /><input class="button" type="button" value="ClickMe"  onClick="clickme"> 
    <div id="divOutput"> 
        <span id="SpanArea" style="color: red; font-weight: boldest;"></span> 
    </div> 
 </div>  
 </body> 
 </html>
 


This is a standard button and NOT a submit button.

See http://www.w3schools.com/
It's free and very good.

User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Wed Aug 11, 2010 1:45 am

Ras - that was my first posting way back when. We went through that and the user said it wasn't what they wanted.

The submit does NOT produce an onclick for the button unless you define an onclick. It also does not do anything but hide the controls inside of a form. It will create issues.

User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

HTA/VBS Noob question

Post by thenoob74 » Wed Aug 11, 2010 2:23 am

Sorry this is the script actually... DIM strOU, strOU1, strGroup, strUser, strDNSDomain, strprovider, strOUG, strUserinDim objRootLDAP, objGroup, objUserstrUserin = InputBox("Enter the name in the following format ex: Lastname, Jason J.","Please enter your Name") If Vartype(strUserin) = 0 Then MsgBox "Cancelled" Wscript.Quit Else'Check these objects referenced by strOU, strGroup exist in strOUstrOU = "OU=Managed Users,"strOU1 = "OU=Standard,"strOUG = "OU=Application Rights, OU=Groups, OU=Managed Users,"strUser = "CN=" & strUserin &","strprovider = "LDAP://"strGroup = "CN=TSM_BackupUsers,"strDNSDomain = "DC=MFI,DC=domain,DC=PVT"' Add (str)User to (str)GroupSet objUser = GetObject(strprovider & strUser & strOU1 & strOU & strDNSDomain)Set objGroup = GetObject(strprovider & strGroup & strOUG & strDNSDomain)objGroup.add(objUser.ADsPath) Dim strComp, oGrp, oUsr, oGrp1strComp = "."Set oGrp = GetObject("WinNT://" & strComp & "/Power Users")set oGrp1 = GetObject("WinNT://" & strComp & "/Backup Operators")Set oUsr = GetObject("WinNT://MFI.domain.pvt/Domain Users")oGrp.Add(oUsr.ADsPath)oGrp1.Add(oUsr.ADsPath)msgbox "Done"WScript.Echo "Check " & strOU & " for " & strGroup & " = " & strUserWscript.QuitEnd if
thenoob742010-08-11 09:24:20

Locked