Web Hosting, Design, & Coding forum

Question

Auto answer Y to VB script prompt

by CJones46 / March 21, 2013 2:54 AM PDT

I am using the following script to automate changing permissions on our file servers using cacls.exe:

Dim oShell, FoldPerm, Calcds, oFSO

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")

sSysDir = oFSO.GetSpecialFolder(1).Path
If Right(sSysDir,1) <> "\" Then sSysDir = sSysDir & "\"

'Remove all existing permsissions and grant domain admins full rights
Calcds = sSysDir & "cacls.exe"

FoldPerm = """" & Calcds &"""" & """C:\test""" & " /T /C /G " & """-username-""" & ":f"

oShell.Run FoldPerm, 1 , True

If you use the /E switch for cacls the entire script runs without issue. However, I want the first set of alterations to completely overwrite the existing permissions so the /E switch will not be used.

When the /E switch is not used you are prompted, in a separate command window "Are you sure Y/N?" Since this will be running at 2 Am on Sundays I'd prefer to not have to wake up and answer "Yes" every time it hits a new directory.

I'm not very good at this so I'm hoping for some help.

Thank you!

Answer This Ask For Clarification
Discussion is locked
You are posting a reply to: Auto answer Y to VB script prompt
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: Auto answer Y to VB script prompt
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
Clarification Request
Sorry but I don't use the vb script for this.
by R. Proffitt Forum moderator / March 21, 2013 3:01 AM PDT
Collapse -
Reply
by CJones46 / March 21, 2013 3:47 AM PDT

I have two questions:

1) The notation preceding the batch files strictly dictates that this be used for users home directories, or directories whose names match the username. Will this work outside those parameters?

2) Since I am doing overwriting and replacing permissions, weekly, for an entire fileserver, how modular is this language? With the script that I provided initially all you need to do is copy and paste the below segment of script and change the directory and username accordingly. For example:

Calcds = sSysDir & "cacls.exe"

FoldPerm = """" & Calcds &"""" & """C:\test""" & " /T /C /G " & """-username-""" & ":f"

oShell.Run FoldPerm, 1 , True

Calcds = sSysDir & "cacls.exe"

FoldPerm = """" & Calcds &"""" & """C:\test""" & " /E /T /C /G " & """-usernameA-""" & ":f"

oShell.Run FoldPerm, 1 , True
Calcds = sSysDir & "cacls.exe"

FoldPerm = """" & Calcds &"""" & """C:\testA""" & " /E /T /C /G " & """-usernameB-""" & ":f"

oShell.Run FoldPerm, 1 , True

and so on throughout the entire file structure. So in relatively little time I can assemble the language for an entire file server.

Collapse -
1. I don't see why not.
by R. Proffitt Forum moderator / March 21, 2013 3:52 AM PDT
In reply to: Reply

But more importantly I want to be sure you understand my replies. That is, I can not write scripts for anyone. Why this is, and this is important to understand is that folk may hold me liable. Second, as the administrator you must fully grasp your script.

With that out of the way there is one last issue.

The solution will likely change with the Server OS in use. I don't see that here so I found something very close to what we used in a Microsoft issued KB article. That way I can't be held liable.
Bob

All Answers

Collapse -
Answer
Re: script
by Kees_B Forum moderator / April 5, 2013 8:16 PM PDT

Run the script with input redirected to a file that contains 1000 lines containing Y. Then it will read Y 1000 times. Might be enough. If not, add more lines.

Input and output redirection are basic features of the command processor, so I won't go into details here.

Kees

Popular Forums
icon
Computer Help 49,613 discussions
icon
Computer Newbies 10,349 discussions
icon
Laptops 19,436 discussions
icon
Security 30,426 discussions
icon
TVs & Home Theaters 20,308 discussions
icon
Windows 10 360 discussions
icon
Phones 15,802 discussions
icon
Windows 7 7,351 discussions
icon
Networking & Wireless 14,641 discussions

Tech explained

Do you know what an OLED TV is?

CNET explains how OLED technology differs from regular TVs, and what you need to know to make the right shopping decision.