Jump to content
Sign in to follow this  
IONCom

Input field with multiple lines for processing

Recommended Posts

IONCom

I am attempting to add to input fields to this form to accept Cut and Paste of multiple entries, one per line, to parse through the 2 box and then generate the code needed.

Currently it works perfect with single entries in each box, but to make it really useful would be to allow for either Cut/Paste or reading a text file to help generate the scripts.

Below is the current code I have. the utility uses the the Microsoft Utility NTRights.exe to work.

i was unable to attach the file so i apologize.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=....ICONSCNFNOT.ICO
#AutoIt3Wrapper_Res_Description=Created to Manually add Local Security rights to servers
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Brian Foster - ION Communications
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <buttonconstants.au3>
#include <comboconstants.au3>
#include <editconstants.au3>
#include <guiconstantsex.au3>
#include <staticconstants.au3>
#include <tabconstants.au3>
#include <windowsconstants.au3>
#include <constants.au3>

;Add Utility file to script
FileInstall("C:ScriptsAddServiceRigthsNTRights.exe", @ScriptDir & "NTRights.exe")
#region ### START Koda GUI section ### Form=c:scriptsaddservicerigthsform1.kxf

$SecurityRights = GUICreate("Security Rights", 657, 403, 192, 114)
GUISetBkColor(0xD4D0C8)
$AccountName = GUICtrlCreateInput("AccountName", 16, 72, 193, 21)
$MachineName = GUICtrlCreateInput("MachineName", 272, 72, 225, 21)
$RightsList = GUICtrlCreateTab(16, 104, 473, 233)
$TabSheet1 = GUICtrlCreateTabItem("Logon Privileges")
$SeBatchLogonRight = GUICtrlCreateCheckbox("Log on as a batch job", 32, 144, 153, 17)
$SeInteractiveLogonRight = GUICtrlCreateCheckbox("Log on locally", 32, 200, 129, 17)
$SeDenyInteractiveLogonRight = GUICtrlCreateCheckbox("Deny local logon", 32, 224, 121, 17)
$SeServiceLogonRight = GUICtrlCreateCheckbox("Logon as a service ", 32, 264, 129, 17)
$SeDenyServiceLogonRight = GUICtrlCreateCheckbox("Deny logon as a service", 32, 288, 145, 17)
$SeNetworkLogonRight = GUICtrlCreateCheckbox("Access this Computer from the Network", 208, 168, 217, 17)
$SeDenyNetworkLogonRight = GUICtrlCreateCheckbox("Deny Access to this computer from the network", 208, 192, 265, 17)
$SeRemoteInteractiveLogonRight = GUICtrlCreateCheckbox("Allow logon through Terminal Services", 208, 264, 241, 17)
$SeDenyRemoteInteractiveLogonRight = GUICtrlCreateCheckbox("Deny logon through Terminal Services", 208, 288, 217, 17)
$Label1 = GUICtrlCreateLabel("The Following are not supported on Windows 2000", 208, 240, 245, 17)
GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
GUICtrlSetColor(-1, 0x800000)
$SeDenyBatchLogonRight = GUICtrlCreateCheckbox("Deny logon as a batch job", 32, 168, 129, 17)
$SeDebugPrivilege = GUICtrlCreateCheckbox("Debug programs", 208, 145, 129, 17)
$TabSheet2 = GUICtrlCreateTabItem("SysAdmin Privileges")
$SeAuditPrivilege = GUICtrlCreateCheckbox("Generate security audits ", 32, 144, 185, 17)
$SeSecurityPrivilege = GUICtrlCreateCheckbox("Manage auditing and security log", 32, 170, 185, 17)
$SeBackupPrivilege = GUICtrlCreateCheckbox("Backup files and directories", 32, 194, 185, 17)
$SeMachineAccountPrivilege = GUICtrlCreateCheckbox("Add workstations to the domain", 32, 218, 185, 17)
$SeShutdownPrivilege = GUICtrlCreateCheckbox("Shut down the system ", 32, 242, 185, 17)
$SeRemoteShutdownPrivilege = GUICtrlCreateCheckbox("Force shutdown from a remote system", 32, 266, 209, 17)
$SeCreatePagefilePrivilege = GUICtrlCreateCheckbox("Create a pagefile", 32, 290, 185, 17)
$SeIncreaseQuotaPrivilege = GUICtrlCreateCheckbox("Increase quotas", 257, 146, 185, 17)
$SeRestorePrivilege = GUICtrlCreateCheckbox("Restore files and directories", 257, 172, 185, 17)
$SeSystemTimePrivilege = GUICtrlCreateCheckbox("Change the system time", 257, 196, 185, 17)
$SeManageVolumePrivilege = GUICtrlCreateCheckbox("Manage the files on a volume (XP Only)", 257, 220, 217, 17)
$SeTakeOwnershipPrivilege = GUICtrlCreateCheckbox("Take ownership of files/objects", 257, 244, 185, 17)
$SeUndockPrivilege = GUICtrlCreateCheckbox("Remove computer from docking station", 257, 268, 225, 17)
$SeEnableDelegationPrivilege = GUICtrlCreateCheckbox("Enable computer/user accounts to be trusted for delegation", 257, 290, 185, 33, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_MULTILINE))
GUICtrlSetResizing(-1, $GUI_DOCKAUTO + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
$TabSheet3 = GUICtrlCreateTabItem("Service Privileges")
$SeCreatePermanentPrivilege = GUICtrlCreateCheckbox("Create permanent shared objects", 32, 152, 193, 17)
$SeCreateTokenPrivilege = GUICtrlCreateCheckbox("Create a token object", 32, 176, 209, 17)
$SeAssignPrimaryTokenPrivilege = GUICtrlCreateCheckbox("Replace a process-level token", 32, 200, 177, 17)
$SeImpersonatePrivilege = GUICtrlCreateCheckbox("Impersonate a client after authentication", 32, 224, 217, 17)
$SeIncreaseBasePriorityPrivilege = GUICtrlCreateCheckbox("Increase scheduling priority", 32, 248, 225, 17)
$SeTcbPrivilege = GUICtrlCreateCheckbox("Act as part of the operating system ", 272, 152, 201, 17)
$SeProfileSingleProcessPrivilege = GUICtrlCreateCheckbox("Profile a single process", 272, 176, 185, 17)
$SeLoadDriverPrivilege = GUICtrlCreateCheckbox("Load and unload device drivers", 272, 200, 201, 17)
$SeLockMemoryPrivilege = GUICtrlCreateCheckbox("Lock pages in memory", 272, 224, 201, 17)
$SeCreateGlobalPrivilege = GUICtrlCreateCheckbox("Create global objects", 272, 248, 193, 17)
$TabSheet4 = GUICtrlCreateTabItem("Misc. Privileges")
$SeChangeNotifyPrivilege = GUICtrlCreateCheckbox("Bypass traverse checking", 32, 160, 161, 17)
$SeSyncAgentPrivilege = GUICtrlCreateCheckbox("Synch directory service data", 32, 192, 161, 17)
$SeSystemEnvironmentPrivilege = GUICtrlCreateCheckbox("Edit firmware environment values", 32, 224, 225, 17)
$SeSystemProfilePrivilege = GUICtrlCreateCheckbox("Profile system performance", 32, 256, 177, 17)
GUICtrlCreateTabItem("")
$RUN = GUICtrlCreateButton("RUN File", 24, 352, 81, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
$EXIT = GUICtrlCreateButton("EXIT", 392, 352, 81, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x800000)
$Label2 = GUICtrlCreateLabel("Enter Account name to grant rights to:", 16, 40, 221, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Domainusername(group) ", 16, 56, 150, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Enter remote Machine Name or LocalHost", 272, 56, 240, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Generate = GUICtrlCreateButton("Generate File", 168, 352, 121, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000080)
$Privileges = GUICtrlCreateCombo("GRANT Privilege", 496, 176, 129, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "REMOVE Privilege")
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xECE9D8)
$Label5 = GUICtrlCreateLabel("Select to ADD/ REMOVE", 496, 152, 147, 17)
GUICtrlSetFont(-1, 6, 800, 4, "MS Sans Serif")
GUISetState(@SW_SHOW)

#endregion ### END Koda GUI section ###
Dim $File
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
FileDelete(@ScriptDir & "NTRights.exe")
Exit
Case $RUN
_CREATEFile()
$Line = '"' & $File & '" >"' & $File & ".log" & '"'
RunWait($Line, "", @SW_HIDE)
FileDelete($File)
MsgBox("", "Log File has been saved as: ", $File & ".log")
Case $EXIT
FileDelete(@ScriptDir & "NTRights.exe")
Exit
Case $Generate
_CREATEFile()
MsgBox("", "File Save Location", "Your File has been saved to: " & @CRLF & @CRLF & $File)
EndSwitch
WEnd

Func _CREATEFile()
Dim $Priv
$User = GUICtrlRead($AccountName)
$CPU = GUICtrlRead($MachineName)
If $User = "AccountName" Then MsgBox("", "Change Account Name", "Please Change the Account Name before continuing")
If $CPU = "MachineName" Then MsgBox("", "Change Machine Name", "Please change the Machine Name before continuing")

If GUICtrlRead($Privileges) = "GRANT Privilege" Then
$Priv = "+r"
Else
$Priv = "-r"
EndIf
$File = @MyDocumentsDir & "" & $CPU & "_" & @MSEC & ".CMD"

$Writefile = FileOpen($File, 1)
If GUICtrlRead($SeBatchLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeBatchLogonRight")
If GUICtrlRead($SeInteractiveLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeInteractiveLogonRight")
If GUICtrlRead($SeDenyInteractiveLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeDenyInteractiveLogonRight")
If GUICtrlRead($SeServiceLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeServiceLogonRight")
If GUICtrlRead($SeDenyServiceLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeDenyServiceLogonRight")
If GUICtrlRead($SeNetworkLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeNetworkLogonRight")
If GUICtrlRead($SeDenyNetworkLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeDenyNetworkLogonRight")
If GUICtrlRead($SeRemoteInteractiveLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeRemoteInteractiveLogonRight")
If GUICtrlRead($SeDenyRemoteInteractiveLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeDenyRemoteInteractiveLogonRight")
If GUICtrlRead($SeDenyBatchLogonRight) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeDenyBatchLogonRight")
If GUICtrlRead($SeDebugPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeDebugPrivilege")
If GUICtrlRead($SeAuditPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeAuditPrivilege")
If GUICtrlRead($SeSecurityPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeSecurityPrivilege")
If GUICtrlRead($SeBackupPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeBackupPrivilege")
If GUICtrlRead($SeMachineAccountPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeMachineAccountPrivilege")
If GUICtrlRead($SeShutdownPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeShutdownPrivilege")
If GUICtrlRead($SeRemoteShutdownPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeRemoteShutdownPrivilege")
If GUICtrlRead($SeCreatePagefilePrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeCreatePagefilePrivilege")
If GUICtrlRead($SeIncreaseQuotaPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeIncreaseQuotaPrivilege")
If GUICtrlRead($SeRestorePrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeRestorePrivilege")
If GUICtrlRead($SeSystemTimePrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeSystemTimePrivilege")
If GUICtrlRead($SeManageVolumePrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeManageVolumePrivilege")
If GUICtrlRead($SeTakeOwnershipPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeTakeOwnershipPrivilege")
If GUICtrlRead($SeUndockPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeUndockPrivilege")
If GUICtrlRead($SeEnableDelegationPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeEnableDelegationPrivilege")
If GUICtrlRead($SeCreatePermanentPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeCreatePermanentPrivilege")
If GUICtrlRead($SeCreateTokenPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeCreateTokenPrivilege")
If GUICtrlRead($SeAssignPrimaryTokenPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeAssignPrimaryTokenPrivilege")
If GUICtrlRead($SeImpersonatePrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeImpersonatePrivilege")
If GUICtrlRead($SeIncreaseBasePriorityPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeIncreaseBasePriorityPrivilege")
If GUICtrlRead($SeTcbPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeTcbPrivilege")
If GUICtrlRead($SeProfileSingleProcessPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeProfileSingleProcessPrivilege")
If GUICtrlRead($SeLoadDriverPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeLoadDriverPrivilege")
If GUICtrlRead($SeLockMemoryPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeLockMemoryPrivilege")
If GUICtrlRead($SeCreateGlobalPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeCreateGlobalPrivilege")
If GUICtrlRead($SeChangeNotifyPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeChangeNotifyPrivilege")
If GUICtrlRead($SeSyncAgentPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeSyncAgentPrivilege")
If GUICtrlRead($SeSystemEnvironmentPrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeSystemEnvironmentPrivilege")
If GUICtrlRead($SeSystemProfilePrivilege) = 1 Then FileWriteLine($Writefile, "NTRights -u " & '"' & $User & '"' & " -m " & $CPU & " " & $Priv & " " & "SeSystemProfilePrivilege")
FileClose($Writefile)
Return ($File)

EndFunc ;==>_CREATEFile
Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Melba23

IONCom,

You will see I have added code tags for you - please do the same when you post code in future. You just put [autoit] before and [/autoit] after the code. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Chad2

You can use an Edit box (GUICtrlCreateEdit). If the EditBox doesn't equal "" then write the contents to a file and FileReadLine.

Edited by Chad2

Share this post


Link to post
Share on other sites
IONCom

Thanks Chad.. I was looking at that, but was not sure of how to utilize it properly.

do you know how i can loop through the function cleanly?

for the utility to work It needs a line for each account, privilege and computer to be written in the CMD file to be run.

So i would have to start with account #1/cpu #1, Then account #2/cpu #1, Account #3/cpu #1..

When all accounts are done, then start: account #1/cpu #2, Then account #2/cpu #2, Account #3/cpu #2 and so on, until all accounts have been married with all CPU's.

ex:

NTRights -u "Account1" -m Machine1 +r SeBatchLogonRight

NTRights -u "Account1" -m Machine1 +r SeNetworkLogonRight

NTRights -u "Account2" -m Machine1 +r SeBatchLogonRight

NTRights -u "Account2" -m Machine1 +r SeNetworkLogonRight

NTRights -u "Account1" -m Machine2 +r SeBatchLogonRight

NTRights -u "Account1" -m Machine2 +r SeNetworkLogonRight

NTRights -u "Account2" -m Machine2 +r SeBatchLogonRight

NTRights -u "Account2" -m Machine2 +r SeNetworkLogonRight

I have not seen an include that does this so I am relying on utility to produce the commands in a repeatable process so they can be applied or reapplied as needed and tracked through the enterprise.

I am doing it this way since GPO's applying the global accounts, overrides the application specific seeds that they add, like SQL and IIS. this way i don't mess up any mission critical apps but can still deploy the rights our enterprise needs.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×