user1766952
user1766952

Reputation: 173

set permission with vbscript

I am trying to give permission to everyone to a folder call Test. if i do this it works

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

but if i do this it doesn't

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

so my question is how can i make it work please help

Upvotes: 0

Views: 1572

Answers (2)

peter
peter

Reputation: 42207

You forgot your spaces, incluide them in your variable like

var = " C:\Test "

or better pre- and append them to the rest of the string

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

Upvotes: 1

Travis G
Travis G

Reputation: 1602

Looks like a spacing issue. Can you please try this?

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

Upvotes: 0

Related Questions