2013-03-04 180 views
0

我正在嘗試爲每個人授予文件夾調用測試權限。如果我這樣做它的工作原理使用vbscript設置權限

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 

所以我的問題是我如何使它發揮作用 請幫助

回答

1

你忘了你的空間,incluide他們在您的變量一樣

var = " C:\Test " 

或更好的售前和他們追加到字符串的其餘部分

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

將變量插入命令字符串時,添加引號也是一個好主意,例如'「...」&Chr(34)&var&Chr(34)&「...」'。 – 2013-03-04 23:28:10

+0

謝謝彼得的幫助。有效 – user1766952 2013-03-05 12:08:13

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 
+0

它的間距問題,感謝 – user1766952 2013-03-06 01:57:44

+0

沒有問題:-) – 2013-03-06 02:01:24