Keniger Posted March 5, 2013 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
water Posted March 5, 2013 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Keniger Posted March 5, 2013 Author 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
water Posted March 5, 2013 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Keniger Posted March 5, 2013 Author Posted March 5, 2013 (edited) #RequireAdmin - Only run scirpt as admin not cmd ;x Edited March 5, 2013 by Keniger
Moderators JLogan3o13 Posted March 5, 2013 Moderators 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!
water Posted March 5, 2013 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Keniger Posted March 5, 2013 Author 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
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