Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript ends when I use CScript XXXX.vbs

Posted on 2008-06-12
3
Medium Priority
?
1,927 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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

916 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