HTA Setting File/Folder Permissions and more...

I am new to HTA, but failrly good with vbscript. I wrote a script that checks our employee record system against our active directory with employee id and any that don't exist in AD get created and put into a NEW USER ACCOUNTS OU in AD.

They stay there until the user signs the acceptable user policy asking for an account to be created. The helpdesk then has to do a couple steps to complete the process. Enable the account, move the user to the proper OU, create the users home directory (the home directory field is filled out, just not created on the server) and possibly create the exchange email accout would be a bonus.

I have a basic HTA right now where a user can input an employee ID and it enables the user account, and creates the home directory, but my line that sets the file permissions isn't working.

intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & HOMEDIRECTORY & " /t /c /g Administrators:f " & UID & ":F ""ALCDSB\Computer Technician"":F " , 2, True)

I know some of the Shell commands don't work like echo, sleep, quit, but I thought the rest did as long as you load the wscript.shell.

Also, would it be possible for me to create the users exchage email account within the HTA or no?
colesyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobSampsonCommented:
Hi colesy,

Almost anything that you can do in VBScript, you can plug into a HTA, so if can find code (I'm sure there's some on EE) to create a mailbox, then we can plug that function in.  I don't have Exchange, so I don't have any code to do that.

As far as the command not working goes, I often use an InputBox to capture the command, then try to run that manually at a command prompt.

So, if you use
InputBox "Prompt", "Title", "%COMSPEC% /c Echo Y| cacls " & HOMEDIRECTORY & " /t /c /g Administrators:f " & UID & ":F ""ALCDSB\Computer Technician"":F "
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " & HOMEDIRECTORY & " /t /c /g Administrators:f " & UID & ":F ""ALCDSB\Computer Technician"":F " , 2, True)

Then you will be able to copy and paste the command and see if it works manually. Two potential issues though:
1) I can't remember is %COMSPEC% is evaluated directly by the Run command.  If not, use cmd /c instead.
2) You may need quotes around the HOMEDIRECTORY, if it contains spaces.
cacls """ & HOMEDIRECTORY & """ /t

Regards,

Rob.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
colesyAuthor Commented:
Rob, first off thank you for taking the time to respond to my question. I have read a ton of your posts on EE and they are very helpful. I think its amazing how much time you spend helping people form start to finish.

I ran the command manually and it did work, so not sure what the deal is.. Where do we go from here?
0
colesyAuthor Commented:
Got it! Completely my fault.. I had another group in the persmissions that wasn't included in the code I posted. It used a variable that wasn't in this script. I had copied this line of code from another script I wrote and didn't notice this. Not sure why I took it out when I posted the code either..

My bad... Thanks for the info.. Points to you for your time. Now I need to try and answer some questions before you do to generate more points for myself lol.
0
RobSampsonCommented:
LOL! That's good. Thanks for the grade.  I'm sure you'll find plenty of questions to answer...the VBScript is the only zone I keep an eye on, and there's always too many for me to check them all out anyway.

Regards,

Rob.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.