Jump to content
Sign in to follow this  
i2i8

I declare a variable, @ ComSpec call does not work

Recommended Posts

i2i8

No problem running CMD:

SetACL -on drivers -ot file -actn ace -ace "n:Everyone;p:read_ex"

However, this does not work:

Local $FilesPath = @ScriptDir & '\drivers',$SetACL_Read_ex = '-ot file -actn ace -ace "n:Everyone;p:read_ex"'
Run(@ComSpec & " /c " & "SetACL -on" & $FilesPath  & $SetACL_Read_ex ,"",@SW_HIDE)

Why?

Edited by i2i8

Share this post


Link to post
Share on other sites
michaelslamet

Seems you forgot to put a space between $FilesPath & $SetACL_Read_ex

so try $FilesPath & " " & $SetACL_Read_ex

Share this post


Link to post
Share on other sites
i2i8

Seems you forgot to put a space between $FilesPath & $SetACL_Read_ex

so try $FilesPath & " " & $SetACL_Read_ex

I've tried this:

Local $FilesPath = @ScriptDir & '\drivers',$SetACL_Read_ex = '-ot file -actn ace -ace "n:Everyone;p:read_ex"'
Run(@ComSpec & " /c " & "SetACL -on" & "" & $FilesPath & "" & $SetACL_Read_ex,"",@SW_HIDE)

or:

Local $FilesPath = @ScriptDir & '\drivers',$SetACL_Read_ex = '-ot file -actn ace -ace "n:Everyone;p:read_ex"'
Run(@ComSpec & " /c " & "SetACL -on" & $FilesPath & "" & $SetACL_Read_ex,"",@SW_HIDE)

But,it still not working

Edited by i2i8

Share this post


Link to post
Share on other sites
Factfinder

Use "SetACL -on " instead of  "SetACL -on" to have a space between -on and $FilesPath. Also use  $SetACL_Read_ex = ' -ot instead of $SetACL_Read_ex = '-ot or use  $FilesPath  & " " & $SetACL_Read_ex

So it will be one of these:

Local $FilesPath = @ScriptDir & '\drivers',$SetACL_Read_ex = ' -ot file -actn ace -ace "n:Everyone;p:read_ex"'
Run(@ComSpec & " /c " & "SetACL -on " & $FilesPath  & $SetACL_Read_ex ,"",@SW_HIDE)
Local $FilesPath = @ScriptDir & '\drivers',$SetACL_Read_ex = '-ot file -actn ace -ace "n:Everyone;p:read_ex"'
Run(@ComSpec & " /c " & "SetACL -on " & $FilesPath  & " " & $SetACL_Read_ex ,"",@SW_HIDE)

Share this post


Link to post
Share on other sites
i2i8

 

Use "SetACL -on " instead of  "SetACL -on" to have a space between -on and $FilesPath. Also use  $SetACL_Read_ex = ' -ot instead of $SetACL_Read_ex = '-ot or use  $FilesPath  & " " & $SetACL_Read_ex

So it will be one of these:

Local $FilesPath = @ScriptDir & '\drivers',$SetACL_Read_ex = ' -ot file -actn ace -ace "n:Everyone;p:read_ex"'
Run(@ComSpec & " /c " & "SetACL -on " & $FilesPath  & $SetACL_Read_ex ,"",@SW_HIDE)
Local $FilesPath = @ScriptDir & '\drivers',$SetACL_Read_ex = '-ot file -actn ace -ace "n:Everyone;p:read_ex"'
Run(@ComSpec & " /c " & "SetACL -on " & $FilesPath  & " " & $SetACL_Read_ex ,"",@SW_HIDE)

 

It still not working :sweating: 

Share this post


Link to post
Share on other sites
i2i8

I'm so happy, I finally understand the correct usage of the script code

Thank you for helping my friends, thank you!

Local $FilesPath = @ScriptDir & "\drivers",$SetACL_Read_ex = '-ot file -actn ace -ace "n:Everyone;p:read_ex"'

Run(@ComSpec & " /c " & 'SetACL -on' & " " & $FilesPath & " " & $SetACL_Read_ex,"",@SW_HIDE)
Edited by i2i8

Share this post


Link to post
Share on other sites
i2i8

It was already given. :)

After "SetACL -on",no one space

You add this code more than one space

Share this post


Link to post
Share on other sites
Factfinder

 

Use "SetACL -on " instead of  "SetACL -on" to have a space between -on and $FilesPath. Also use  $SetACL_Read_ex = ' -ot instead of $SetACL_Read_ex = '-ot or use  $FilesPath  & " " & $SetACL_Read_ex

So it will be one of these:

Local $FilesPath = @ScriptDir & '\drivers',$SetACL_Read_ex = ' -ot file -actn ace -ace "n:Everyone;p:read_ex"'
Run(@ComSpec & " /c " & "SetACL -on " & $FilesPath  & $SetACL_Read_ex ,"",@SW_HIDE)
Local $FilesPath = @ScriptDir & '\drivers',$SetACL_Read_ex = '-ot file -actn ace -ace "n:Everyone;p:read_ex"'
Run(@ComSpec & " /c " & "SetACL -on " & $FilesPath  & " " & $SetACL_Read_ex ,"",@SW_HIDE)

In both the above cases there was only one space.

Share this post


Link to post
Share on other sites
i2i8

In both the above cases there was only one space.

Thank you for your continued interest in my topic and for helping me

but

I suggest you test this yourself better

SetACL

Share this post


Link to post
Share on other sites
i2i8

 

I'm so happy, I finally understand the correct usage of the script code

Thank you for helping my friends, thank you!

Local $FilesPath = @ScriptDir & "\drivers",$SetACL_Read_ex = '-ot file -actn ace -ace "n:Everyone;p:read_ex"'

Run(@ComSpec & " /c " & 'SetACL -on' & " " & $FilesPath & " " & $SetACL_Read_ex,"",@SW_HIDE)

Just now, when I run this code again, it does not work.why??

Share this post


Link to post
Share on other sites
michaelslamet

Try to replace the Run(@ComSpec & " /c " with Run(@ComSpec & " /k " so you can see what's wrong

Share this post


Link to post
Share on other sites
i2i8

Try to replace the Run(@ComSpec & " /c " with Run(@ComSpec & " /k " so you can see what's wrong

I could not see the wrong.

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  

×