ricardofilipe
IS-IT--Management
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.
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.