Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

wshShell.Run syntax problemHelpful Member!(2) 

elmurado (IS/IT--Management) (OP)
14 Mar 07 21:53
Hi all,
have this snippet:
=======================
For Each groupName in ShareList
Set wshShell = wscript.CreateObject("WScript.Shell")
wshShell.run "xcacls ""d:\User Folders\admin"" /g _ administrators:f /y"
==============================

Which does work.
If I put
==========================
For Each groupName in ShareList
Set wshShell = wscript.CreateObject("WScript.Shell")
wshShell.run "xcacls ""d:\User Folders\"" & groupName_ & " /g administrators:f /y"

It doesn't work. I have tried a few variations and it seems to come down to the syntax especially where the quotes go and how many I need.

Any ideas?
Documentation on this seems pretty scant.
Helpful Member!  dm4ever (TechnicalUser)
14 Mar 07 21:59
Try this:

CODE

For Each groupName in ShareList
Set wshShell = wscript.CreateObject("WScript.Shell")
wshShell.run "xcacls ""d:\User Folders\" & groupName_ & """ /g administrators:f /y"

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid

elmurado (IS/IT--Management) (OP)
14 Mar 07 22:06
nice one dude.
I keep getting confused with which pair of quotes is doing what and belongs where.
dm4ever (TechnicalUser)
14 Mar 07 22:14
Thanks.  EBGreen suggested, in another thread, using a function to add the additional quotes so this could be another possible option.

CODE

...code
For Each groupName in ShareList
Set wshShell = wscript.CreateObject("WScript.Shell")
wshShell.run "xcacls " & AddQuotes("d:\user folders\" & groupName_) & " /g administrators:f /y"
...code
Next

Function AddQuotes(strInput)
    AddQuotes = Chr(34) & strInput & Chr(34)
End Function

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid

elmurado (IS/IT--Management) (OP)
14 Mar 07 22:30
That's nice too. A little cleaner.
elmurado (IS/IT--Management) (OP)
19 Mar 07 1:59
Hey guys, related to this is a problem I find with putting in group names that have a space in them. eg 'InfoSec' as a string works when passed in the script as the instance of the variable groupName but 'Info Sec' does not.
Is this something that can be solved with some more quotes or not?
I can get:
============================
For Each groupName in ShareList
Set wshShell = wscript.CreateObject("WScript.Shell")
wshShell.run "xcacls ""d:\User Folders\" & groupName & """_ /g administrators:f " & groupName & ":c /y"
============================

to work but not if groupName uses an instance that has a space in it.
I know as a workaround I could simply make all the group names 'space-less'.

TIA
Helpful Member!  PHV (MIS)
19 Mar 07 5:19
You may try this:
wshShell.Run "xcacls ""d:\User Folders\" & groupName & """ /g ""administrators:f " & groupName & ":c"" /y"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886

elmurado (IS/IT--Management) (OP)
20 Mar 07 0:04
Thanks PHV-it didn't work but you put me on the right path:
==================
wshShell.run "xcacls ""d:\User Folders\" & groupName & """ /g administrators:f """ & groupName & """:c /y"
==========================
The second string groupName-I think-needs to be enclosed in quotes(as it has a space and any command line stuff needs the extra set of quotes in Win).
This works now.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close