Jump to content

Recommended Posts

Posted (edited)

Hello

I'm trying to use an AutoIT script to change rights on a lot of files and directories. I use cacls with this line :

Run(@COMSPEC & " /c " & "cacls """ & $dir & "\" & $file & """ /G SYSTEM:F Administrateur:F user:R")

The problem is that I need to write "y" and then type ENTER to confirm that I really want to change the rights. I tried with Send() function after a little Sleep(), but it seems to create some problems, if the sleep time isn't enough, or something like that.

This is the whole part I want to get better :

Run(@COMSPEC & " /c " & "cacls """ & $dir & "\" & $file & """ /G SYSTEM:F Administrateur:F user:R")

Sleep(200)
Send("o{ENTER}")
WinWaitClose(@COMSPEC)

Do you know a way to automate the "yes" answer after the Run command (in same window)? It can't be done with cacls (no parameter to do that).

Thanks for help

Edited by 440LVB
Posted

Hello

I'm trying to use an AutoIT script to change rights on a lot of files and directories. I use cacls with this line :

Run(@COMSPEC & " /c " & "cacls """ & $dir & "\" & $file & """ /G SYSTEM:F Administrateur:F user:R")

The problem is that I need to write "y" and then type ENTER to confirm that I really want to change the rights. I tried with Send() function after a little Sleep(), but it seems to create some problems, if the sleep time isn't enough, or something like that.

This is the whole part I want to get better :

Run(@COMSPEC & " /c " & "cacls """ & $dir & "\" & $file & """ /G SYSTEM:F Administrateur:F user:R")

Sleep(200)
Send("o{ENTER}")
WinWaitClose(@COMSPEC)

Do you know a way to automate the "yes" answer after the Run command (in same window)? It can't be done with cacls (no parameter to do that).

Thanks for help

<{POST_SNAPBACK}>

from http://www.robvanderwoude.com/index.html

XCACLS' /Y switch can be emulated by piping a Y to CACLS' standard input:

ECHO Y ¦ CACLS .....

If that does not work for you, there is a way to do both Y and Enter, but I cannot seem to locate the method... it is on the site shown above.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted (edited)

from http://www.robvanderwoude.com/index.html

XCACLS' /Y switch can be emulated by piping a Y to CACLS' standard input:

ECHO Y ¦ CACLS .....

If that does not work for you, there is a way to do both Y and Enter, but I cannot seem to locate the method... it is on the site shown above.

<{POST_SNAPBACK}>

The pipe syntax does work. Thank you herewasplato, not the first time that I have this kind of problem, but this is the best solution I've found yet.

Could be useful to others.

This is the updated command line :

Run(@COMSPEC & " /c " & "echo y|cacls """ & $dir & "\" & $file & """ /G SYSTEM:F Administrateur:F user:R")
Edited by 440LVB
Posted

The pipe syntax does work.

.....

This is the updated command line :

Run(@COMSPEC & " /c " & "echo o|cacls """ & $dir & "\" & $file & """ /G SYSTEM:F Administrateur:F user:R")

<{POST_SNAPBACK}>

should that be "echo Y|cacls

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted

should that be "echo Y|cacls

<{POST_SNAPBACK}>

Yep sure but I'm french, then 'yes' => 'oui'. Sorry, I gonna change that.
Posted

Yep sure but I'm french, then 'yes' => 'oui'. Sorry, I gonna change that.

<{POST_SNAPBACK}>

Sorry, I forgot my audience - the world.

I don't mean to keep harping on this, just wondering:

Does it "not work" because you need an enter also...

...or is the "Y" not making it to the command?

Sending Y and Enter involved piping a txt file to the command... but I cannot find that link that I was reading yesterday. Do you think that this would help?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted

The pipe syntax does work. Thank you herewasplato, not the first time that I have this kind of problem, but this is the best solution I've found yet.

No more problem... I don't really understand you last message.

To find the article, just search "cacls" with the search tool on http://www.robvanderwoude.com/index.html

Posted

No more problem... I don't really understand you last message.

To find the article, just search "cacls" with the search tool on http://www.robvanderwoude.com/index.html

<{POST_SNAPBACK}>

You said, "The pipe syntax does work."

I was just wondering if that meant:

the pipe sent the desired character...

...but did not work because you still needed to press enter

or

the pipe did not send the desired character...

or

the pipe syntax does not work within AutoIt

or

..........

The example on the site about sending both Y and Enter to a command did not happen to use calcs as the command :-(

No big deal for me, I do not need it, I was looking for it for you... :-)

You said, "The problem is that I need to write "y" and then type ENTER to confirm that I really want to change the rights." So I replied, "Sending Y and Enter involved piping a txt file to the command... but I cannot find that link that I was reading yesterday. Do you think that this would help?"

...but alas, I'm out of time for now...

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted

The syntax "echo y|cacls...." means that 'y' is sent as an input in the function cacls. So when cacls needs an input (during the confirmation), 'y' is queuing and is interpreted as the answer.

No need to press ENTER or emulate that.

"The pipe syntax does work" => this way to enter the command do exactly what I want (= the pipe syntax works, i didn't forget a "not" between does and work =). Thanks a lot.

Posted

The syntax "echo y|cacls...." means that 'y' is sent as an input in the function cacls. So when cacls needs an input (during the confirmation), 'y' is queuing and is interpreted as the answer.

No need to press ENTER or emulate that.

"The pipe syntax does work" => this way to enter the command do exactly what I want (= the pipe syntax works, i didn't forget a "not" between does and work =). Thanks a lot.

<{POST_SNAPBACK}>

No wonder you were confused!

I do not know what I was reading/thinking!!!

(I'll blame it on lack of sleep... yeah, that's it, not enough sleep.)

Glad that I could help - sorry that you had to put up the senility that followed my one good post in this thread. You were very kind and patience with me. Thanks...

[size="1"][font="Arial"].[u].[/u][/font][/size]

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