Solved

VBScript ends when I use CScript XXXX.vbs

Posted on 2008-06-12
3
1,586 Views
Last Modified: 2010-04-21
The following VBScript code works but displays the informational message:

'set permissions on new home folder  
                    Set objWsh = CreateObject("Wscript.Shell")
                    If objFSO.FolderExists(strHomeFolder) Then
                    ' Uncheck inherit permissions on home folder.
                    objWsh.run "c:\WINNT\xcacls.vbs \\oak\Users$\" & strNTName & " /I copy", 1, True
                    'remove Authenticated Users from ACL'
                    objWsh.run "c:\WINNT\xcacls.vbs \\oak\Users$\" & strNTName & " /r ""NT AUTHORITY\Authenticated Users""", 1, True
                    'Add SYSTEM account to ACL
                    objWsh.run "c:\WINNT\xcacls.vbs \\oak\Users$\" & strNTName & " /G ""NT AUTHORITY\SYSTEM"":F", 1, True
                    'Add Administrators group to ACL'
                    objWsh.run "c:\WINNT\xcacls.vbs \\oak\Users$\" & strNTName & " /E /G administrators:F", 1, True
                    End If

When I insert "cscript" (e.g. objWSH.run "cscript c:\WINNT\xcacls.vbs...) the first line executes and a command window opens showing the status but then the script ends without executing the remaining lines of code.
Any thoughts on supressing the informational dialog box without halting the script?

Thanks.
0
Comment
Question by:bstillion
  • 2
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 125 total points
ID: 21769400
try passing it through cmd or start..


objWsh.run "cmd /c cscript c:\WINNT\xcacls.vbs \\oak\Users$\" & strNTName & " /I copy", 1, True

'or

objWsh.run "start /wait c:\WINNT\xcacls.vbs \\oak\Users$\" & strNTName & " /r ""NT AUTHORITY\Authenticated Users""", 1, True

Open in new window

0
 

Author Comment

by:bstillion
ID: 21769505
Sirbounty,

Thanks. The first option worked perfectly!

You saved me hours of "trial-and-error" and "google"

Brad
0
 

Author Closing Comment

by:bstillion
ID: 31466543
Thanks for the almost instant response!
Brad
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Welcome to part one of a multi-part tutorial series, VBScript for Windows System Administrators.  The goal of this series is to teach non-programmers how to write useful VBS code to automate their environment, and perform tasks faster, and in a more…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now