aceklub97
asked on
VBScript - Can I convert MSGBox prompts into Radio Buttons or Dropdown Menus?
Greetings,
I have a script that peforms the followings:
1. Pops a messagebox up that displays a list of groups that are found in a folder, and has the customer type a corresponding numnber in the message box.
2. Depending on the answer, go to the particualr start folder and prompts them for the particular sub group that are found within that group
3. Once that data is set is asked them whether they want to backup or restore. And then either creates or accesses a backupfolder that is created from the first two response.
Everything works perfectly, but it is that user friendly. Is there way that I can have thos prompts converted to either drop-down menus or Radio buttons on the .hta screen that I have calling the .vbs script? If I were able to have the same functionality and be able to read the information into the script the same way that would be perfect.
I have a script that peforms the followings:
1. Pops a messagebox up that displays a list of groups that are found in a folder, and has the customer type a corresponding numnber in the message box.
2. Depending on the answer, go to the particualr start folder and prompts them for the particular sub group that are found within that group
3. Once that data is set is asked them whether they want to backup or restore. And then either creates or accesses a backupfolder that is created from the first two response.
Everything works perfectly, but it is that user friendly. Is there way that I can have thos prompts converted to either drop-down menus or Radio buttons on the .hta screen that I have calling the .vbs script? If I were able to have the same functionality and be able to read the information into the script the same way that would be perfect.
You can embed the script into the HTA, and instead of reading the InputBox values, you just use something like
strGroup = lst_groups.Value
to read which group name has been selected from a list box.
Perhaps if you post the scripts (the HTA and VBS) we could help you combine them.
Regards,
Rob.
strGroup = lst_groups.Value
to read which group name has been selected from a list box.
Perhaps if you post the scripts (the HTA and VBS) we could help you combine them.
Regards,
Rob.
ASKER
Rob,
1. I have attached to porttion of the code that I need to read the information. I didn't include the core part of the script because it is just copying files.
2. I have included the .hta file that I have. It is realatively simple. I would like to be able to have the customer select a. There business group, and then b. the name of their trainer, and c. Whether they want to backup or restore.
If you need any more information, please let me know
VBSCode.vbs.txt
HTACode.hta.txt
1. I have attached to porttion of the code that I need to read the information. I didn't include the core part of the script because it is just copying files.
2. I have included the .hta file that I have. It is realatively simple. I would like to be able to have the customer select a. There business group, and then b. the name of their trainer, and c. Whether they want to backup or restore.
If you need any more information, please let me know
VBSCode.vbs.txt
HTACode.hta.txt
OK, I've changed the HTA a bit, to include the drop down and radio boxes, but currently, when you click Start, nothing happens. You'll need to copy in the code from the VBS that actually does the operation based on the folders and values. At the moment, you select your options, then click Start, and it just outputs what you've selected. Once you're happy with that, you can add your code below this line
'tmrExternal = window.setInterval("tmrExt ernal_time r", 1000, "VBScript")
to have it perform additional steps based on the values selected.
I hope this helps so far.
Regards,
Rob.
'tmrExternal = window.setInterval("tmrExt
to have it perform additional steps based on the values selected.
I hope this helps so far.
Regards,
Rob.
<HTML>
<HEAD>
<TITLE>
Nationwide Services Company - Training Room Data Migration Tool
</TITLE>
<link href="\\10.120.28.74\scripts\Backup\nwlogo.ico" type="text/css" rel="stylesheet">
<HTA:application scroll=no>
<STYLE>
div.clsIndent {margin-left: 30px}
div.clsIndentRed {margin-left: 30px; color: red}
</STYLE>
<SCRIPT language=VBScript>
Option Explicit
Const WshRunning = 0
Const WshFinished = 1
Dim wshShell
Dim wseExternal
Dim tmrExternal
Dim strComputer
Dim objWMIService
Dim colItems
Dim intHorizontal
Dim intVertical
Dim objExplorer
Dim colServices
Dim intServices
Dim intIncrement
Dim strBackupStartFolder
Dim strParentFolder
Dim strHTML
Dim objFSO
Dim strLOBFolder
Dim objSubFolder
Dim backupOrRestoreResponse
Sub cmdStart_onclick()
'On Error Resume Next
'Set wseExternal = _
' wshShell.Exec("Wscript.exe //NOLOGO \\10.120.28.74\scripts\Backup\nss_Backup.vbs")
'If Err.number <> 0 Then
' lblStatus.innerText = "Failed to start!"
'Else
If optBackupOrRestore(0).Checked = True Then
backupOrRestoreResponse = 0
ElseIf optBackupOrRestore(1).Checked = True Then
backupOrRestoreResponse = 1
End If
lblStatus.innerText = "Your Backup/Restore is in progress. Please do not use your keyboard or mouse ... This process could take several minutes to complete." & VbCrLf & _
"LOB: " & cbo_LOB.Value & VbCrLf & _
"Trainer: " & cbo_Trainer.Value & VbCrLf & _
"Backup Or Restore: " & backupOrRestoreResponse
cmdStart.disabled = True
cmdReset.disabled = True
buttonClose.disabled = True
'tmrExternal = window.setInterval("tmrExternal_timer", 1000, "VBScript")
' End if
End sub
'sub cmdStart_Progress()
'End sub
Sub cmdReset_onclick()
lblStatus.innerText = "Click the Start Button to begin the process:"
lblResults.innerHTML = " "
lblMore.innerHTML = ""
cmdReset.disabled = true
cmdStart.disabled = False
End Sub
'Button Close
Sub ButtonCloseClick()
If msgbox ("Are you sure you want to Close?",4,"Close Backup?") = vbYes then
window.Close
End if
End Sub
Sub Continue()
lblMore.innerHTML = _
"The Data Migration process has completed.<br>" _
& vbCrLf & "If you have just backed up your PC, please go to your new PC and run this process again, selecting '1' for restore.<P>" _
& vbCrLf & "If you have just restored you data to the new PC, then your work is done. Please double check to make sure everything was successfully transfered.<br>" _
& vbCrLf & "If you have any computer related issues, please call the IT Service Desk at 515-508-8515." _
& VbCrLf & VbCrLf
cmdReset.disabled = true
buttonClose.disabled = false
cmdStart.disabled = False
End Sub
Sub tmrExternal_timer()
With lblStatus
If wseExternal.Status = WshRunning Then
If .className = "clsIndentRed" Then
.className = "clsIndent"
Else
.className = "clsIndentRed"
End If
Else
window.clearInterval tmrExternal
.innerText = _
"Finished. Exit code " _
& CStr(wseExternal.ExitCode)
.className = "clsIndent"
Set wseExternal = Nothing
window.setTimeout "Continue", 200, "VBScript"
End If
End With
End Sub
Sub window_onload()
Set wshShell = CreateObject("WScript.Shell")
Populate_LOB
End Sub
Sub window_onunload()
Set wshShell = Nothing
End Sub
Sub Populate_LOB
Set objFSO = CreateObject("Scripting.FileSystemObject")
strLOBFolder = "\\10.120.28.74\Line_of_Business\"
If Right(strLOBFolder, 1) = "\" Then strLOBFolder = Left(strLOBFolder, Len(strLOBFolder) - 1)
strHTML = "<select size='1' name='cbo_lob' onchange='Populate_Trainer'" & VbCrLf
strHTML = strHTML & "<option selected value='cbo_select_lob'> --- Select Line Of Business --- </option>" & VbCrLf
For Each objSubFolder In objFSO.GetFolder(strLOBFolder).SubFolders
strHTML = strHTML & "<option value='" & objSubFolder.Name & "'>" & objSubFolder.Name & "</option>" & VbCrLf
Next
strHTML = strHTML & "</select>"
span_lob.InnerHTML = strHTML
End Sub
Sub Populate_Trainer
Dim boolValid
boolValid = True
strBackupStartFolder = cbo_lob.Value
If strBackupStartFolder = "Nationwide Sales Solutions" Then
strParentFolder = "\\10.120.28.74\training\"
ElseIf strBackupStartFolder = "Commercial Lines Processing Center" Then
strParentFolder = "\\10.120.28.74\Training_CLPC\"
ElseIf strBackupStartFolder = "Commercial Lines Service Center" Then
strParentFolder = "\\10.120.28.74\Training_CSC\"
ElseIf strBackupStartFolder = "PLSC_Customer Service Unit" Then
strParentFolder = "\\10.120.28.74\Training_CSU\"
ElseIf strBackupStartFolder = "PLSC_Exclusive Channel" Then
strParentFolder = "\\10.120.28.74\Training_PLSCEC\"
ElseIf strBackupStartFolder = "PLSC_Independent Channel" Then
strParentFolder = "\\10.120.28.74\Training_PLSCIC\"
ElseIf strBackupStartFolder = "Speciality Products & Boat" Then
strParentFolder = "\\10.120.28.74\Training_SPECPROD\"
ElseIf strBackupStartFolder = "Des Moines Claims Call Center" Then
strParentFolder = "\\10.120.28.74\Training_DMCCC\"
ElseIf strBackupStartFolder = "Claims_CLASS" Then
strParentFolder = "\\10.120.28.74\Training_Claims_CLASS\"
Else
MsgBox "You did not select a valid LOB."
window.Close
boolValid = False
End If
If boolValid = True Then
If Right(strParentFolder, 1) = "\" Then strParentFolder = Left(strParentFolder, Len(strParentFolder) - 1)
strHTML = "<select size='1' name='cbo_trainer'" & VbCrLf
strHTML = strHTML & "<option selected value='cbo_select_trainer'> --- Select Trainer --- </option>" & VbCrLf
For Each objSubFolder In objFSO.GetFolder(strParentFolder).SubFolders
strHTML = strHTML & "<option value='" & objSubFolder.Name & "'>" & objSubFolder.Name & "</option>" & VbCrLf
Next
strHTML = strHTML & "</select>"
span_trainer.InnerHTML = strHTML
End If
End Sub
</SCRIPT>
</HEAD>
<BODY bgcolor="white">
<img src="\\10.120.28.74\scripts\Backup\image002.gif" alt="Go"><br><br><br><br><br><br>
<H3>Data Migration Status:</H3>
<DIV id=lblStatus class=clsIndent>Ready to begin</DIV>
Select your Line of Business:
<span id="span_lob">
<select size="1" name="cbo_lob">
<option selected value="cbo_select_lob"> --- Select Line of Business --- </option>
</select>
</span>
<br>Select your Trainer:
<span id="span_trainer">
<select size="1" name="cbo_trainer">
<option selected value="cbo_select_trainer"> --- Select Trainer --- </option>
</select>
</span>
<br><br>
<input type='radio' name='optBackupOrRestore' value='optBackup' CHECKED> Backup<br>
<input type='radio' name='optBackupOrRestore' value='optRestore'> Restore<br>
<br><br>
<H3><span style="text-decoration:underline">Click the Start Button</span> to begin the process. <br><span style="text-decoration:underline">Click the Close Button</span> when the process has finished:</H3><br>
<DIV id=lblMore class=clsIndent></DIV><br>
<DIV>
<INPUT type=button id=cmdStart value="Start">
<INPUT type=button id=cmdReset value=Reset disabled>
<button accesskey=C id=buttonClose onclick=ButtonCloseClick><U>C</U>lose</button><br><br><br>
<img src="\\10.120.28.74\scripts\Backup\image001.gif" alt="Go"><br><br><br><br>
<p>
<object classid="clsid:35053A22-8589-11D1-B16A-00C0F0283628" id="ProgressBar1" height="20" width="400">
<param name="Min" value="0">
<param name="Max" value="100">
<param name="Orientation" value="0">
<param name="Scrolling" value="1">
</object>
</p><br><br>
</DIV>
</BODY>
</HTML>
ASKER
Rob,
Ok. This make a lot of sense. I will work on this when I get into the office today. Just to clarify to make sure that I have what you are saying I have included the full script I have so far.
are you saying:
1. To go down through the rest of the VBscript and tranfer each "function" to a the .hta as a Sub similar to way you currently have Sub Populate_trainer?
2. I am a little confused. Are we able to transfer all of the code to the .hta and not need the external script anymore? Or do we still need to call both.
Thanks for the help to so far. This coming along great. VBS code attached.
FullVBSCode.vbs.txt
Ok. This make a lot of sense. I will work on this when I get into the office today. Just to clarify to make sure that I have what you are saying I have included the full script I have so far.
are you saying:
1. To go down through the rest of the VBscript and tranfer each "function" to a the .hta as a Sub similar to way you currently have Sub Populate_trainer?
2. I am a little confused. Are we able to transfer all of the code to the .hta and not need the external script anymore? Or do we still need to call both.
Thanks for the help to so far. This coming along great. VBS code attached.
FullVBSCode.vbs.txt
ASKER
Rob,
I am trying to include the VBSCript into the .hta. I am able to get all the const and variables entered in. but when I list the instance, I get a vbscript runtime error. The orignal VBS works fine, but now when I pasted:
'GLOBAL OBJECT INSTANCES DECLARATIONS ************************** ********** ********** ********** ********** **
Set fso = wscript.createobject("Scri pting.File SystemObje ct")
Set shell = wscript.createobject("wscr ipt.shell" )
Set network = wscript.createobject("wscr ipt.networ k")
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objTrainers = CreateObject("Scripting.Di ctionary")
Set objLOB = CreateObject("Scripting.Di ctionary")
Set objNetwork = CreateObject("WScript.Netw ork")
Set objShell = CreateObject("WScript.Shel l")
Set objDictionary = CreateObject("Scripting.Di ctionary")
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
I get :
An error occured in the script of this page.
Line 80
Char 1
Error Variable is undefined: "wscript"
Code 0
The line in question is, "Set fso = wscript.createobject("Scri pting.File SystemObje ct")". I don't see whats wrong. fso is already declared as DIM
am I doing something wrong?
I am trying to include the VBSCript into the .hta. I am able to get all the const and variables entered in. but when I list the instance, I get a vbscript runtime error. The orignal VBS works fine, but now when I pasted:
'GLOBAL OBJECT INSTANCES DECLARATIONS **************************
Set fso = wscript.createobject("Scri
Set shell = wscript.createobject("wscr
Set network = wscript.createobject("wscr
Set objFSO = CreateObject("Scripting.Fi
Set objTrainers = CreateObject("Scripting.Di
Set objLOB = CreateObject("Scripting.Di
Set objNetwork = CreateObject("WScript.Netw
Set objShell = CreateObject("WScript.Shel
Set objDictionary = CreateObject("Scripting.Di
Set WshShell = WScript.CreateObject("WScr
I get :
An error occured in the script of this page.
Line 80
Char 1
Error Variable is undefined: "wscript"
Code 0
The line in question is, "Set fso = wscript.createobject("Scri
am I doing something wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rob,
That worked out great. Things are so much easier to manage from the .hta as opposed to the MsgBox. Thanks for all your help. If I could just figure out how to get a viable progress bar to run on my form, I would be golden. I have had an open question on that one for a while now.
That worked out great. Things are so much easier to manage from the .hta as opposed to the MsgBox. Thanks for all your help. If I could just figure out how to get a viable progress bar to run on my form, I would be golden. I have had an open question on that one for a while now.
http://www.visualbasicscri
From MS...
http://www.microsoft.com/t