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

Re: can't rename Repository Dir remotely by Torgeir

Torgeir
Mon Jul 25 05:54:24 CDT 2005

Digiman57 wrote:

> 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.
> (snip code)
Hi,

After stopping the WMI service, why not use the admin share
(\\ComputerName\C$\Windows\system32\wbem\Repository) to rename
the folder (using e.g. WSH's FileSystemObject)?




--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: can't rename Repository Dir remotely by Digiman57

Digiman57
Mon Jul 25 09:03:07 CDT 2005

Thanks Torgeir,
That worked. I will figure out how to get the Input of the computer name to
work now. I think it is cool that I mentioned you to our other Network guru a
while back, as you being a scripting 'god', and you were the first to answer
my post. I think I have learned how to script just from looking up scripting
issues on google and putting your name in the search.
Thanks again Torgeir.
Jeff Little

"Torgeir Bakken (MVP)" wrote:

> Digiman57 wrote:
>
> > 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.
> > (snip code)
> Hi,
>
> After stopping the WMI service, why not use the admin share
> (\\ComputerName\C$\Windows\system32\wbem\Repository) to rename
> the folder (using e.g. WSH's FileSystemObject)?
>
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>