Jump to content
Sign in to follow this  
tm4cncrn

pass value to the cacls command

Recommended Posts

tm4cncrn

I am trying to pass values to the cacls command.  Here is what i am doing:

I have a DIM statement

DIM $casedir

DIM $casedir1

$casedir = "servernamesharedir1dir2"

$casedir1 = "Testing"

I prompt the user for an $answer.  They fill out the prompt and i create they dir with this

DirCreate($casedir & $answer & "" & $casedir1)

The answer provides me the ability to create a unique directory name after dir2.

What i would like to do is $casedir $answer $casedir1 and take the values and insert them into the cacls command so i can answer a specific group full control rights to the testing dir.

here is my attempt:

run (cacls.exe($casedir "" $answer "" $casedir27) /E /C /T /G "domainnamelegalassistants":F)

any help would be awesome.

Thanks

Bob

 

Share this post


Link to post
Share on other sites
water

If Cacls.exe is in the same directory as your script then try:

Run("cacls.exe " & $casedir & "\" & $answer & "\" $casedir27 & " /E /C /T /G domainname\legalassistants:F")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
tm4cncrn

received error in expression after using this line:

Run("cacls.exe " & $casedir & "" & $answer & "" $casedir27 & " /E /C /T /G domainnamelegalassistants:F")

Share this post


Link to post
Share on other sites
FireFox

received error in expression after using this line:

 

Run("cacls.exe " & $casedir & "" & $answer & "" $casedir27 & " /E /C /T /G domainnamelegalassistants:F")

Please use autoit code tags to post your code.

There is a missing & before $casedir27.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
water

Oops, sorry, my fault :>


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
tm4cncrn

I receive no errors but, its not applying the permissions.   How would i pause the window so i can see the error?

Thanks again

Bob

Share this post


Link to post
Share on other sites
FireFox

Take a look at the StderrRead or StdoutRead functions. (beware of the run parameters to retrieve the standard outputs).

Br, FireFoX.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
water

Try:

Run(@ComSpec & " /k " & "cacls.exe " & $casedir & "\" & $answer & "\" & $casedir27 & " /E /C /T /G domainname\legalassistants:F"')

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
JLogan3o13

Hi, tm4cncrn. Below is a snippet I used for a helpesk customer, so they could delegate folks to set NTFS permissions. You may not need all of it, but shows you a working method for running CACLS with params:

$UID = InputBox("Grant Access", "Enter the user ID")
$dir = InputBox("Directory", "UNC path to parent directory")
$perm = InputBox("Level of Access", "Enter the level of Access: C(hange), F(ull control), R(ead only), W(rite)")

While 1
        $dir2 = FileSelectFolder("Choose a folder.", $dir, 1)
        RunWait( 'CACLS "' & $dir2 & '" /E /G ' & $UID & ':' & $perm, "", @SW_HIDE )
        $ok = MsgBox(4, "Complete", "Would you like to specify another directory?")
            If $ok = 7 Then ExitLoop
    WEnd

MsgBox(0, "Access Granted", "Access has been granted to the specified directories.")

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
tm4cncrn

i had to switch to icacls and now i am getting a message invalid parameter "&".  I used this:

(

Run(@ComSpec & " /k " & '"icacls.exe " & $casedir & "\" & $answer & "\" & $casedir27 & " /grant legalassistants:(OI)(CI)M"')  

 

 

thanks

bob

Share this post


Link to post
Share on other sites
water

Can you please post the complete output from the SciTE console pane?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
BrewManNH

You're mixing up the quotes in that run command. You have the whole string starting from icacls inside single quotes, all the way to the end of the string.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
tm4cncrn

;Places the input box in the top left corner displaying the characters as they
;are typed.
DIM $casedir
DIM $casedir27
 
$casedir = "\\server\users\dir\user\"
$casedir27 = "Legal Assistant Work Product"
 
MsgBox(4096, "Case Directory Verification", "Please verify that the Case Directory you want to create DOES NOT exist!  You will receive a window containing the Cases Folder, please verify the folder does not exist.  Click OK to continue.")
Run ('explorer.exe \\server\users\dir\user')
sleep (5000)
$answer = MsgBox(4, "Case Directory Verification", "DOES THE CASE FOLDER EXIST?")
If $answer = 6 Then
    MsgBox(0, "Folder Exists", "OK. Folder Already Exists. GoodBye!", 30)
    Exit
EndIf
Local $answer = InputBox("Question", "What is the Case Name and LM Number", "Example: XYZ Corp - LM Number", "", _
         - 1, -1, 0, 0)
; MsgBox(4096, $answer, "This box will time out in 10 seconds", 10)
If FileExists ($casedir & $answer) then
 MsgBox(4096, "Title", "This Case Folder Already Exists, Please Contact Your Helpdesk for Assistance!!", 30)
Else
 DirCreate($casedir & $answer)
  DirCreate($casedir & $answer & "\" & $casedir27)
 
 
 Run(@ComSpec & " /k " & '"icacls.exe " & $casedir & "\" & $answer & "\" & $casedir27 & " /grant legalassistants:(OI)(CI)M"')
 MsgBox(4096, "Title", "The Case Folder Has Been Successfully Created!", 30)
EndIf

Share this post


Link to post
Share on other sites
water

Try:

Run(@ComSpec & " /k " & "icacls.exe " & $casedir & "\" & $answer & "\" & $casedir27 & " /grant legalassistants:(OI)(CI)M")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
tm4cncrn

im getting there but what happening is if i put a space in the directory name thc icacls command errors out on the space.  So i guess i need to put quotes around something.  would like be a single or double quote around the $casedir and $casedir27?

Share this post


Link to post
Share on other sites
water

To handle spaces in the directory use:

Run(@ComSpec & " /k " & "icacls.exe '" & $casedir & "\" & $answer & "\" & $casedir27 & "' /grant legalassistants:(OI)(CI)M")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
tm4cncrn

Im still erroring out.  I am receiving this message:

Invalid parameter "bobLegalAssistantDocs

Here's the command:

Run(@ComSpec & " /k " & "icacls.exe '" & $casedir & "\" & $answer & "\" & $casedir27 & "' /grant legalassistants:(OI)(CI)M")

 

$casedir = "serverusersdetbob"

$answer = "Hello Bob"

$casedir27 = "LegalAssistantDocs"

I think i need to use double quotes around the path. 

Please advice!

Thanks

Bob

Share this post


Link to post
Share on other sites
BrewManNH

Try it with this line

Run(@ComSpec & " /k " & "icacls.exe """ & $casedir & "\" & $answer & "\" & $casedir27 & """ /grant legalassistants:(OI)(CI)M")
ConsoleWrite("icacls.exe """ & $casedir & "\" & $answer & "\" & $casedir27 & """ /grant legalassistants:(OI)(CI)M" & @crlf & '>Error code: ' & @error & @crlf)

You'll see by the consolewrite that the path now has double quotes around it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
tm4cncrn

Thank you.  Worked great.

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
Sign in to follow this  

×