Keniger Posted March 5, 2013 Share Posted March 5, 2013 (edited) Hi guys ! RunWait("cmd.exe /c " & "wmic USERACCOUNT get Name >"&@DesktopDir&"\users.txt",@ScriptDir,@SW_HIDE) This little command save all users names on computer to file. Then ! I wrote script wich use that names to give permissions (Folders/Files) $file0 = @DesktopDir & "\lol.txt" $file = FileOpen("users.txt", 0) $user1 = FileReadLine($file, 2) RunWait("cmd.exe /c" & "cacls " & $file0 & " " & "/grant " & $user1 & ":(R)") FileClose($file) Wich should get this f**king permission to that file (R = only read and see) If i write that command in cmd manually works -,- but in autoit nope... what is wrong here ? This command in autoit looks like that : cacls file_patch /grant user_name:® so what ... This should work but nope... Sr for my english if bad xd @@@@@@@@@@@@@@@@@@@@@@EDIT Ooops ! Sorry for bad section ! Edited March 5, 2013 by Keniger Link to comment Share on other sites More sharing options...
water Posted March 5, 2013 Share Posted March 5, 2013 Are you sure the command is correct? Here (WIndows 7) the syntax (according to the help file) is: RunWait("cmd.exe /c" & "cacls " & $file0 & " " & "/G " & $user1 & ":R") 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...
Keniger Posted March 5, 2013 Author Share Posted March 5, 2013 I know what is going wrong ;x Command Prompt just run as normal user, cmd needs admin rights (Im on vista so...) Anyway, how can I run cmd as admin ;o ? $user = "Administrator" $pass = "" RunAs($user, @ComputerName, $pass,0,@ComSpec & "/c " & "cacls C:\Users\marek\Desktop\lol.txt /grant marek:r") This dont work ;x Link to comment Share on other sites More sharing options...
water Posted March 5, 2013 Share Posted March 5, 2013 Add #RequireAdminat the top of your script and use Run to execute Cacls. 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...
Keniger Posted March 5, 2013 Author Share Posted March 5, 2013 (edited) #RequireAdmin - Only run scirpt as admin not cmd ;x Edited March 5, 2013 by Keniger Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 5, 2013 Moderators Share Posted March 5, 2013 Did you try what Water suggested? Did it not work? "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...
water Posted March 5, 2013 Share Posted March 5, 2013 If you try something and it doesn't work, please don't post "it doesn't work" but the return value of the function in error and the value of @error and @extended. 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...
Keniger Posted March 5, 2013 Author Share Posted March 5, 2013 (edited) Ye, cmd runs with admin but its only illusion because command dont work right...If I run CMD : Start > Acessories > Command Prompt > PPM Run As Admin Command work... Idk what is going on ;xOnly manualy works, with au3 nope WTF Is going on ? How I can run cmd as admin ?@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EDITOkay I solved the problem I used "icacls" then I try with "cacls" and work ! How I can Edited March 5, 2013 by Keniger 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