Hi all,

Just wondering if someone can point out where I have gone wrong with this, I am getting this error code. - 0x80041017

This code is restoring a dll file I replaced in another script (which works finie) but this one errors.

Dim FSO
'Copies over new warngina.dll and replaces the old one in the C:\windows\system32 folder

Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("Wscript.Shell")

sd = WshShell.ExpandEnvironmentStrings("%systemdrive%")
sr = WshShell.ExpandEnvironmentStrings("%systemroot%")

strComputer = "."
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Cim_Datafile where Name = " _
& "'C:\winnt\system32\warngina.dll'")
For Each objFile in colfiles
errResult = objFile.Rename("C:\\winnt\\system32\\warngina.002" )
Wscript.Echo errResult
Next

SourceFolder = "\\<server>\migration$\WTS Update Scripts\Warngina_Update\warngina.old"
DestFolder = sr & "\system32\warngina.dll"

'Copies the file to system32 path and overwrites the existing one there.
FSO.CopyFile SourceFolder, DestFolder, True

Cheers for any help,
TG
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
You don't say at which line the error occurs. It could be the rename which fails (IMV, the most likely - see below) or the copy.

I suspect that, given that the filename includes the text 'GINA' that this is a login screen add-on/replacement of some kind? If so, it's likely that the file is open and cannot be replaced in that state: you'd have to use the usual PendingFileRenameOperation-and-reboot hack to replace it.
Answered 05/18/2009 by: VBScab
Red Belt

Please log in to comment
0
don't do it, create a msi file and let windows installer take care of versioning for you
Answered 05/19/2009 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
Not much use if the OP wants to return to a previous, older version, though, Mr G. :)
Answered 05/19/2009 by: VBScab
Red Belt

Please log in to comment
0
Yeah, you see all kinds of crazy things in this here world...LOL!
Answered 05/19/2009 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
ORIGINAL: VBScab

You don't say at which line the error occurs. It could be the rename which fails (IMV, the most likely - see below) or the copy.

I suspect that, given that the filename includes the text 'GINA' that this is a login screen add-on/replacement of some kind? If so, it's likely that the file is open and cannot be replaced in that state: you'd have to use the usual PendingFileRenameOperation-and-reboot hack to replace it.



Sorry people,

Getting the error at this line
For Each objFile in colfiles
The error is saying (null) to I was thinking the colfiles or something is empty maybe.

I have got it working just using FSO instead, I couldnt spend that much more time on it as I needed it working.
Answered 05/19/2009 by: Thegunner
Second Degree Green Belt

Please log in to comment
0
LOL...That'll teach me to actually READ posts...I didn't notice you weren't using FSO!

You can't specify a path like that. It would have to be:Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Path = '\\Scripts\\'" AND Drive = 'C:')
Answered 05/20/2009 by: VBScab
Red Belt

Please log in to comment
0
I was using FSO for a part, but saw someone using WMI so I tried it that way couldnt get it work due to the error. Now just gone down the road of using FSO. But if someone knows how to get it to work, I will use it for the future.

ta
Answered 05/20/2009 by: Thegunner
Second Degree Green Belt

Please log in to comment
0
if someone knows how to get it to workEr, did you somehow miss the post immediately above your last?!? :)
Answered 05/21/2009 by: VBScab
Red Belt

Please log in to comment
0
Hi VBScab,

I replaced the line with the line you put and its still giving me a error on the 'For Each objFile in colFiles'
Saying value is Null.

anymore ideas?


'On Error Resume Next
Dim FSO
'Copies over new warngina.dll and replaces the old one in the C:\windows\system32 folder

Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("Wscript.Shell")

sd = WshShell.ExpandEnvironmentStrings("%systemdrive%")
sr = WshShell.ExpandEnvironmentStrings("%systemroot%")

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Path = 'C:\Winnt\system32\warngina.dll'")

For Each objFile in colFiles
errResult = objFile.Rename("C:\\winnt\\system32\\warngina.001" )
Wscript.Echo errResult
Next

SourceFolder = "\\<server>\migration$\WTS Update Scripts\Warngina_Update\warngina.old"
DestFolder = sr & "\system32\warngina.dll"

'Copies the file to system32 path and overwrites the existing one there.
FSO.CopyFile SourceFolder, DestFolder, True
Answered 05/21/2009 by: Thegunner
Second Degree Green Belt

Please log in to comment
0
Really? I don't see it there!Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Path = 'C:\Winnt\system32\warngina.dll'") should be
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Path = '\Winnt\system32' AND Drive = 'C:'")

NB! In pasting this text in, I noticed that I'd left the original terminating quote mark in the wrong place. The line above should work.

Also, you wish to refer to the horse's mouth, as it were: http://www.microsoft.com/technet/scriptcenter/resources/qanda/dec04/hey1209.mspx
Answered 05/22/2009 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity