Jump to content

I declare a variable, @ ComSpec call does not work


i2i8
 Share

Recommended Posts

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

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

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)
Link to comment
Share on other sites

 

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: 

Link to comment
Share on other sites

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

 

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.

Link to comment
Share on other sites

 

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

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