So I’m posting this here for my future reference:
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FolderExists("C:Program Files (x86)SmartDraw 2012") Then oFSO.CopyFile "SDX.DLX", "C:Program Files (x86)SmartDraw 2012" End If
If oFSO.FolderExists("C:Program FilesSmartDraw 2012") Then oFSO.CopyFile "SDX.DLX", "C:Program FilesSmartDraw 2012" End If
VBScript can be funny. If you omit the “” on the end of the CopyFile statement, the run time engine will bark at you: something like “Access Denied”. Yet, the “” isn’t needed in the FolderExists statement. So you can spend minutes and minutes looking at the two statements scratching your head why the later doesn’t work.
So what does this code do? Well, it copies an updated license file for a program we use called Smartdraw. The funny thing is that I copied the new license before the old one expired, yet users running Windows 7 started calling the HelpDesk stating their copy of Smartdraw had expired. Yet, if you did a run-as administrator on Smartdraw, the program would work fine. I contacted Smartdraw tech support only to be told that you can simply go into the properties of said program and check the “Run as administrator” box to fix the problem. Not the most elegant solution.
The real problem was that an older copy of the file SDX.DLX was sitting in C:UsersusernameAppDataLocalVirtualStoreProgram Files (x86)SmartDraw 2012. Removing this file fixed the issue. The real question is: why wasn’t this file updated when I did the file copy? Obviously, UAC stepped in the first time and noticed that a file was trying to be written to C:Program Files (x86), so it was re-directed instead to the VirtualStore folder.
Upon first launching Smartdraw, the program attempts to contact an activation server over the Internet and then writes the SDX.DLX file back to the Program Files (x86) directory with the activation status. UAC senses this and then re-directs it to the VirtualStore instead. However, when I ran my script, it ran under the SYSTEM account which likely bypasses UAC and the VirtualStore folder.
– Soli Deo Gloria