Nonexistent Object for System32

I’m lost on this one… My end goal is to see if file defaultassociations.xml exists in the C:\Windows\System32 directory with a specific SHA1 and if it does not, copy the correct one there.

This should be straightforward but it is like my file isn’t being seen the System32.

See the comparison between my file and a native file:

Q: sha1 of file "C:\Windows\System32\defaultassociations.xml"
E: Singular expression refers to nonexistent object.

Q: sha1 of file "C:\Windows\System32\DefaultDeviceManager.dll"
A: 238a31be3e716e9ba70ea299d8579bdcc000d573

Any ideas?

Take a look at this thread; "Special Windows folders" filesystem inspectors

Whenever you’re working with System Folders, you have to consider x64 redirection. In short, it’s a pain in the behind, but that thread should hold some key observations because I ran into this very problem a while back :slight_smile:

4 Likes

Ha! That is exactly it. Thank you so much for the reference! :medal_military:

1 Like

Of course things can’t be too easy… The action script below, though showing successful, is not working. The delete action isn’t even removing the file using the Fixlet Debugger…

delete "{system x64 folder}\defaultassociations.xml"

move __Download\defaultassociations.xml "{system x64 folder}\defaultassociations.xml"

delete delete?

Also, I have had issues with the move command in the past as it tends to try to retain file permissions of the source file. Try copy instead, and then delete the source file afterwards.

Are you getting some kind of error on the move command? Make sure the file doesn’t already exist, or any native actionscript move or copy command will fail.

Typo on the deletes… The delete command does make sure a file doesn’t already exist. I’ll try the copy. No error, it shows the correct path and success in the BF log… Just doesn’t do it. I’ll keep digging.

Got’cha. Yeah, as far as I know, that action looks kosher. Let me dig up one of my similar fixlets to see if I did something different.

So this is weird. I’m not actually sure why I did it this way, but I disable x64 redirection and then look in system x64 folders but take action in system folders…

if{x64 of operating system}
action uses wow64 redirection false
endif

if{(not exists files “backgroundDefault.jpg” whose (sha1 of it = “1655197b2319ea224960a44f60fd3b91e29f9ba4”) of folders “oobe\info\backgrounds” of system x64 folders) OR (exists files whose (name of it != “backgroundDefault.jpg”) of folders “oobe\info\backgrounds” of system x64 folders)}
folder delete {(system folder as string & “\oobe\info\backgrounds”)}
folder create {(system folder as string & “\oobe\info\backgrounds”)}
copy __Download\backgroundDefault.jpg “{(system folder as string & “\oobe\info\backgrounds\backgroundDefault.jpg”)}”
endif

The bizarre part is that this definitely works; we have a Windows standard image and this action has correctly reverted the image used on several thousand computers. I can’t see why this wouldn’t work with system x64 folder instead of disabling x64 redirection and then operating on system folder, though.

The only real difference I can find is that in my actionscript I use a relevance clause for the whole string, whereas you use a relevance clause for the first part followed by a string. Might want to ensure that you get the expected folder path in the fixletdebugger output, or try the relevance clause string approach to see if it makes a difference.

1 Like

That is all odd… My Actions are taking action on C:\Windows\SysWOW64 and not C:\Windows\System32.

Let me try with the disabling method that you’ve shown…

Ha!!! Success. Thanks again. That is one of those settings that you forget about.

1 Like

Awesome, nicely done.

Yeah, strawgate had some comments on the system32 vs syswow64:

The few times I’ve had to deal with system folders I always had to run through a bunch of testing iterations to get the action to apply to the correct folder. Definitely is confusing.