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
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
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…
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.
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.
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.