Jump to content
Keniger

CACLS in Autoit

Recommended Posts

Keniger

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 by Keniger

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - 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
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Keniger

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

Share this post


Link to post
Share on other sites
water

Add

#RequireAdmin
at the top of your script and use Run to execute Cacls.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - 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
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Keniger
#RequireAdmin - Only run scirpt as admin not cmd ;x Edited by Keniger

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - 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
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Keniger

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 ;x

Posted Image

Only manualy works, with au3 nope :D WTF Is going on ? How I can run cmd as admin ?

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EDIT

Okay I solved the problem :D I used "icacls" then I try with "cacls" and work ! How I can

Edited by Keniger

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

×