Re: Array and InputBox Integration ?
- From: "Tom Lavedas" <tglbatch@xxxxxxx>
- Date: 13 Feb 2007 10:06:20 -0800
On Feb 13, 10:19 am, "Script-Newb" <ClayT...@xxxxxxxxx> wrote:
On Feb 12, 4:51 pm, Jeffery Hicks <"jhicks[at]SAPIEN.com"> wrote:
On 12 Feb 2007 13:19:06 -0800, Script-Newb wrote:
All,
I am having a little trouble getting values of an array to number
themselves in an InputBox for a user to make their choice.
Script Goal = Get a list of all the local user accounts and display
them to a user to choose one of them and store their choice as a
variable for other uses later on.
What I have so far:
Set oNet = CreateObject("Wscript.Network")
strComputer = oNet.ComputerName
ListLocalAccounts
Sub ListLocalAccounts
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
'This is where I need to make a visible choice list for users to
'Select their old account they were using prior to domain join
WScript.Echo objUser.Name
Next
End Sub
I can get them individually into a inputbox and have a user selct yes
or no but would like it to be a numbered list where they can just pick
a number.
Thanks in advance
Clay
You're limited by the size of the InputBox but I've done things like this:
strMenu=strMenu & "Menu" & VbCrLf
strMenu=strMenu & "1 - apple" & vbCrlf
strMenu=strMenu & "2 - orange" & vbCrlf
strMenu=strMenu & "3 - banana" & vbCrlf
strMenu=strMenu & "Make a selection [1,2,3]"
iOption=InputBox(strMenu,"Menu",1)
WScript.Echo iOption
Select Case CInt(iOption)
Case 1 wscript.echo "you picked apple"
Case 2 wscript.echo "you picked orange"
Case 3 wscript.echo "you picked banana"
Case Else
WScript.Echo "Invalid choice: " & iOption
End Select
--
Jeffery Hicks
SAPIEN Technologies - Scripting, Simplified.www.SAPIEN.com
VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp
Windows PowerShell? -www.SAPIENPress.com/powershell.asp
blog:http://blog.SAPIEN.com
blog:http://jdhitsolutions.blogspot.com-Hide quoted text -
- Show quoted text -
Thanks for the input but the problem is that i will not know what the
menu options will be or the quantity.
I am pulling all the local accounts off the machine which will vary
from 3-7 accounts. I want to take each one the array finds and make
it a numbered option in an inputbox. I want to use straight vbs/wsh
and not get into an HTA type thing since this inputbox will only be
for on error branch that I hope it will never have to take.
Clay
Come on, be a little creative. Mr. Hicks gave you the basic structure
of what you wanted. Just build the menu string using a variable,
rather than use the literal strings, something like this ...
Sub ListLocalAccounts
Dim aNames(), s, objUser, colAccounts
Set colAccounts = GetObject("WinNT://" & strComputer)
colAccounts.Filter = Array("user")
s = "Enter the number of your selection from below:" & vbNewline
n = 0
For Each objUser In colAccounts
ReDim aNames(n)
aNames(n) = objUser.Name
n = n + 1
s = s & n & ". " & objUser.Name & vbNewline
Next
'This is where you put the choice list for users to
'select the account they were using prior to domain join
Do while n > 0 ' Loops until a 'proper' entry is made
sSelection = InputBox(s, "Make a selection")
if CInt(sSelection) > 0 and CInt(sSelection) <= n Then exit do
msgbox "Your entry was invalid"
Loop
if n > 0 then
' whatever processing is desired goes here
msgbox "You selected: " & aNames(sSelection - 1)
else
msgbox "UNEXPECTED ERROR - No users found."
end if
End Sub
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
.
- Follow-Ups:
- Re: Array and InputBox Integration ?
- From: Tom Lavedas
- Re: Array and InputBox Integration ?
- References:
- Re: Array and InputBox Integration ?
- From: Script-Newb
- Re: Array and InputBox Integration ?
- Prev by Date: Re: Array and InputBox Integration ?
- Next by Date: Re: Array and InputBox Integration ?
- Previous by thread: Re: Array and InputBox Integration ?
- Next by thread: Re: Array and InputBox Integration ?
- Index(es):
Relevant Pages
|