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!

Bullet list Select Case 1

Status
Not open for further replies.

GrimR

IS-IT--Management
Jun 17, 2007
1,149
ZA
Need help to finish this one a little stuck
Error is object required:"

I'm not sure if I'm passing the response on correctly either.
Does the Case need to be 1 or "1" neither working

Code:
Dim bullet
Dim response
Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
bullet = Chr(10) & "   " & Chr(149) & " "
Do
    response = InputBox("Please enter the script number you wish to run next:" & Chr(10) & bullet & "1.) MoveToCopyTo" & bullet & "2.) RegistryEntries" & bullet & "3.) CreateFolders" & bullet & "4.) Wallpaper" & bullet & "5.) DescriptioninAD" & Chr(10), "Select Thing")
    If response = "" Then WScript.Quit  'Detect Cancel
    If IsNumeric(response) Then Exit Do 'Detect value response.
    MsgBox "You must enter a numeric value.", 48, "Invalid Entry"
Loop

result = response

Select Case result

Case "1"
		strFolder = objFSO.GetParentFolderName(WScript.ScriptFullName)
		sf = (strFolder & "\2GTDBNMoveToCopyTo.vbs")
		WshShell.Run(chr(34) & sf & chr(34))
Case "2"
		strFolder = objFSO.GetParentFolderName(WScript.ScriptFullName)
		sf = (strFolder & "\3GTDBNRegistryEntries.vbs")
		WshShell.Run(chr(34) & sf & chr(34))
		
Case "3"
		strFolder = objFSO.GetParentFolderName(WScript.ScriptFullName)
		sf = (strFolder & "\4GTDBNCreateFolders.vbs")
		WshShell.Run(chr(34) & sf & chr(34))

Case "4"
		strFolder = objFSO.GetParentFolderName(WScript.ScriptFullName)
		sf = (strFolder & "\5GTDBNWallpaper.vbs")
		WshShell.Run(chr(34) & sf & chr(34))

Case "5"
		strFolder = objFSO.GetParentFolderName(WScript.ScriptFullName)
		sf = (strFolder & "\6DescriptioninAD.vbs")
		WshShell.Run(chr(34) & sf & chr(34))
		
End Select

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
You have to create the WshShell object before using it.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
So simple.
Thanks

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Is there a way to use a sub something like below to make it look cleaner, I just don't have the know how to get it working.

Code:
Dim bullet, response
Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim WshShell:Set WshShell = WScript.CreateObject("WScript.Shell")
bullet = Chr(10) & "   " & Chr(149) & " "

Do
    response = InputBox("Please enter the script number you wish to run next:" & Chr(10) & bullet &_
	"0.) Quit" & bullet & "1.) Script1" & bullet & "2.) Another Scrit" & Chr(10), 4096, "Select a script to Run")
	
    If response = "" Then 
		MsgBox "Enter a Value between 1 and 8, OR 0 to Quit"
	else if response = "0" then WScript.Quit  
    If IsNumeric(response) Then Exit Do 
		MsgBox "You must enter a numeric value.", 48, "Invalid Entry"
	end if
Loop

start = response

Select Case start(script)

Case "1"
		scriptname = ("\Scriptorun.vbs")

Case "2"
		scriptname = ("\Another.vbs")	
		
End Select

Sub script
		strFolder = objFSO.GetParentFolderName(WScript.ScriptFullName)
		sf = (strFolder & scriptname)
		WshShell.Run(chr(34) & sf & chr(34))
End Sub

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
No need for a Sub
Code:
...
Select Case start(script)
Case "1"
	scriptname = ("\Scriptorun.vbs")
Case "2"
	scriptname = ("\Another.vbs")	
End Select
strFolder = objFSO.GetParentFolderName(WScript.ScriptFullName)
sf = (strFolder & scriptname)
WshShell.Run(chr(34) & sf & chr(34))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV , works, of course, you make it look easy.

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Sorry for the typo, replace this:
Select Case start(script)
with this:
Select Case start

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thanks, figured as much

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top