使用vbscript设置权限

时间:2013-03-04 22:03:14

标签: vbscript

我正在尝试将每个人的权限授予文件夹调用Test。如果我这样做就行了

objShell.ShellExecute "cmd.exe","/k icacls c:\Test /grant everyone:(OI)(CI)M ", "",  

但是,如果我这样做,它不会

Set objShell = CreateObject("Shell.Application")
  Dim var
  var = "C:\Test"
  objShell.ShellExecute "cmd.exe", "/k icacls" & var & "/grant everyone:(OI)(CI)M ", "",  "runas", 1

所以我的问题是如何让它发挥作用 请帮忙

2 个答案:

答案 0 :(得分:1)

您忘记了空格,将其包含在您的变量中

var = " C:\Test "

或更好预先将它们附加到字符串的其余部分

objShell.ShellExecute "cmd.exe", "/k icacls " & var & " /grant everyone:(OI)(CI)M ", "",  "runas", 1

答案 1 :(得分:0)

看起来像是间距问题。你能试试吗?

Set objShell = CreateObject("Shell.Application")
  Dim var
  var = "C:\test"
  objShell.ShellExecute "cmd.exe", " /k icacls " & var & " /grant everyone:(OI)(CI)M ", "",  " runas ", 1