ChrisNYS Posted July 29, 2019 Share Posted July 29, 2019 I have been having a helluva time finding what I need to read and write AD terminal server/remote desktop. I found the pile of code to stuff into my include directory with LOTS of active directory tools, and they will definitely come in handy, but nowhere to I see any hint i that heap of code on how to access the remote desktop profile and home directory paths. I am trying to make a nice, simple GUI so that some other folks can just plug the data into the form and click submit (and say, "Duh," for effect) and the job is done. I've got the form, with the error checking that I need to make sure they fill in all the necessary spaces, but I can't hook it to the thing they need to change. I can do it in Powershell, but that doesn't do the nice GUI's and forms that AutoIT can do. Any ideas? Code I can just steal outright? :-) Thanks. -Chris Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 29, 2019 Moderators Share Posted July 29, 2019 @ChrisNYS welcome to the forum. It would help a lot if you posted what code you have, or expand on your explanation of what you're trying to accomplish a bit. It is a bit frenetic and difficult to understand. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
ChrisNYS Posted July 29, 2019 Author Share Posted July 29, 2019 (edited) Sorry. Not typing so well today. I am trying to use AutoIT to update Active Directory records for Terminal Server Home Directory path and Profile Path. Here's what I have so far. See the comments near the end in BOLD for more info. Thanks. expandcollapse popup#include <GuiConstants.au3> #include <AD.au3> Global $Input_UserName, $input_DomainName, $Input_ServerName, $Input_AdminUserName, $Input_AdminPassword, $Input_ShareName Global $UserName, $DomainName, $ServerName, $AdminUserName, $AdminPassword, $OKToContinue, $ShareName Global $oProfilePath, $oTDrivePath ;Main Body $OKtoContinue = 3 $Def_UserName = "" $Def_DomainName = "" $Def_ServerName = "" $Def_AdminUserName = "" $Def_AdminPassword = "" $Def_ShareName = "" MakeWindow() CheckDataEntries() Select Case $OKtoContinue = 0 MsgBox(16, "Received", "Looks good...") CreateTDriveAD() Case $OKtoContinue = 1 MsgBox(64, "Wups!", "You forgot a bunch of stuff. Try again.") GuiDelete() EndSelect Func MakeWindow() GUICreate("T Drive Maker", 500, 400) $UserName = GUICtrlCreateLabel("User ID", 5, 5, 175, 18) $Input_UserName = GuiCtrlCreateInput($Def_UserName, 125, 5, 150, 18, $ES_UPPERCASE) $DomainName = GUICtrlCreateLabel("Domain", 5, 35, 175, 18) $Input_DomainName = GuiCtrlCreateInput($Def_DomainName, 125, 35, 150, 18, $ES_UPPERCASE) $ServerName = GUICtrlCreateLabel("Server Name", 5, 65, 175, 18) $Input_ServerName = GuiCtrlCreateInput($Def_ServerName, 125, 65, 150, 18, $ES_UPPERCASE) $AdminUserName = GUICtrlCreateLabel("Admin User ID", 5, 95, 175, 18) $Input_AdminUserName = GUICtrlCreateInput($Def_AdminUserName, 125, 95, 175, 18, $ES_UPPERCASE) $AdminPassword = GUICtrlCreateLabel("Password", 5, 125, 175, 18) $Input_AdminPassword = GUICtrlCreateInput($Def_AdminPassword, 125, 125, 175, 18, $ES_PASSWORD) $ShareName = GUICtrlCreateLabel("Share Name", 5, 155, 175, 18) $Input_ShareName = GUICtrlCreateInput($Def_ShareName, 125, 155, 175, 18, $ES_UPPERCASE) $SubmitButton = GUICtrlCreateButton ("Submit", 25, 360, 70,20) GuiSetState() While 1 $msg = GuiGetMsg() If $msg = $Submitbutton Then ExitLoop WEnd EndFunc Func CheckDataEntries() ;Check entries. $OKtoContinue = 0 $Def_UserName = GUICtrlRead($Input_UserName) $Def_DomainName = GUICtrlRead($Input_DomainName) $Def_ServerName = GUICtrlRead($Input_ServerName) $Def_AdminUserName = GUICtrlRead($Input_AdminUserName) $Def_AdminPassword = GUICtrlRead($Input_AdminPassword) $Def_ShareName = GUICtrlRead($Input_ShareName) If GUICtrlRead($Input_Username) = "" Then $OKtoContinue = 1 If GUICtrlRead($Input_ServerName) = "" Then $OKtoContinue = 1 If GUICtrlRead($Input_DomainName) = "" Then $OKtoContinue = 1 If GUICtrlRead($Input_AdminUserName) = "" Then $OKtoContinue = 1 If GUICtrlRead($Input_AdminPassword) = "" Then $OKtoContinue = 1 If GUICtrlRead($Input_ShareName) = "" Then $OKtoContinue = 1 EndFunc Func CreateTDriveAD() _AD_Open("","","",DomainControllerName) $oProfilePath = "M:\MandatoryProfile" $oTDrivePath = "\\" & $ServerName & "\\" & chr(34) & $ShareName & Chr(34) & "\" & $UserName ;======================================================================================================================================= ;HERE IS WHERE I NEED TO GET THESE TWO THINGS INTO MY ACTIVE DIRECTORY ENTRY FOR THE USER, AS WELL AS THE DRIVE LETTER. As you may note below, I tried to call a Powershell script that I wrote/stole that works, but it chokes there. Rather than wasting time trying to untangle that, I'd like to be able to write it all in AutoIT. The next thing will be getting AutoIT to write ACL's, but that's something I'll tackle later... ;======================================================================================================================================= ; Runwait(@Comspec & " /c " & "powershell.exe -nologo -file C:\Temp\SetADTDrive.ps1 " & $UserName & Chr(32) & $ServerName & Chr(32) & Chr(34) & $ShareName & Chr(34), SystemDir) ;Runwait(@Comspec & " /c " & "icacls " & Chr(92) & Chr(92) & $ServerName & Chr(92) & Chr(92) & Chr(34) & $ShareName & Chr(34) & Chr(92) & $UserName & " /setowner " & Chr(34) & "SVC\OCFS SOs /T /C", SystemDir) ;Runwait(@Comspec & " /c " & "icacls " & Chr(92) & Chr(92) & $ServerName & Chr(92) & Chr(92) & Chr(34) & $ShareName & Chr(34) & Chr(92) & $UserName & " /grant " & Chr(34) & "SVC\" & $UserName & Chr(34) & ":(OI)(CI)M /T /C", SystemDir) EndFunc Edited July 29, 2019 by JLogan3o13 Link to comment Share on other sites More sharing options...
water Posted July 29, 2019 Share Posted July 29, 2019 The following post describes how to handle this properties: My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now