Hi, I have a script that stops the SMS service, then Stops the winmgmt
service, then renames the %windir%\system32\Wbem\repository to
repository.old.
I then have the SMS service restart and the winmgmt service restarts
automatically.
I altered the script to work off of a computer machine name input. It goes
to the computer stops both the SMS service agent, winmgmnt sucessfully....but
when WMI is used to rename the folder of this remote machine, winmgmt starts
up again and blocks renaming of the repository directory. I guess WMI
directly uses the repository directory and can't rename a folder it is using.
Strange how the script runs great on a local machine but can't complete the
rename of the folder remotely. I guess I am using WMI to rename the
Repository on a remote machine and Plain Wscript when renaming the repository
when the script is run locally.
Any ideas of how to run a script like this and have it rename the Repository
from a remote machine. Here is some of the code that fails when it trys to
rename the repository. BTW, it works fine if you rename another folder inside
the Wbem directory...such as performance. It is obvious that invoking WMI
from a remote machine to rename a folder that WMI needs, starts WMI and locks
down the renaming of the Repository.
I am looking at having to repair SMS on 500 machines and I hate to VNC to
all of them. I am just about ready to give up on a script to kill the
directory remotely. Having a script to do it all will VNCing to a machine
will still save time.
Thanks for any ideas.
Jeff
If someone wants to look at the code for local renaming and remote, the code
is below. For the remote renameing, strComputer is taken from an Input
sub...person inputs the machine name to connect to.
Here is the script portion to rename the Repository remotely.
'Set objWMIService = GetObject("winmgmts:" _
' & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'
'Set colFolders = objWMIService.ExecQuery _
' ("Select * from Win32_Directory where name =
'c:\\Windows\\system32\\wbem\\Repository'")
''
'For Each objFolder In colFolders
' errResults = objFolder.Rename ("C:\Windows\system32\wbem\Repository."&
Month(Now) &"-" & Day(Now) &"-" & Right(Year(Now),2))
'' errResults = objFolder.Rename("C:\Windows\system32\wbem\Repository.old")
Here is a sub of the code I run when trying to rename the Repository dir
locally.
Sub SubMove_Repository()
'Rename Repository directory with MoveFolder command...can't force a move
to overwrite, so we use the date as extension
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFso.FolderExists("c:\Windows\system32\wbem\Repository") Then
objFSO.MoveFolder objNetworkSysEnv("SYSTEMROOT") &
"\system32\wbem\Repository" , objNetworkSysEnv("SYSTEMROOT") &
"\system32\wbem\Repository."& Month(Now) &"-" & Day(Now) &"-" &
Right(Year(Now),2)
End If
End Sub