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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert vbs script to hta format.

Status
Not open for further replies.

redlair

Technical User
Jun 29, 2004
54
US
I have a vbs script that prompts for a user name and server address then creates a Gruopwise mail icon on the desktop. I have started a .hta with severs addresses and a dropdown menu. I would like to merge the two so the user will have a dropdown rather then entering the server address. I do not know enough about HTA to merge my script. If there is any advise, I would appreciate it

----------------------
<html>
<head>
<title>My Second HTA</title>
<HTA:APPLICATION
ID="Groupwise Icon"
APPLICATIONNAME="GWIcon"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal">
</head>
<SCRIPT Language="VBScript">

Sub RunScript

Dim r
Dim oshell, fso, Uname, Ipa
Dim WScript
Set oshell = WScript.CreateObject("WScript.Shell")

Dim shcut, d, dpath, wpath
Dim Swtc



r = MsgBox("Would you like a shortcut to GroupWise?", 36, "Create Shortcut?")
If r = 7 Then
WScript.quit

Else

Set fso = CreateObject("Scripting.FileSystemObject")

dpath = oshell.SpecialFolders("Desktop")
wpath = "C:\Novell\GroupWise"

Uname = InputBox("Input a username (Last_First):", "Staff members user name")
Ipa = DropDown1.value


Set shcut = oshell.CreateShortcut(dpath & "\" & Uname & " GroupWise.lnk")

shcut.TargetPath = oshell.ExpandEnvironmentStrings(wpath + "\GrpWise.exe")
shcut.arguments = (" /@u-" & Uname & " /Ipa-" & Ipa)
shcut.WorkingDirectory = oshell.ExpandEnvironmentStrings(wpath)
shcut.WindowStyle = 4
shcut.IconLocation = oshell.ExpandEnvironmentStrings(wpath & "\GrpWise.exe, 0")
shcut.Save

End If
End Sub
</SCRIPT>
<body>

<select
<select size="1" name="DropDown1" onChange="RunScript">
<option value="10.0.0.4">
Auburn
</option>
<option value="10.0.1.4">
Baker
</option>
</select>
</body>
</html>
 
Let me expand on this issue. Here is my vbs sript, which works great:



Option Explicit

Dim r
Dim oshell, fso, Uname, Ipa
Set oshell = WScript.CreateObject("WScript.Shell")

Dim shcut, d, dpath, wpath
Dim Swtc

r = MsgBox("Would you like a shortcut to GroupWise?", 36, "Create Shortcut?")
If r = 7 Then
WScript.quit

Else

Set fso = CreateObject("Scripting.FileSystemObject")

dpath = oshell.SpecialFolders("Desktop")
wpath = "C:\Novell\GroupWise"

Uname = InputBox("Input a username (Last_First):", "Staff members user name")
Ipa = InputBox("Input the Ipa address for your building.", "Building Ipa")


Set shcut = oshell.CreateShortcut(dpath & "\" & Uname & " GroupWise.lnk")

shcut.TargetPath = oshell.ExpandEnvironmentStrings(wpath + "\GrpWise.exe")
shcut.arguments = (" /@u-" & Uname & " /Ipa-" & Ipa)
shcut.WorkingDirectory = oshell.ExpandEnvironmentStrings(wpath)
shcut.WindowStyle = 4
shcut.IconLocation = oshell.ExpandEnvironmentStrings(wpath & "\GrpWise.exe, 0")
shcut.Save

End If
---------------------

And here is the hta I have started:

<html>
<head>
<title>My Second HTA</title>
<HTA:APPLICATION
ID="Groupwise Icon"
APPLICATIONNAME="GWIcon"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal">
</head>
<SCRIPT Language="VBScript">

Sub RunScript


End Sub
</SCRIPT>
<body>

<select
<select size="1" name="DropDown1" onChange="RunScript">
<option value="10.0.0.4">
Auburn
</option>
<option value="10.0.1.4">
Baker
</option>
</select>
</body>
</html>



 
Hello redlair,

I just add or delete or change here and there something so make it work. Look into what changed. You sure can make it more stylistic and expand on it functionality based on it.
Code:
<html>
<head>
<title>My Second HTA</title>
<HTA:APPLICATION 
ID="Groupwise Icon"
APPLICATIONNAME="GWIcon"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal">

<SCRIPT Language="VBScript">

Sub RunScript

	Dim r
	Dim oshell, fso, Uname, Ipa
	Dim WScript
	'Set oshell = WScript.CreateObject("WScript.Shell")
	Set oshell = CreateObject("WScript.Shell")

	Dim shcut, d, dpath, wpath
	Dim Swtc
	
	dim elem_username
	dim elem_ipa
	
 
	r = MsgBox("Would you like a shortcut to GroupWise?", 36, "Create Shortcut?")
	If r = 7 Then
		'WScript.quit
		'htaclose
	Else

		Set fso = CreateObject("Scripting.FileSystemObject")

		dpath = oshell.SpecialFolders("Desktop")
		wpath = "C:\Novell\GroupWise"

		'Uname = InputBox("Input a username (Last_First):", "Staff members user name")
		'Ipa = DropDown1.value    '???!!!

		set elem_username=document.forms("data").elements("username")
		Uname=elem_username(elem_username.selectedIndex).value

		set elem_ipa=document.forms("data").elements("ipa")
		Ipa=elem_ipa(elem_ipa.selectedIndex).value
	
			msgbox uname & vbcrlf & ipa    'comment this out after testing

		Set shcut = oshell.CreateShortcut(dpath & "\" & Uname & " GroupWise.lnk")

		shcut.TargetPath = oshell.ExpandEnvironmentStrings(wpath + "\GrpWise.exe")
		shcut.arguments = (" /@u-" & Uname & " /Ipa-" & Ipa)
		shcut.WorkingDirectory = oshell.ExpandEnvironmentStrings(wpath)
		shcut.WindowStyle = 4
		shcut.IconLocation = oshell.ExpandEnvironmentStrings(wpath & "\GrpWise.exe, 0")
		shcut.Save

	End If
	
	htaclose
	
End Sub

sub htaClose
	window.close
end sub

</SCRIPT>
</head>
<body>
<form name="data">
User&nbsp;
<select size="1" name="username">
<option value="smith_john">John Smith</option>
<option value="smith_alan">Alan Smith</option>
</select>
<br /><br />
Address&nbsp;
<select size="1" name="ipa">
<option value="10.0.0.4">Auburn</option>
<option value="10.0.1.4">Baker</option>
</select>
<br /><br />
<input type="button" value="Process now..." onclick="RunScript" />
</form>
</body>
</html>
The script inherits all the weakpoints of the original, so if you want to promote it, apart from stylistic, there are room for logic improvement.

regards - tsuji
 
tsuji - Thank you it works great. The only thing that needs modified is the username. I need to have them type in there name insteed of a dropdown. Again thanks...
 
tsuji - I have done some research. I know how to create the text box (input)for the username, but I havent figured out how to recieve the data value in the vbscript. Can you help....

Redlair
 
redlair,

Textbox entry is exposed through .elements("textboxname").value which is read/write property.

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top