Jump to content

Recommended Posts

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

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:

  Reveal hidden contents

 

Posted

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

Posted

Add

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

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

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:

  Reveal hidden contents

 

Posted (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 ;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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...