Solved

VBScript ends when I use CScript XXXX.vbs

Posted on 2008-06-12
3
1,719 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

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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