Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I need help in finding a value from the combobox and then call another subroutine called removeshares to perform the action for that found value.

Here is the code attached below.
<html>
<head>
<title>Test</title>
<HTA:APPLICATION 
     ID="objNoTitleBar"
     APPLICATIONNAME="Window Without a Title Bar"
     SCROLL="No"
     SINGLEINSTANCE="yes"
     CAPTION="yes"
	 SysMenu="no"
	 ICON = "BIOHAZRD.ico"
>
</head>

<SCRIPT LANGUAGE="VBScript">


Sub Window_Onload
	iTimerID = window.setInterval("ShowSplash",4000)
	'self.Focus()
	self.ResizeTo 650,425	
	End Sub

Sub CloseWindow
       self.close
End Sub

Sub ShowSplash
        Splash.Style.Display = "None"
        Main.Style.Display = "Inline"
End Sub

Sub RunScript
    If BasicCheckbox.Checked Then
        strHTML= "<p align='center'><font color='black' size='3'><b>Updating....<br></font></p>"
		self.setTimeout "RemoveShares", 9
	Else
        strHTML= "<p align='center'><font color='black' size='3'><b>Exiting....<br></font></p>"
		self.close
    End If
DataArea.InnerHTML = strHTML	
End Sub

Sub MoveItem(oSource, oDestination)
	Dim oListItem
	If oSource.selectedIndex >= 0 Then
		'  Create an variable to hold the item.
		Set oListItem = oSource.options(oSource.selectedIndex)
		'  Remove the item from the source list.
		oSource.remove(oSource.selectedIndex)
		'  Add the item to the destination list.
		oDestination.add(oListItem)
	End If
	Call DisableButtons()
End Sub

Sub UpdateItem
'ddlBleh, ddlBlah
Dim MyArray(10)
Dim Search
Search = "1"
	For i = 0 to (ddlBlah.Options.Length - 1)
     strComputer =  strComputer & ddlBlah.Options(i).Value & vbcrlf
	Next
	msgbox strComputer	
    
Call UpdateItem1
Call International
End sub

Sub International
Dim intX 
If ddlBlah.Text = "Red" Then Exit Sub
For intX = 0 To ddlBlah.ListCount - 1
	If UCase(ddlBlah.Text) = UCase(ddlBah.List(intX)) Then
MsgBox "Item '" & ddlBlah.Text & "' is already in list."
Exit Sub
End If
Next
end sub

Sub UpdateItem1
    For j = 0 to (ddlBleh.Options.Length - 1)
	strK =  strK & ddlBleh.Options(j).Value & vbcrlf
	Next
	msgbox strK
End sub
<br />
Sub DisableButtons()
	If ddlBlah.options.length = 0 Then
		btnAdd.disabled = True
	Else
		btnAdd.disabled = False
	End If
	If ddlBleh.options.length = 0 Then
		btnRemove.disabled = True
	Else
		btnRemove.disabled = False
	End If
End Sub

sub RemoveShares
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colShares = objWMIService.ExecQuery _
    ("Select * from Win32_Share where Type != 2147483648")
	
For Each objShare in colShares
    	objShare.Delete
Next
end sub
	
</SCRIPT>
<body STYLE="font:14pt arial; color:white;
 filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#F5F5F5', EndColorStr='#D8BFD8')">
<DIV id="Splash" STYLE="Height:275;Width:550;Border:0.1mm solid black;
position:relative;top:50;left:30;font:14pt arial;
 filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#00BFFF', EndColorStr='#ADD8E6')
progid:DXImageTransform.Microsoft.dropshadow(OffX=10, OffY=10, 
        Color='black', Positive='true')">

<CENTER>
<br>
<br>
<br>
<font size="4" color="maroon">Test<br>
<br>
</font>
<font size="2" color="maroon">abc</font>
<br>
<br>
<br>
<img src="gears.gif">
</CENTER>
</DIV>
<DIV id="Main" STYLE="display:none;position:absolute">

<p></p>
<p></p>
<p align=center><font face="Arial" size="3" COLOR="black"><b>Hardening Settings</b></font></p>
<center>
<table border="0" cellpadding="2" cellspacing="1">
<tr valign="middle">
	<td>
	<select id="ddlBlah" class="ColorList" size="6">
	<option value="1">Red
	<option value="2">Green
	<option value="3">Blue
	<option value="4">Black
	<option value="5">Gray
	<option value="6">White
	</select>
	</td>
	<td>
	<button id="btnAdd" class="MoveButton" onclick="Call MoveItem(ddlBlah, ddlBleh)">Add -></button><br>
	<br>
	<button id="btnRemove" class="MoveButton" onclick="Call MoveItem(ddlBleh, ddlBlah)"><-Remove</button>
	</td>
	<td>
	<select id="ddlBleh" class="ColorList" size="6">
	</select>
	</td>
</tr>
</table>
</center>
<input id=runbutton type="button" value="Quit" onClick="CloseWindow" STyle='background-color: darkred;' STyle='color:white;'>
<input id=runbutton type="button" value="Update" onClick="UpdateItem" STyle='background-color: darkred;' STyle='color:white;'>
<font face="arial" size="2">
<hr WIDTH ="600">
<span id = "DataArea"></span>
</font>		
</body>
</html>
Posted
Updated 10-Aug-10 9:31am
v3
Comments
Christian Graus 10-Aug-10 6:31am    
You realise that using VBScript means your web page will only work in IE ?
protocol461 10-Aug-10 9:15am    
Yes Chris , I realise this. I just wanted the I.E to work as a frontend and the main part is the VBscript through which i need to execute other codes for certain hardening tasks as an system administrator
E.F. Nijboer 10-Aug-10 15:31pm    
Remember to put code in pre tags for readability
Christian Graus 10-Aug-10 15:34pm    
I suspect your issue will be that no-one uses VBScript for the reason I stated. If you were using javascript, I could help you.
E.F. Nijboer 10-Aug-10 15:37pm    
Also, I can't really get the exact problem because you do got some code but what about it? Also, you might want to lose the:

If UCase(A) = UCase(B) then
... into
If StrComp(A, B, 1) = 0 then
... or into some function and use that
Function SameText(A, B)
SameText = StrComp(A, B, 1) = 0
End Function

1 solution

Thanks Chris / Nijboer, I have worked on this and resolved this case and it seems to work through javascript.

:suss:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900