Iznogoud Posted March 10, 2008 Share Posted March 10, 2008 (edited) Does anyone know a good way to use an AutoIT written executable in combination with this feature of the right mouse button.I have written a code wich sets some permissions to a specific folder with the following files: RMTShare and CACLS.exe.Part of my code:Run(@ComSpec & " /c " & "RMTSHARE \\TestServer\" & $User &"$=" & EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" /GRANT " & $User &":F /GRANT ""Domeinadministrators"":F /REMARK:""HomeDirectory van " & $User & """", "", @SW_HIDE) Run(@ComSpec & " /c " & "cacls " & EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" /T /E /R Gebruikers", "", @SW_HIDE) Run(@ComSpec & " /c " & "cacls " & EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" /T /E /R ""Maker Eigenaar""", "", @SW_HIDE) Run(@ComSpec & " /c " & "cacls " & EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" /T /E /R System", "", @SW_HIDE) Run(@ComSpec & " /c " & "cacls " & EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" /T /E /R Administrators", "", @SW_HIDE) Run(@ComSpec & " /c " & "cacls " & EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" /T /E /G " & $User &":R", "", @SW_HIDE) Run(@ComSpec & " /c " & "cacls " & EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" /T /E /G " & $User &":W", "", @SW_HIDE) Run(@ComSpec & " /c " & "cacls " & EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" /T /E /G " & $User &":C", "", @SW_HIDE) Run(@ComSpec & " /c " & "cacls " & EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" /T /E /G Domeinadministrators:F", "", @SW_HIDE) Run(@ComSpec & " /c " & "echo Homedirectory for " & $User & " has been created >> C:\Log.txt", "", @SW_HIDE)As you see is the EnvGet("InputHomeLocation") & "HomeDirectory\" & $User &" part the variable.Is it possible to combine with this option described in the link below?http://www.petri.co.il/add_command_prompt_...ws_explorer.htmWhat i want to do is creating a script wich sets permission on a specific folder when a customer is right clicking on a folder and click an option Set Permissions for an example.Wich than will kick in the script and set the permissions to that specific folder.I think i would be something like using the %1 part of the link above, but i am not a pro programma, just a beginner.Could someone help me push me in the correct direction? Edited March 10, 2008 by Iznogoud Link to comment Share on other sites More sharing options...
Iznogoud Posted March 10, 2008 Author Share Posted March 10, 2008 Forget the story i solved it myself by just trial and error method. $location = MsgBox("", "Test", $CmdLineRaw) This does the job for me, don't know if this is the best way? Link to comment Share on other sites More sharing options...
Iznogoud Posted March 10, 2008 Author Share Posted March 10, 2008 One question left about my code i have written, first i will show you my code: expandcollapse popupOpt("TrayIconDebug", 1) #include <GUIConstants.au3> ; ************************************************************************************* ; Creating a list of Users ; Example list: ; "User1" ; "User3" ; "User4" ; ************************************************************************************* $Userlist = RunWait(@ComSpec & " /c dsquery user ou=Klanten,dc=Test,dc=local -o samid > C:\UsersTemp.txt", @SystemDir, @SW_HIDE) $Medewerkers="" ; ************************************************************************************* ; Checking files ; ************************************************************************************* $USersTemp = FileOpen("C:\USersTemp.txt", 0) $Users = FileOpen("C:\USers.txt", 2) If $USersTemp = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf If $Users = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; ************************************************************************************* ; Transforming Userlist to unquoted ; Example list after it is unquoted: ; User1 ; User3 ; User4 ; ************************************************************************************* While 1 $line = FileReadLine($UsersTemp) If @error = -1 Then ExitLoop $linepart1 = StringTrimLeft($line, 1) $linepart2 = StringTrimRight($linepart1, 1) FileWrite($Users, $linepart2 & @CRLF) Wend ; ************************************************************************************* ; Closing Files ; ************************************************************************************* FileClose($UsersTemp) FileClose($Users) ; ************************************************************************************* ; Creating correct input for ComboBox ; ************************************************************************************* $Gebruikers = FileOpen("C:\Users.txt", 0) If $Gebruikers = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 $Wline = FileReadLine($Gebruikers) If @error = -1 Then ExitLoop $Medewerkers = $Medewerkers & "|" & $Wline WEnd FileClose($Gebruikers) ; ************************************************************************************* ; Creating GUI ; ************************************************************************************* GUICreate("My GUI combo") ; ************************************************************************************* ; Filling ComboBox with actual list of users ; ************************************************************************************* GUICtrlCreateCombo ("item1", 10,10) GUICtrlSetData(-1,$Medewerkers,"") GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend What i was wondering is there an easier way to do this? I know this code is working now, but does it keep working or could i make adjustments so it works better in the feature? Just a question to learn more about AutoIT in combination with Strings, Arrays, etc. I have written this code by meself and this code i understand so hopefully if there are suggested adjustments i could understand them, because this script is so simple for the most of you i think. 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