Hallo liebe Gemeinde,
ich versuche ein Tool zu erstellen, welches diese Dinge tut:
GUI mit Eingabe von Ordnername, Username.
Dieser erstellt ein Ordner, der Besitzer ist der angemeldete User und hat auch Vollzugriff.
Das funktioniert auch.
Nun möchte ich mit Eingabe des Usernames einen Benutzer hinzufügen, der auch lesen kann. Quasi ein temporärer Austauschordner.
Mit dem Powershell Script, funktioniert das auch ohne Probleme. Nun weiß ich nicht wie ich das in Verbindung mit Autoit bringen soll.
Jemand vielleicht eine Idee?
Bash
New-Item -Path "H:\Share_Test\Testordner" -ItemType "directory"
$Right="ReadAndExecute"
$path="H:\Share_Test\Testordner"
$Principal="DOMAIN\testuserinderdomain"
$rule=New-Object System.Security.AccessControl.FileSystemAccessRule($Principal,$Right,3, 0,"Allow")
$acl = get-acl $path
$acl.SetAccessRule($rule)
set-acl $path $acl
AutoIt
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 434, 209, 197, 178)
$Input1 = GUICtrlCreateInput("Input1", 168, 40, 185, 21)
$Checkbox1 = GUICtrlCreateCheckbox("lesen", 168, 80, 65, 17)
$Button1 = GUICtrlCreateButton("Erstellen", 168, 176, 75, 25)
$Checkbox2 = GUICtrlCreateCheckbox("lesen und schreiben", 168, 96, 129, 17)
$Label1 = GUICtrlCreateLabel("Rechte", 24, 80, 62, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Zugriff für", 21, 127, 84, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Ordnernamen", 24, 44, 113, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("Input2", 168, 128, 185, 21)
$Button2 = GUICtrlCreateButton("Abbrechen", 280, 176, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;~ Powershell Comman
Func _PowerShell_Command($sCommand)
Local $iPID = Run(StringFormat('"%s" "%s"', 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe', $sCommand), @ScriptDir, @SW_HIDE, 0x2)
Local $sOut
Do
$sOut &= StdoutRead($iPID)
Until @error
StdioClose($iPID)
Return $sOut
EndFunc ;==>_PowerShell_Command
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$ordnername=GUICtrlRead($Input1)
$username=GUICtrlRead($Input2)
DirCreate("H:\Share_Test\"& $ordnername)
$Right="ReadAndExecute"
$path="H:\Share_Test\"& $ordnername
$Principal="DOMAIN\"&$username
$rule="New-Object System.Security.AccessControl.FileSystemAccessRule("&$Principal&","&$Right&",3, 0,""Allow"")"
$acl = "get-acl "& $path
$acl=_PowerShell_Command($acl)
_PowerShell_Command($acl&'RemoveAccessRule('&$rule&')')
_PowerShell_Command('set-acl '&$path &$acl)
EndSwitch
WEnd
Alles anzeigen