How to run a VBS script in VBA

R

Rob LMS

In an earlier posting, I mentioned modifying NTSF security settings. I found
the xcacls.vbs script by Microsoft that accomplishes the task.

Is there a way to convert it to VBA? Do I have to call it with a shell
command or is there another way to excute the vbs script from within VBA?

Thanks
 
J

John Nurick

Hi Rob,

xcacls.vbs is designed to be run from the command line just like
cacls.exe, so to use it from VBA or another script you'd normally shell
to it in the usual way, e.g.

RetVal = Shell("CSCRIPT ""D:\folder\xcacls.vbs"" arguments")

In principle, if you have the VBScript code you can paste it into a VBA
module and hack it about until it compiles and you can run the
procedures it contains. Since xcacls.vbs looks as if it contains more
than 2000 lines of code in 40 or 50 procedures, that's no small task. I
feel it would be easier to write VBA code that generates the Shell
statements needed.
 
D

Douglas J. Steele

It depends on the script. Sometimes it'll port directly into VBA with no
changes. Sometimes you might have to set a reference to the Scripting
Library.

Have you tried just running it in VBA? If so, what happened?
 
Top