Jump to content

CACLS in Autoit


Recommended Posts

So I have a very simple Auotit script that is utilizing the Printbrm to export to a file but Cacls are not being changed......

Attached is the script:

$sUser = "WTF"
$sPass = "IsGoing"
$sDomain = "OnHere"
$sCMD = "C:\Windows\System32\spool\tools\Printbrm.exe /b /f C:\temp\Printers\backup.printerExport"
$sCalc = "C:\Windows\System32\cacls C:\temp\Printers /t /e /g Everyone:f"

DirCreate ("C:\Temp\Printers")
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCalc)
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCMD)

 

Please any help will be grateful......

THANKS

Link to comment
Share on other sites

On 3/5/2013 at 10:36 AM, water said:

Add

#RequireAdmin

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

So I have a very simple Auotit script that is utilizing the Printbrm to export to a file but Cacls are not being changed......

Attached is the script:

$sUser = "WTF"
$sPass = "IsGoing"
$sDomain = "OnHere"
$sCMD = "C:\Windows\System32\spool\tools\Printbrm.exe /b /f C:\temp\Printers\backup.printerExport"
$sCalc = "C:\Windows\System32\cacls C:\temp\Printers /t /e /g Everyone:f"

DirCreate ("C:\Temp\Printers")
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCalc)
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCMD)

 

Link to comment
Share on other sites

So I have a very simple Auotit script that is utilizing the Printbrm to export to a file but Cacls are not being changed......

Attached is the script:

$sUser = "WTF"
$sPass = "IsGoing"
$sDomain = "OnHere"
$sCMD = "C:\Windows\System32\spool\tools\Printbrm.exe /b /f C:\temp\Printers\backup.printerExport"
$sCalc = "C:\Windows\System32\cacls C:\temp\Printers /t /e /g Everyone:f"

DirCreate ("C:\Temp\Printers")
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCalc)
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCMD)

Link to comment
Share on other sites

So I have a very simple Auotit script that is utilizing the Printbrm to export to a file but Cacls are not being changed......

Attached is the script:

$sUser = "WTF"
$sPass = "IsGoing"
$sDomain = "OnHere"
$sCMD = "C:\Windows\System32\spool\tools\Printbrm.exe /b /f C:\temp\Printers\backup.printerExport"
$sCalc = "C:\Windows\System32\cacls C:\temp\Printers /t /e /g Everyone:f"

DirCreate ("C:\Temp\Printers")
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCalc)
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCMD)

Link to comment
Share on other sites

Why did you create another exact same thread?

EDIT: is this for 2003 sp2 or Vista+? If it is they say you should use icacls instead.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Ok np.

Did you try any combination of single or double quotes on the paths?

PS: and running as admin?

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

I have tried so many variables I can not recall......

$sUser = "WTF", $sPass = "IsGoing", $sDomain = "OnHere"

I am passing the cred to elevate to admin. 

The export of the printer is working fine however the Cacls are not changing as expected......
If I runas an admin and pass the arguements "C:\Windows\System32\cacls.exe C:\temp\Printers /t /e /g Everyone:f" It works fine

$sUser = "WTF"
$sPass = "IsGoing"
$sDomain = "OnHere"
$sCMD = "C:\Windows\System32\spool\tools\Printbrm.exe /b /f C:\temp\Printers\backup.printerExport"
$sCalc = "C:\Windows\System32\cacls.exe C:\temp\Printers /t /e /g Everyone:f"

DirCreate ("C:\Temp\Printers")
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCalc)
RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCMD)

 

Test3.au3

Link to comment
Share on other sites

  • Developers

Merged all three places you posted into this thread... lets try staying here now. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

20 hours ago, spudw2k said:

What is the return value and value of @error after your RunAsWait function call?

Give this a read: https://www.autoitscript.com/forum/topic/160817-elevate-a-part-of-a-script-using-run-as/

I am a newbie at this so apologies from the start....

so are you asking me to run this:

RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCalc @error)

 

Link to comment
Share on other sites

I was thinking of something like this:

;untested
$iRtn = RunAsWait ($sUser, $sDomain, $sPass, 0, "cmd /c " & $sCalc)
ConsoleWrite("Return Value: " & $iRtn & @CRLF & "@error Value: " & @error)

 

That article I linked to has some info in regards to RunAsWait not doing automatic process elevation.

Link to comment
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
 Share

  • Recently Browsing   0 members

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