Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript help

Status
Not open for further replies.

cdonkin

IS-IT--Management
May 22, 2009
6
US
Hi guys, first post!

I've got a web page with some check boxes the idea being the user selects a check box and then selects a button to launch a script. Ideally I'd prefer it to be a combo box than a checkbox but i've not gotten round to learning combo boxes.

The code is as follows :

<script type="text/VBScript" language="VBScript">

Set WshShell =CreateObject("WScript.Shell")

'
' Marks which script has been selected to run
'
Sub runScript

If b8o.checked Then
runb80
End If

If b8vpn.checked then
runb8vpn
End If

If bdevo.checked then
run bdevo
End If

If bdevvpn.checked then
run bdevvpn

If b70.checked Then
runb70
End If

If b7vpn.checked then
runb7vpn
End If

End Sub

Sub runb80

WshShell.Run "cmd /c netsh interface ip set DNS ""Local Area Connection"" Static 000.000.000.000",0

End Sub

Sub runb8vpn

WshShell.Run "cmd /c netsh interface ip set DNS ""{"" Static 000.000.000.000",0

End Sub

Sub bdevo
WshShell.Run "cmd /c netsh interface ip set DNS ""Local Area Connection"" Static 000.000.000.000",0

End Sub

Sub bdevvpn

WshShell.Run "cmd /c netsh interface ip set DNS ""{"" Static 000.000.000.000",0

End Sub

Sub runb70

WshShell.Run "cmd /c netsh interface ip set DNS ""Local Area Connection"" dhcp",0

End Sub

Sub runb7vpn

WshShell.Run "cmd /c netsh interface ip set DNS ""{"" dhcp",0

End Sub

</Script>

I omitted the IP addresses i am using.

In the body of the page i have the following :

<input type="Checkbox" name="b80"> Banner 8 Office <br><br>
<input type="Checkbox" name="b8vpn"> Banner 8 VPN <br><br>
<input type="Checkbox" name="bdevo"> Business Development Office <br><br>
<input type="Checkbox" name="bdevvpn"> Business Development VPN <br><br>
<input type="Checkbox" name="b70"> Banner 7 Office <br><br>
<input type="Checkbox" name="b7vpn"> Banner 7 VPN <br><br>

<! -- Ok button to run selected script -->

<input type="Submit" value="Run" onclick="runScript">

However when i select the Button it is throwing up errors of Mismatch with the "runScript" part and also i'm getting errors saying b8o object is undefined.

Any help greatly appreciated.

 
Are you running this as html or ASP code? Before diving in to the code, please post the entire page so things are not out of context. Change your IP if it is public. If internal it doesn't matter.

Please enclose in a code box using [ignore]
Code:
[/ignore] TGML tags.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SGHE International UDC Demonstration Environment</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style1 a {
	text-decoration: none;
	color: #000000;
}
-->
</style>
</head>

<script type="text/VBScript" language="VBScript">

Set WshShell =CreateObject("WScript.Shell")


'******************************************
' Marks which script has been selected to run
'******************************************

Sub run

	If b8o.checked Then
		runb80
	End If

	If b8vpn.checked then
		runb8vpn
	End If
	
	If bdevo.checked then
		run bdevo
	End If
	
	If bdevvpn.checked then
		run bdevvpn
	End If
	
	If b70.checked Then
		runb70
	End If

	If b7vpn.checked then
		runb7vpn
	End If

End Sub 

'******************************************
'run banner 8 office script
'******************************************

Sub runb80

Set WshShell = WScript.CreateObject("Wscript.Shell")

WshShell.Run "cmd /c netsh interface ip set DNS ""Local Area Connection"" Static 150.24.223.10",0



End Sub 


'******************************************
'run banner 8 vpn script
'******************************************

Sub runb8vpn

Set WshShell = WScript.CreateObject("Wscript.Shell")

WshShell.Run "cmd /c netsh interface ip set DNS ""{"" Static 150.24.223.10",0

End Sub 


'******************************************
'run busdev office script
'******************************************

Sub bdevo

Set WshShell = WScript.CreateObject("Wscript.Shell")

WshShell.Run "cmd /c netsh interface ip set DNS ""Local Area Connection"" Static 150.24.223.20",0

End Sub 


'******************************************
'run busdev office script
'******************************************

Sub bdevvpn

Set WshShell = WScript.CreateObject("Wscript.Shell")

WshShell.Run "cmd /c netsh interface ip set DNS ""{"" Static 150.24.223.20",0

End Sub 

'******************************************
'run banner 7 office script
'******************************************

Sub runb70

Set WshShell = WScript.CreateObject("Wscript.Shell")

WshShell.Run "cmd /c netsh interface ip set DNS ""Local Area Connection"" dhcp",0

End Sub 


'******************************************
'run banner 7 VPN script
'******************************************

Sub runb7vpn

Set WshShell = WScript.CreateObject("Wscript.Shell")

WshShell.Run "cmd /c netsh interface ip set DNS ""{"" dhcp",0

End Sub 

'*****************************************
'Script for exiting
'****************************************

sub killApp
	window.close
 End sub    

</Script>


<body>

<p class="style1">In order to access the various environments available for demonstration and/or development, you need to run a script to redirect your DNS to the appropriate server.
Look at the table below and select your method of connectivity (VPN or Office) for the environment you want to access (e.g. Banner 8) and select the link.
You will be prompted to run or save a file, choose run. You can now connect to the service through your browser.
When you have finished either run the script to unset the DNS server back to its default or, if you are using VPN, disconnect</p>


<! -- Form object that works with the scripts -->

<input type="Checkbox" name=b80> Banner 8 Office <br><br>
<input type="Checkbox" name="b8vpn"> Banner 8 VPN <br><br>
<input type="Checkbox" name="bdevo"> Business Development Office <br><br>
<input type="Checkbox" name="bdevvpn"> Business Development VPN <br><br>
<input type="Checkbox" name="b70"> Banner 7 Office <br><br>
<input type="Checkbox" name="b7vpn"> Banner 7 VPN <br><br>

<! -- Ok button to run selected script -->

<input type="Button" value="Run" onclick="run">
<input type="button" value="EXIT" name="run_button" onClick="killApp">

</body>
</html>
 
[tt]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[ignore][/ignore]">
<html xmlns="[ignore][/ignore]">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SGHE International UDC Demonstration Environment</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style1 a {
text-decoration: none;
color: #000000;
}
-->
</style>
</head>

<script type="text/VBScript" language="VBScript">

[red]'[/red]Set WshShell =CreateObject("WScript.Shell")


'******************************************
' Marks which script has been selected to run
'******************************************

Sub run

If [red]document.formname.[/red]b8o.checked Then
runb80
End If

If [red]document.formname.[/red]b8vpn.checked then
runb8vpn
End If

If [red]document.formname.[/red]bdevo.checked then
[red]'[/red]run bdevo
[red]bdevo[/red]
End If

If [red]document.formname.[/red]bdevvpn.checked then
[red]'[/red]run bdevvpn
[red]bdevvpn[/red]
End If

If [red]document.formname.[/red]b70.checked Then
runb70
End If

If [red]document.formname.[/red]b7vpn.checked then
runb7vpn
End If

End Sub

'******************************************
'run banner 8 office script
'******************************************

Sub runb80

[red]Set WshShell = CreateObject("Wscript.Shell")[/red]

WshShell.Run "cmd /c netsh interface ip set DNS ""Local Area Connection"" Static 150.24.223.10",0

[red]set WshShell=nothing[/red]

End Sub


'******************************************
'run banner 8 vpn script
'******************************************

Sub runb8vpn

[red]Set WshShell = CreateObject("Wscript.Shell")[/red]

WshShell.Run "cmd /c netsh interface ip set DNS ""{"" Static 150.24.223.10",0

[red]set WshShell=nothing[/red]

End Sub


'******************************************
'run busdev office script
'******************************************

Sub bdevo

[red]Set WshShell = CreateObject("Wscript.Shell")[/red]

WshShell.Run "cmd /c netsh interface ip set DNS ""Local Area Connection"" Static 150.24.223.20",0

[red]set WshShell=nothing[/red]

End Sub


'******************************************
'run busdev office script
'******************************************

Sub bdevvpn

[red]Set WshShell = CreateObject("Wscript.Shell")[/red]

WshShell.Run "cmd /c netsh interface ip set DNS ""{"" Static 150.24.223.20",0

[red]set WshShell=nothing[/red]

End Sub

'******************************************
'run banner 7 office script
'******************************************

Sub runb70

[red]Set WshShell = CreateObject("Wscript.Shell")[/red]

WshShell.Run "cmd /c netsh interface ip set DNS ""Local Area Connection"" dhcp",0

[red]set WshShell=nothing[/red]

End Sub


'******************************************
'run banner 7 VPN script
'******************************************

Sub runb7vpn

[red]Set WshShell = CreateObject("Wscript.Shell")[/red]

WshShell.Run "cmd /c netsh interface ip set DNS ""{"" dhcp",0

[red]set WshShell=nothing[/red]

End Sub

'*****************************************
'Script for exiting
'****************************************

sub killApp
window.close
End sub

</Script>


<body>

<p class="style1">In order to access the various environments available for demonstration and/or development, you need to run a script to redirect your DNS to the appropriate server.
Look at the table below and select your method of connectivity (VPN or Office) for the environment you want to access (e.g. Banner 8) and select the link.
You will be prompted to run or save a file, choose run. You can now connect to the service through your browser.
When you have finished either run the script to unset the DNS server back to its default or, if you are using VPN, disconnect</p>


<[highlight]!-[/highlight]- Form object that works with the scripts -->
[red]<form name="formname">[/red]
<input type="Checkbox" name=b80> Banner 8 Office <br><br>
<input type="Checkbox" name="b8vpn"> Banner 8 VPN <br><br>
<input type="Checkbox" name="bdevo"> Business Development Office <br><br>
<input type="Checkbox" name="bdevvpn"> Business Development VPN <br><br>
<input type="Checkbox" name="b70"> Banner 7 Office <br><br>
<input type="Checkbox" name="b7vpn"> Banner 7 VPN <br><br>

<[highlight]!-[/highlight]- Ok button to run selected script -->

<input type="Button" value="Run" onclick="run">
<input type="button" value="EXIT" name="run_button" onClick="killApp">
[red]</form>[/red]
</body>
</html>[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top