Page 1 of 1 1
Topic Options
#169659 - 2006-10-20 01:19 AM Inputing users/groups into scripts
jeremyschubert Offline
Getting the hang of it

Registered: 2005-09-17
Posts: 89
My teachers want to restrict access to a color printer. So I'm writing a script that will allow them to enter the name of user(s) or a global group. The script should then apply that list to a loop that will add each object to the appropriate group (using the GroupAdd UDF by Bryce). I'm trying to search for information on what kix commands to use that will create a list of users for the loop to draw on. What search terms should I be using? (I've tried 'inputting users into a script' in Google and this forum but that didn't help).

Thanks,
_________________________
---
Bishop Grandin Technology Department
'Either we're on time, or we're late'

Top
#169660 - 2006-10-20 01:48 AM Re: Inputing users/groups into scripts
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, what you are after is a scriptlet that will list users in a group?
Top
#169661 - 2006-10-20 07:20 AM Re: Inputing users/groups into scripts
jeremyschubert Offline
Getting the hang of it

Registered: 2005-09-17
Posts: 89
I don't think that's what I'm looking for exactly. I'm looking for the descriptors I should use in a search engine when looking for how to pass user name(s) into a loop. Is that what an array is used for?
_________________________
---
Bishop Grandin Technology Department
'Either we're on time, or we're late'

Top
#169662 - 2006-10-20 07:24 AM Re: Inputing users/groups into scripts
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh, you are looking for basics?
yes, array is the simpliest way to do this.

$usernames="billy","joan","basta","jenny"

and that's the array.
then just fly with the values:
for each $username in $usernames
" -> " $username ?
next

Top
#169663 - 2006-10-20 07:29 AM Re: Inputing users/groups into scripts
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
if the list is input on some text field, you could use "name, name2, name3" format instead.
when the input is done, then just do split() on the names string and it becomes array.

Top
#169664 - 2006-10-20 07:36 AM Re: Inputing users/groups into scripts
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Something like this should get you all the user names

UNTESTED

Code:
$DomainObj = GetObject("WinNT://" + @Domain)
$DomainObj.Filter = Array("User",)

For Each $UserObj in $DomainObj
$UserObj.Name ?
Next


Top
#169665 - 2006-10-20 10:37 AM Re: Inputing users/groups into scripts
jeremyschubert Offline
Getting the hang of it

Registered: 2005-09-17
Posts: 89
So, if I wanted teachers to be able to enter specific names, my kixforms script would look something like this?
Code:

$InputBox = $AddToPrinterGroup.InputBox()
Show( "Please enter the student user name(s) who should be given access to the Xerox printer."Chr(13)"Seperate names with a semi-colon (;)", Student Name Entry, xpos, ypos)
Translate the teacher's entries to variable $names
for each $username in $usernames
" -> " $username ?
next



How do I Translate the teacher's entries to variable $names
Thanks,
_________________________
---
Bishop Grandin Technology Department
'Either we're on time, or we're late'

Top
#169666 - 2006-10-20 11:02 AM Re: Inputing users/groups into scripts
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well forgot you were working on a KIXForms project.

Think you need to provide the link to that post / or post your current script here so that people can see the bigger picure here.

Top
#169667 - 2006-10-20 02:16 PM Re: Inputing users/groups into scripts
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Code:



Break On
$System = CreateObject("Kixtart.System")


;************* Form **************
$ADForm = $System.Form()
$ADForm.FormBorderStyle = 3
$ADForm.Height = 435
$ADForm.MaximizeBox = "False"
$ADForm.MinimizeBox = "False"
$ADForm.Text = ""
$ADForm.Width = 195
;**************************************

;************* TextBox1 **************
$ADTextBox1 = $ADForm.Controls.TextBox("", 5, 5, 175, 20)
$ADTextBox1.OnKeyDown = "FindUser()"
;**************************************

;************* ListBox1 **************
$ADListBox1 = $ADForm.Controls.ListBox("", 5, 35, 175, 330)
$ADlistBox1.Sorted = "True"
$ADlistBox1.OnClick = "ListBoxClicked"
$ADlistBox1.OnDoubleClick = "ListBoxdblClicked"
;**************************************

;************* TextBox2 **************
$ADTextBox2 = $ADForm.Controls.TextBox("", 5, 375, 175, 20)
$ADTextBox2.BackColor = 212,208,200
$ADTextBox2.BorderStyle = 0
$ADTextBox2.ReadOnly = "True"
$ADTextBox2.TabStop = "False"
;**************************************



;************* ProgForm **************
$ProgForm = $System.Form()
$ProgForm.FormBorderStyle = 0
$ProgForm.Height = 60
$ProgForm.StartPosition = 4
$ProgForm.Text = ""
$ProgForm.TopMost = "True"
$ProgForm.Width = 300
;**************************************

;************* PBar1 **************
$PBar1 = $ProgForm.Controls.ProgressBar("PBar1", 15, 30, 267, 11)
;**************************************

;************* Label1 **************
$pbLabel1 = $ProgForm.Controls.Label("Collecting Usernames", 60, 10, 170, 16)



GetUsers()


While $ADForm.Visible
$=Execute($ADForm.DoEvents())
Loop
Exit 1




Function GetUsers()
$target = $button
$ADForm.Show
if $adListBox1.ListCount <1
$ProgForm.Show
$oDomain = GetObject("WinNT://@LDomain")
$oDomain.filter = "User",""
For Each $oUser In $oDomain
if instr($oUser.FullName,',') or instr($oUser.FullName,'=') > 0
$adlistbox1.additem($oUser.FullName)
$adTextBox2.text = '' + $adListBox1.ListCount + ' Items found'
endif
$PBar1.Value = iif($PBar1.Value < $PBar1.Max,$PBar1.Value + 1,0) ;for progress bar only
Next
$ProgForm.Hide
Endif
$adTextBox1.SetFocus
; $rc = SENDKEYS ("^{END}")
EndFunction

Function Finduser(optional $skip)
select
case $adTextBox1.KeyCode=13 and not $skip
; ********************************************************************
; ***** This is the section that returns the selected username *****
; ***** back to your main form *****
; ***** $ReturnText.text = text of the name *****
; ***** $ReturnLDAP = the ldap string of the selected acct *****
; ********************************************************************
$ADForm.Hide
$adTextBox1.text = $adListBox1.Text
$nameLDAP = TranslateName(1, @domain, 4, $adListBox1.Text, 1)
if $nameLDAP[1] = 0
$ReturnText.text = $adListBox1.Text
$ReturnLDAP = $nameLDAP[0]
endif
case $adTextBox1.KeyCode=40 and not $skip and $adListBox1.ListIndex +1 < $adListBox1.ListCount
$adListBox1.ListIndex = $adListBox1.ListIndex +1
$adTextBox1.text = $adListBox1.Text
$adTextBox1.SetFocus()
$rc = SENDKEYS ("^{END}")
case $TextBox1.KeyCode=38 and not $skip and $adListBox1.ListIndex -1 > 0
$adListBox1.ListIndex = $adListBox1.ListIndex -1
$adTextBox1.text = $adListBox1.Text
$adTextBox1.SetFocus()
$rc = SENDKEYS ("^{END}")
case 1
for $element=0 to $adListBox1.ListCount - 1
if left($adListBox1.List($element),len($adTextBox1.text))=$adTextBox1.text
$adListBox1.ListIndex = $element
$element = $adListBox1.ListCount
endif
next
endselect
EndFunction

Function ListBoxClicked()
$adTextBox1.text = $adListBox1.Text
$adTextBox1.SetFocus()
$rc = SENDKEYS ("^{END}")

EndFunction

Function TranslateName($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
Dim $InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType
Dim $NameTranslate, $ReturnName, $Error, $ErrorText
$Error = 0 $ErrorText = "" $ReturnName = ""
$NameTranslate = CREATEOBJECT ("NameTranslate") $Error = @error $ErrorText = @serror
if $Error = 0
$NameTranslate.Init ($InitType, $BindName) $Error = @error $ErrorText = @serror
if $Error = 0
$NameTranslate.Set ($LookupNameType, $LookupName) $Error = @error $ErrorText = @serror
if $Error = 0
$ReturnName = $NameTranslate.Get($ReturnNameType) $Error = @error $ErrorText = @serror
endif
endif
endif
$TranslateName = $ReturnName, $Error, $ErrorText
Endfunction


Top
#169668 - 2006-10-20 09:10 PM Re: Inputing users/groups into scripts
jeremyschubert Offline
Getting the hang of it

Registered: 2005-09-17
Posts: 89
I am posting my script to try and make my intentions more clear.
The red line is where my knowledge lacks (OK, one of the places my knowledge lakcs!)
And I'll take a moment to say I really appreciate all the people who have the talent to creat UDFs and who post them in the UDF libraries for us newbies!

Code:

;NAME AddStudentToXeroxPrinterGroup.kix
;AUTHOR Jeremy Schubert
;PURPOSE Allows to add students to the Xerox printer group which will allow the students
;to print to that printer.

Break On
$System = CreateObject("Kixtart.System")

If Not $System
$nul= MessageBox("KiXforms Not Initiated. This Script Will Now Close.","Error",16)
Quit()
EndIf

HTMLInputBox("Please enter the user name of the student to be added to the Xerox Printer Group.", "Add Students To Xerox Printer Group","Names","SUBMIT","","","CANCEL","")


$usernames=names ;value of the box that shows in the HTMLInputBox function


For Each $username in $usernames
" GroupAdd (CSSDSTU, GG047-XeroxPrinter, $username)
Next

While $Form.Visible
$nul = Execute($Form.DoEvents)
Loop
Exit 1

Function HTMLInputBox() - Displays an Input-Box via IE

; Function HTMLInputBox() - Displays an Input-box via IE
;
; Author: Steve O ; posted as UDF by NTDOC
; Posted in Beta forum - http://www.kixtart.org/ubbthreads/showthreaded.php?Cat=0&Number=77407
;
; ACTION: Displays an Input-box that allows a user to input a string. This box is HTML based and
; uses the Internet Explorer Application object.
;
; SYNTAX: HTMLInputBox("HTML Message", OPTIONAL "Window Title","Default Value","Button Text","Text Color",
; "Background Color", "Alt Button Text","Alt Button Return Value")
;
; Version: 1.0
;
; Date: Sep 27 2001
;
; Date Revised:
;
; Revision Reason:
;
; PARAMETERS:
; HTML Message: The message for the Input Box. ex: What is your favorite color?
; Note: This can accept any HTML code, so go to town! Also Note: the tag is enabled, so if you want to do
; custom HTML, put
as the first tag.
; Window Title: ( OPTIONAL ) The title of the HTML Input Box Window. If blank, defaults to "Question...".
; Default Value: ( OPTIONAL ) The default value for the box which will show when the box appears.
; If blank, defaults to blank.
; Button Text: ( OPTIONAL ) The text on the main button. If blank, default is "SUBMIT".
; Text Color: ( OPTIONAL ) The color of text on the input box. If blank, this defaults to black.
; Note: This can be overridden by including additional HTML tags in the HTML Message.
; Background Color: ( OPTIONAL ) The color of the background of the HTML form. Defaults to silver.
; Alt Button Text: ( OPTIONAL ) If this is specified, an alternate button will appear on the form and
; if clicked, the function will (by default) return "-1". This is useful as a "HELP" button, or
; for many other purposes.
; Alt Button Return Value: ( OPTIONAL ) If the Alt button is needed, and -1 is a potential legitimate
; return value for the main submit button, you can specify an alternate return value for the alternate button.
;
; REMARKS:
; This has been tested by the author on Win 98 and Win 2k machines. It should require at least IE 4.0
; to function, however it does not check the IE version before executing.
;
; RETURNS:
; The string in the text box, or another value if the "Alternate button" is pressed. The alternate value
; defaults to -1, but can be changed by specifying the "Alt Button Return Value".
;
; Dependencies: IE, KiXtart 4.x
;
; EXAMPLE:
; HTMLInputBox("What is your favorite color?","Color Quiz","Red","Submit Me!","Black","Yellow","I don't know!!!")
;
; Source:

Function HTMLInputBox($L_Prompt, OPTIONAL $L_Title,$L_DefaultValue,$L_ButtonText,$L_TextColor,$L_BGColor,$L_AltButtonText,$L_AltButtonReturnValue)
Dim $HTML, $AppIE, $SF
If $L_Title = ""
$L_Title = "Question..."
EndIf

If $L_ButtonText = ""
$L_ButtonText = "Submit"
EndIf

If $L_AltButtonReturnValue = ""
$L_AltButtonReturnValue = -1
EndIf

Select
Case $L_TextColor = "Black"
$L_TextColor = "000000"
Case $L_TextColor = "Silver"
$L_TextColor = "C0C0C0"
Case $L_TextColor = "Gray"
$L_TextColor = "808080"
Case $L_TextColor = "White"
$L_TextColor = "FFFFFF"
Case $L_TextColor = "Maroon"
$L_TextColor = "800000"
Case $L_TextColor = "Red"
$L_TextColor = "FF0000"
Case $L_TextColor = "Purple"
$L_TextColor = "800080"
Case $L_TextColor = "Fuchsia"
$L_TextColor = "FF00FF"
Case $L_TextColor = "Green"
$L_TextColor = "008000"
Case $L_TextColor = "Lime"
$L_TextColor = "00FF00"
Case $L_TextColor = "Olive"
$L_TextColor = "808000"
Case $L_TextColor = "Yellow"
$L_TextColor = "FFFF00"
Case $L_TextColor = "Navy"
$L_TextColor = "000080"
Case $L_TextColor = "Blue"
$L_TextColor = "0000FF"
Case $L_TextColor = "Teal"
$L_TextColor = "008080"
Case $L_TextColor = "Aqua"
$L_TextColor = "00FFFF"
Case $L_TextColor = ""
$L_TextColor = "000000"
EndSelect

Select
Case $L_BGColor = "Black"
$L_BGColor = "000000"
Case $L_BGColor = "Silver"
$L_BGColor = "C0C0C0"
Case $L_BGColor = "Gray"
$L_BGColor = "808080"
Case $L_BGColor = "White"
$L_BGColor = "FFFFFF"
Case $L_BGColor = "Maroon"
$L_BGColor = "800000"
Case $L_BGColor = "Red"
$L_BGColor = "FF0000"
Case $L_BGColor = "Purple"
$L_BGColor = "800080"
Case $L_BGColor = "Fuchsia"
$L_BGColor = "FF00FF"
Case $L_BGColor = "Green"
$L_BGColor = "008000"
Case $L_BGColor = "Lime"
$L_BGColor = "00FF00"
Case $L_BGColor = "Olive"
$L_BGColor = "808000"
Case $L_BGColor = "Yellow"
$L_BGColor = "FFFF00"
Case $L_BGColor = "Navy"
$L_BGColor = "000080"
Case $L_BGColor = "Blue"
$L_BGColor = "0000FF"
Case $L_BGColor = "Teal"
$L_BGColor = "008080"
Case $L_BGColor = "Aqua"
$L_BGColor = "00FFFF"
Case $L_BGColor = ""
$L_BGColor = "C0C0C0"
EndSelect

$HTML = '' +
'' +
'' + $L_Title + '' +
$L_Prompt + '
' +
'
' +
'
' +
'' value="' + $L_DefaultValue + '" Tabindex="1"> ' +
'' +
'' onclick="CompTrends.Submitted.value=1" Tabindex="2">'

If $L_AltButtonText <> ""
$HTML = $HTML + '' onclick="CompTrends.Submitted.value=2" Tabindex="3">'
EndIf

$HTML = $HTML + '
' +
''

$AppIE = CreateObject("InternetExplorer.Application")

;Set IE Object Properties
$appIE.top = 30
$appIE.left = 30
$appIE.height = 350
$appIE.width = 500
$appIE.addressbar = 0
$appIE.menubar = 0
$appIE.toolbar = 0
$appIE.statusbar = 0
$appIE.resizeable = 0
$appIE.navigate("about:blank")
While $AppIE.busy <> 0 And @ERROR = 0 Loop

;Write the HTML code to the document
$AppIE.document.write($HTML)

While $AppIE.busy <> 0 And @ERROR = 0 Loop

;Make IE visible and set focus
$AppIE.visible = 1
$SF = SetFocus("about:blank - Microsoft Internet Explorer")
$AppIE.document.GetElementById("Answer").focus

Dim $L_LastBoxValue,$L_LastBoxValueCache
While $appIE.document.GetElementById("Submitted").value = 0
If $appIE.document.GetElementById("Submit").value = " " + $L_ButtonText + " "
If $appIE.document.GetElementById("Answer").value <> ""
$L_LastBoxValue = $appIE.document.GetElementById("Answer").value
If $L_LastBoxValue <> ""
$L_LastBoxValueCache = $L_LastBoxValue
EndIf
EndIf
EndIf
Loop

If $AppIE.document.GetElementById("Submitted").value = 2
$HTMLInputBox = $L_AltButtonReturnValue
Else
$HTMLInputBox = $L_LastBoxValueCache
EndIf

$AppIE.QUIT
$AppIE = ""
EndFunction

GroupAdd() - Ads a User/Group to a Group Global/Local

Code:
--------------------------------------------------------------------------------

;NAME GroupAdd
;
;AUTHOR ???
;
;ACTION Add's a object (user or group) to a group (global or local)
;
;SYNTAX GroupAdd(Target, Group, Object To add)
;
;PARAMETERS Target
; The Domain name or Workstation To work with. For faster workstation
; execution, include the Domain Name that the workstation is a meber of.
;
; "Kixtart/beanbag" would be working with the workstation Beanbag In the
; Kixtart domain
;
; Group
; The Group you want To add To
;
; Object To add
; This can be a local group or a userid, depending on what type of group
; the Group variable is. Always try To give the full name of the object.
;
;
;RETURNS @ERROR code
;
;REMARKS ADSI com object must be installed.
;
;EXAMPLES ;this adds the domain user "testuser" To the Global group "Domain Admins"
; $nul = groupadd("kixtart","Domain admins","testuser")
;
; ;this adds the user "testuser" In the domain "kixtart" To the local administrators
; ;group on the workstation beanbag
; $nul = Groupadd("kixtart/beanbag", "administrators", "kixtart\testuser")
Function GroupAdd($Target, $Group, $ObjToAdd)
Dim $target, $group, $OBJToAdd, $obj, $objhome

If SubStr($target,1,2) = '\\'
$target = SubStr($target,3,Len($target))
EndIf
If InStr($objtoadd,'\') <> 0
$objtoadd = Split($objtoadd,'\')
If UBound($objtoadd) <> 1 Exit 13 EndIf
$objhome = $objtoadd[0]
$obj = $objtoadd[1]
Else
$objhome = $target
$obj = $objtoadd
EndIf

$group = GetObject('WinNT://' + $target + '/' + $group)
If VarType($group) = 9 And @ERROR = 0
$group.Add ('WinNT://'+$objhome+'/'+$obj)
Else
$GroupAdd = @ERROR
Exit @ERROR
EndIf
$GroupAdd = @ERROR
Exit @ERROR
EndFunction

_________________________
---
Bishop Grandin Technology Department
'Either we're on time, or we're late'

Top
#169669 - 2006-10-20 09:24 PM Re: Inputing users/groups into scripts
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well I've taken your code and used PostPrep to post it
which attempts to allow certain html coding to be displayed.

Notice that you have mis-matched quotes which is why the
syntax coloring is off on the post as well here.

I've added some comments and have changed some indenting.

Your HTMLInput UDF is rather large and I would really work
on that as an individual UDF and make sure it works as
expected in a self contained script until you know it is
working the way you want it.

Basically review your code and remove the mis-matched quotes
and remark or remove stuff that is not code you expect to
operate as part of the script.

;NAME AddStudentToXeroxPrinterGroup.kix 
;AUTHOR Jeremy Schubert
;PURPOSE Allows to add students to the Xerox printer group which will allow the students
;to print to that printer.

Break On
$System = CreateObject("Kixtart.System")

If Not $System
$nul= MessageBox("KiXforms Not Initiated. This Script Will Now Close.","Error",16)
Quit()
EndIf

HTMLInputBox("Please enter the user name of the student to be added to the Xerox Printer Group.", "Add Students To Xerox Printer Group","Names","SUBMIT","","","CANCEL","")

;How do I do the array here?
$usernames=names ;value of the box that shows in the HTMLInputBox function

For Each $username in $usernames
;Well I see a quote that does not belong here
" GroupAdd (CSSDSTU, GG047-XeroxPrinter, $username)
Next

While $Form.Visible
$nul = Execute($Form.DoEvents)
Loop
Exit 1

;You can't leave the description of the UDF here and have it run
;You need to use a semi-colon to remark it out


Function HTMLInputBox() - Displays an Input-Box via IE

; Function HTMLInputBox() - Displays an Input-box via IE
;
; Author: Steve O ; posted as UDF by NTDOC
; Posted in Beta forum - http://www.kixtart.org/ubbthreads/showthreaded.php?Cat=0&Number=77407
;
; ACTION: Displays an Input-box that allows a user to input a string. This box is HTML based and
; uses the Internet Explorer Application object.
;
; SYNTAX: HTMLInputBox("
HTML Message", OPTIONAL "Window Title","Default Value","Button Text","Text Color",
; "
Background Color", "Alt Button Text","Alt Button Return Value")
;
; Version: 1.0
;
; Date: Sep 27 2001
;
; Date Revised:
;
; Revision Reason:
;
; PARAMETERS:
; HTML Message: The message for the Input Box. ex: What is your favorite color?
; Note: This can accept any HTML code, so go to town! Also Note: the tag is enabled, so if you want to do
; custom HTML, put
as the first tag.
; Window Title: ( OPTIONAL ) The title of the HTML Input Box Window. If blank, defaults to "
Question...".
; Default Value: ( OPTIONAL ) The default value for the box which will show when the box appears.
; If blank, defaults to blank.
; Button Text: ( OPTIONAL ) The text on the main button. If blank, default is "
SUBMIT".
; Text Color: ( OPTIONAL ) The color of text on the input box. If blank, this defaults to black.
; Note: This can be overridden by including additional HTML tags in the HTML Message.
; Background Color: ( OPTIONAL ) The color of the background of the HTML form. Defaults to silver.
; Alt Button Text: ( OPTIONAL ) If this is specified, an alternate button will appear on the form and
; if clicked, the function will (by default) return "
-1". This is useful as a "HELP" button, or
; for many other purposes.
; Alt Button Return Value: ( OPTIONAL ) If the Alt button is needed, and -1 is a potential legitimate
; return value for the main submit button, you can specify an alternate return value for the alternate button.
;
; REMARKS:
; This has been tested by the author on Win 98 and Win 2k machines. It should require at least IE 4.0
; to function, however it does not check the IE version before executing.
;
; RETURNS:
; The string in the text box, or another value if the "
Alternate button" is pressed. The alternate value
; defaults to -1, but can be changed by specifying the "
Alt Button Return Value".
;
; Dependencies: IE, KiXtart 4.x
;
; EXAMPLE:
; HTMLInputBox("
What is your favorite color?","Color Quiz","Red","Submit Me!","Black","Yellow","I don't know!!!")
;
; Source:

Function HTMLInputBox($L_Prompt, OPTIONAL $L_Title,$L_DefaultValue,$L_ButtonText,$L_TextColor,$L_BGColor,$L_AltButtonText,$L_AltButtonReturnValue)
Dim $HTML, $AppIE, $SF
If $L_Title = ""
$L_Title = "Question..."
EndIf

If $L_ButtonText = ""
$L_ButtonText = "Submit"
EndIf

If $L_AltButtonReturnValue = ""
$L_AltButtonReturnValue = -1
EndIf

Select
Case $L_TextColor = "Black"
$L_TextColor = "000000"
Case $L_TextColor = "Silver"
$L_TextColor = "C0C0C0"
Case $L_TextColor = "Gray"
$L_TextColor = "808080"
Case $L_TextColor = "White"
$L_TextColor = "FFFFFF"
Case $L_TextColor = "Maroon"
$L_TextColor = "800000"
Case $L_TextColor = "Red"
$L_TextColor = "FF0000"
Case $L_TextColor = "Purple"
$L_TextColor = "800080"
Case $L_TextColor = "Fuchsia"
$L_TextColor = "FF00FF"
Case $L_TextColor = "Green"
$L_TextColor = "008000"
Case $L_TextColor = "Lime"
$L_TextColor = "00FF00"
Case $L_TextColor = "Olive"
$L_TextColor = "808000"
Case $L_TextColor = "Yellow"
$L_TextColor = "FFFF00"
Case $L_TextColor = "Navy"
$L_TextColor = "000080"
Case $L_TextColor = "Blue"
$L_TextColor = "0000FF"
Case $L_TextColor = "Teal"
$L_TextColor = "008080"
Case $L_TextColor = "Aqua"
$L_TextColor = "00FFFF"
Case $L_TextColor = ""
$L_TextColor = "000000"
EndSelect

Select
Case $L_BGColor = "Black"
$L_BGColor = "000000"
Case $L_BGColor = "Silver"
$L_BGColor = "C0C0C0"
Case $L_BGColor = "Gray"
$L_BGColor = "808080"
Case $L_BGColor = "White"
$L_BGColor = "FFFFFF"
Case $L_BGColor = "Maroon"
$L_BGColor = "800000"
Case $L_BGColor = "Red"
$L_BGColor = "FF0000"
Case $L_BGColor = "Purple"
$L_BGColor = "800080"
Case $L_BGColor = "Fuchsia"
$L_BGColor = "FF00FF"
Case $L_BGColor = "Green"
$L_BGColor = "008000"
Case $L_BGColor = "Lime"
$L_BGColor = "00FF00"
Case $L_BGColor = "Olive"
$L_BGColor = "808000"
Case $L_BGColor = "Yellow"
$L_BGColor = "FFFF00"
Case $L_BGColor = "Navy"
$L_BGColor = "000080"
Case $L_BGColor = "Blue"
$L_BGColor = "0000FF"
Case $L_BGColor = "Teal"
$L_BGColor = "008080"
Case $L_BGColor = "Aqua"
$L_BGColor = "00FFFF"
Case $L_BGColor = ""
$L_BGColor = "C0C0C0"
EndSelect

$HTML = '
<HTML>' +
'
<BODY TEXT=' + $L_TextColor + ' BGCOLOR=' +
$L_BGColor + '
>' +
'
<TITLE>' + $L_Title + '</TITLE><B>' +
$L_Prompt + '
</B>' +
'
<form name=CompTrends>' +
'
<BR>' +
'
<input id=Answer name=Answer class=tbox' +
'
value="' + $L_DefaultValue + '" Tabindex="1"> ' +
'
<input id=Submitted name=Submitted type=hidden value=0>' +
'
<input id=Submit name=Submit type=button value=" ' +
$L_ButtonText + ' "
' +
'
onclick="CompTrends.Submitted.value=1" Tabindex="2">'

If $L_AltButtonText <> ""
$HTML = $HTML + '
<input id=AltButton name=AltButton type=button value=" ' +
$L_AltButtonText + ' "
' +
'
onclick="CompTrends.Submitted.value=2" Tabindex="3">'
EndIf

$HTML = $HTML + '
</FORM>' +
'
</BODY></HTML>'

$AppIE = CreateObject("InternetExplorer.Application")

;Set IE Object Properties
$appIE.top = 30
$appIE.left = 30
$appIE.height = 350
$appIE.width = 500
$appIE.addressbar = 0
$appIE.menubar = 0
$appIE.toolbar = 0
$appIE.statusbar = 0
$appIE.resizeable = 0
$appIE.navigate("about:blank")
While $AppIE.busy <> 0 And @ERROR = 0 Loop

;Write the HTML code to the document
$AppIE.document.write($HTML)

While $AppIE.busy <> 0 And @ERROR = 0 Loop

;Make IE visible and set focus
$AppIE.visible = 1
$SF = SetFocus("about:blank - Microsoft Internet Explorer")
$AppIE.document.GetElementById("Answer").focus

Dim $L_LastBoxValue,$L_LastBoxValueCache
While $appIE.document.GetElementById("Submitted").value = 0
If $appIE.document.GetElementById("Submit").value = " " + $L_ButtonText + " "
If $appIE.document.GetElementById("Answer").value <> ""
$L_LastBoxValue = $appIE.document.GetElementById("Answer").value
If $L_LastBoxValue <> ""
$L_LastBoxValueCache = $L_LastBoxValue
EndIf
EndIf
EndIf
Loop

If $AppIE.document.GetElementById("Submitted").value = 2
$HTMLInputBox = $L_AltButtonReturnValue
Else
$HTMLInputBox = $L_LastBoxValueCache
EndIf

$AppIE.QUIT
$AppIE = ""
EndFunction

GroupAdd() - Ads a User/Group to a Group Global/Local

;You can'
t leave extraneous code in your script it will error out
Code:
--------------------------------------------------------------------------------

;NAME GroupAdd
;
;AUTHOR ???
;
;ACTION Add's a object (user or group) to a group (global or local)
;
;SYNTAX GroupAdd(Target, Group, Object To add)
;
;PARAMETERS Target
; The Domain name or Workstation To work with. For faster workstation
; execution, include the Domain Name that the workstation is a meber of.
;
; "Kixtart/beanbag" would be working with the workstation Beanbag In the
; Kixtart domain
;
; Group
; The Group you want To add To
;
; Object To add
; This can be a local group or a userid, depending on what type of group
; the Group variable is. Always try To give the full name of the object.
;
;
;RETURNS @ERROR code
;
;REMARKS ADSI com object must be installed.
;
;EXAMPLES ;this adds the domain user "testuser" To the Global group "Domain Admins"
; $nul = groupadd("kixtart","Domain admins","testuser")
;
; ;this adds the user "testuser" In the domain "kixtart" To the local administrators
; ;group on the workstation beanbag
; $nul = Groupadd("kixtart/beanbag", "administrators", "kixtart\testuser")
Function GroupAdd($Target, $Group, $ObjToAdd)
Dim $target, $group, $OBJToAdd, $obj, $objhome

If SubStr($target,1,2) = '\\'
$target = SubStr($target,3,Len($target))
EndIf
If InStr($objtoadd,'\') <> 0
$objtoadd = Split($objtoadd,'\')
If UBound($objtoadd) <> 1 Exit 13 EndIf
$objhome = $objtoadd[0]
$obj = $objtoadd[1]
Else
$objhome = $target
$obj = $objtoadd
EndIf

$group = GetObject('WinNT://' + $target + '/' + $group)
If VarType($group) = 9 And @ERROR = 0
$group.Add ('WinNT://'+$objhome+'/'+$obj)
Else
$GroupAdd = @ERROR
Exit @ERROR
EndIf
$GroupAdd = @ERROR
Exit @ERROR
EndFunction

Top
#169670 - 2006-10-21 12:45 AM Re: Inputing users/groups into scripts
jeremyschubert Offline
Getting the hang of it

Registered: 2005-09-17
Posts: 89
Thanks for the suggestions NTDOC. I check out your suggestions and put them into play when I test my script next week. I'll let you know how it goes.
Just to let you know, the HTMKInputBox function isn't mine, it was written by Steve O.
And where can I find more info on PressPost?
Thanks,
_________________________
---
Bishop Grandin Technology Department
'Either we're on time, or we're late'

Top
#169671 - 2006-10-21 12:51 AM Re: Inputing users/groups into scripts
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well don't really recommend that you use PostPrep as once you post it you can not come back and edit your post anymore.
Only Moderators can.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 756 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.078 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org