Jump to content
Sign in to follow this  
tm4cncrn

pass value to the cacls command

Recommended Posts

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

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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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

Oops, sorry, my fault :>


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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

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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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.")

"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!

Share this post


Link to post
Share on other sites

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

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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

;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

Try:

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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

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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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

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

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...