COM1 wrote:I believe that solved my issue. THANK YOU Steffen!
Now to just adjust permissions for those running the script. They need to be able to change the permissions of the folders they create, but the ACE "Change Permissions" doesn't seem to have an effect on the new folder, even though the ACE is checked
You may want to try vbsedit then due to the highlighting you won't be making mistakes like that so easily. it's free software.
For the ACE part of your question, unfortunately with my version this option is not available.
I only have options Read/Write/Change/Full so can't help you with that.
I've also enjoyed myself rewriting it a bit, as you can see vbscript screams for some getObjectErr, throwException function. Anyways, I've added the option explicit and beware that if you don't use braces at some point you will run into the the famous: Can't use quotes when calling a Sub error. Using Call in a consistent manner prevents that although it may change the way that parameters are passed, that's not an issue usually performance wise. Also performance wise it's better to make permanent connections and then reuse those rather than to redeclare oFSO every time you use it.
Code: Select all
option explicit
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oWshShell : Set oWshShell = createobject("wscript.shell")
On Error resume Next
Call oFSO.CreateFolder( "\\folder1\folder1.1\folder1.2\" & InputBox("Please enter a folder") )
Dim iError : iError = Err.Number
On Error Goto 0
If iError = 0 Then
Rem (
'Open write stream
On Error resume Next
Dim outFile : Set outFile = oFSO.CreateTextFile("j:\Projects\CreateFolders.cmd", True)
iError = Err.Number
On Error Goto 0
If iError = 0 Then
Rem (
Call outFile.WriteLine( "md " & strfolder & "\00CustomerService" )
Call outFile.WriteLine( "icacls " & strFolder & "\00CustomerService" /deny domain\user:R /T )
Call outFile.WriteLine( "exit" )
Call outFile.Close()
Rem )
End If
Rem )
End if
If iError <> 0 _
Then Call Err.Raise( iError ) _
Else Call oWshShell.Run( "%comspec% /K \\server\dept\Projects\CreateFolders", 1, True )
etcetera....
Check for Acces Denied Error will make your code more robust ( Not that I am doing anything important rather than just suppressing and then raising the error again, but in the future you may want to decide having the script not to just raise an error and well crash.. )
i also see your naming is not very consistent, at one point you use the term 'obj...' for an object but then you use 'outFile' for another object, which is actually a Textstream object. That's a matter of choice but consistency wise I'd just call it oTextstream and put everything in a function as to not dirty global environment
hope it helps