Jump to content

Recommended Posts

Posted (edited)

Case $BOK
Local $sObject = GUICtrlRead($IObject)
Local $ssComputer = GUICtrlRead($ComputerToMove)
Local $hSelection = _GUICtrlTreeView_GetSelection($hTree)
If $hSelection = 0 Then
MsgBox(64, "Error", "You must select an OU!")
Endif
For $i = 1 To $aTreeView[0][0]
If $hSelection = $aTreeView[$i][2] Then ExitLoop
Next
Local $sOU = $aTreeView[$i][1]
ExitLoop
EndSwitch
WEnd

I think I'm missing something as I get the msgbox when no OU is selected and the move and update button is pressed but then it exits so its not looping back. What am I missing?

Edited by Iceman682
Posted (edited)

Case $BOK
Local $sObject = GUICtrlRead($IObject)
Local $ssComputer = GUICtrlRead($ComputerToMove)
Local $hSelection = _GUICtrlTreeView_GetSelection($hTree)


If $hSelection = 0 Then
MsgBox(64, "Error", "You must select an OU!")
Else

For $i = 1 To $aTreeView[0][0]
If $hSelection = $aTreeView[$i][2] Then ExitLoop
Next
Local $sOU = $aTreeView[$i][1]
ExitLoop
EndIf
EndSwitch
WEnd

It seems I got it working, I hope it's the best way!

Edited by Iceman682
Posted

You could also have used continueloop

If $hSelection = 0 Then
  MsgBox(64, "Error", "You must select an OU!")
  Continueloop
Endif

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Posted

Looks good. I think this is the way it's being done in my example script too.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

Func _AddAdmins($InputUserAdmin)
GUISetState(@SW_HIDE, $localAdminsGUI)
RunWait(@ComSpec & " /c " & "Net localgroup Administrators " & $HelpDesk & " /add", "", @SW_HIDE)
RunWait(@ComSpec & " /c " & "Net localgroup Administrators " & $InputUserAdmin & " /add", "", @SW_HIDE)
MsgBox(0, "", "Authorised accounts successfully added to the Administrators Group")
GUISetState(@SW_SHOW, $localAdminsGUI)
EndFunc ;==>_AddAdmins

Func _AddPowerUsers($InputPowerUser)
GUISetState(@SW_HIDE, $localAdminsGUI)
RunWait(@ComSpec & " /c " & "Net localgroup Administrators " & $HelpDesk & " /add", "", @SW_HIDE)
RunWait(@ComSpec & " /c " & '"Net localgroup "Power Users" "' & $InputPowerUser & " /add", "", @SW_HIDE)
MsgBox(0, "", "Authorised accounts successfully added to the Administrators and Power User Group")
GUISetState(@SW_SHOW, $localAdminsGUI)
EndFunc ;==>_AddPowerUsers

I seem to have found another issue that hopefully someone could assist.

As #RequiresAdmin is inserted, my script pops up the UAC prompts after the domain join and subsequent reboot asking for elevated credentials, unfortunatly when these are inserted it fails.

After removing the #RequiresAdmin the UAC prompts are gone, however when a domain user is added to the local Administrators Group or the Power Users Group the user names are not inserted into the respective groups. (due to it requiring the #RequiresAdmin)

Any assistance will be most welcome.

Edited by Iceman682

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
×
×
  • Create New...