VBSCRIPT Help (Full Version)

All Forums >> [Scripting Technologies] >> VB Script



Message


Soze -> VBSCRIPT Help (6/2/2008 12:31:24 PM)



I trying to changed this script so that it deletes the "UCF" directory for all users instead of just the person that is logged on. What do I have to change for that to happen?

Thx for the Help


Dim objWSHShell :Set objWSHShell = CreateObject("WScript.Shell")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

DocumentumDir = ExpandEvnVariable("userProfile") & "\Documentum\"
If objFSO.folderExists(DocumentumDir & "ucf") Then
If objFSO.folderExists(DocumentumDir & "ucf.old") Then
objFSO.deleteFolder(DocumentumDir & "ucf.old")
End If
objFSO.MoveFolder DocumentumDir & "ucf" , DocumentumDir & "ucf.old"
End If
''________________________________________________ __________________________________________________ _____________________________
Function ExpandEvnVariable(ExpandThis)
ExpandEvnVariable = objWSHShell.ExpandEnvironmentStrings("%" & ExpandThis & "%")
End Function




vrodrigues -> RE: VBSCRIPT Help (7/2/2008 1:57:31 PM)

The script below should do the trick.

'************************* Start of Script ********************************
Option Explicit
Dim DebugMode
Dim strComputer
Dim objFSO
Dim objRegistry
Dim result
Dim ProfSIDKeys
Dim ProfSID
Dim strProfPath
Dim DocumentumDir

Const HKEY_LOCAL_MACHINE = &H80000002

Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = GetWMIAttributeValue("Win32_ComputerSystem","Name")
set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/default:StdRegProv")

result = objRegistry.EnumKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", ProfSIDKeys)

For Each ProfSID In ProfSIDKeys
If (ProfSID <> "S-1-5-18") And (ProfSID <> "S-1-5-19") And (ProfSID <> "S-1-5-20") Then
result = objRegistry.GetExpandedStringValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & ProfSID, "ProfileImagePath", strProfPath)
DocumentumDir = strProfPath & "\Documentum\"
If objFSO.folderExists(DocumentumDir & "ucf") Then
 If objFSO.folderExists(DocumentumDir & "ucf.old") Then
  objFSO.deleteFolder(DocumentumDir & "ucf.old")
 End If
 objFSO.MoveFolder DocumentumDir & "ucf" , DocumentumDir & "ucf.old"
End If
End If
Next


Function GetWMIAttributeValue (ClassName,ClassAttribute)
Dim value
Dim ClassSet
Dim ClassInst
value=""
Set ClassSet = GetObject("winmgmts:").ExecQuery("Select * from " + ClassName)
For Each ClassInst In ClassSet
value = Trim(ClassInst.properties_(ClassAttribute))
Next
GetWMIAttributeValue = value  
end Function

'********************************* End of Script ************************************




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.265625