myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


VBSCRIPT Help

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Scripting Technologies] >> VB Script >> VBSCRIPT Help Page: [1]
Login
Message << Older Topic   Newer Topic >>
VBSCRIPT Help - 6/2/2008 12:31:24 PM   
Soze

 

Posts: 3
Score: 0
Joined: 5/28/2008
Status: offline


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
Post #: 1
RE: VBSCRIPT Help - 7/2/2008 1:57:31 PM   
vrodrigues

 

Posts: 65
Score: 9
Joined: 6/8/2001
From: Massachusetts
Status: offline
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 ************************************

< Message edited by vrodrigues -- 7/2/2008 1:59:11 PM >

(in reply to Soze)
Post #: 2
Page:   [1]
All Forums >> [Scripting Technologies] >> VB Script >> VBSCRIPT Help Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.625