Jump to content
Sign in to follow this  
ChrisNYS

All things Terminal Server

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

@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!

Share this post


Link to post
Share on other sites

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.

#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 by JLogan3o13

Share this post


Link to post
Share on other sites

The following post describes how to handle this properties:

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...