Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with startup script for folder permissions

Status
Not open for further replies.

ricardofilipe

IS-IT--Management
Jul 7, 2008
4
PT
I'm using a Windows 2003 Server Domain AD for authentication. The user's machines (computers running windows xp pro sp3) have a folder in which i need to change permissions so that i can install an app and the user has full control over that folder . I managed to create a startup script in vbs that would change the folder's permissions on all machines to full control for the autheticated user but the problem is that when the script runs, a DOS window opens and asks for the administrator password. Here is the script:

Set WshShell = WScript.CreateObject("WScript.Shell")
dim PastaDaBarra, objFSO, Erro
set objFSO = CreateObject("Scripting.FileSystemObject")
PastaDaBarra ="c:\Barra"
If objFSO.FolderExists(PastaDaBarra) Then
Erro = WshShell.run("runas /user:Administrator ""%COMSPEC% /C Echo Y| cacls c:\Barra /E /T /C /G Users:F""", 2, True)
WScript.Sleep 200
WshShell.Sendkeys "adminpassword"
WScript.Sleep 200
WshShell.Sendkeys "~"

If Erro <> 0 Then
WScript.Echo "Error" & strUtilizador & " for folder " & PastaDaBarra
Else
WScript.Echo "Success " & strUtilizador & " for folder " & PastaDaBarra
End If
End If


I want the script to run without asking any questons and to change permissions for the folder to full control for the user. What is wrong with my script and is there any other way besides changing it locally on every machine?
I know it's a bit confusing but i tried to explain the best i could :)
Thank you for your help.
 
RE:("runas /user:Administrator ""%

try running it as SYSTEM, or doing this as a startup script instead which will use system automatically.


_______________________________________
I hope any help I give leads to great successes.
MCSE, MCSA, MCTS, CCA, VCP, CCNA
 
You are calling the shell to run the runas command without supplying a password. You need to supply a password to use the method you are trying. I DO NOT SUGGEST THIS, as the password will be in clear text in your script....not good...

-Brandon Wilson
MCSE:Security00/03
MCSA:Messaging00
MCSA:Security03
A+

 
Why do you need to make this a startup script in the first place?

Why not run the script once from your admin workstation and have it remotely access the workstations and set permissions?

You could use error trapping to identify computers that were offline and follow up with those.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
One other comment, if you REALLY want to use a RUNAS to enter admin credentials remotely, then you can use a utility to pass those on securely. Check out the alternatives here:


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
I second Marks first comment...run a remote script to perform this task. It can be done via a network shell with vbscript combined with shell commands to run subinacls, cacls, or xcacls.

-Brandon Wilson
MCSE:Security00/03
MCSA:Messaging00
MCSA:Security03
A+

 
Thank you very much everyone for your help, it's working great now.
 
What was the resolution you chose?


_______________________________________
I hope any help I give leads to great successes.
MCSE, MCSA, MCTS, CCA, VCP, CCNA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top