Custom file in system32 folder - Advanced Installer Community
AlfieJ
Posts: 6
Joined: Thu Mar 03, 2016 8:23 pm

Custom file in system32 folder

Good afternoon,

I'm building an installer that installs one executable, a Service, and a web site. All 3 things are successfully installed. They each also refer to a common SQLite database file that also gets installed.

Then I need to create a custom file that contains the path to the SQLIte database file. The file contains a simple JSON structure with the path to the database. I created a C# custom action and it successfully creates this custom file, so everything appears to be working fine up to this point.

But then I need to copy the file to the C:\Windows\System32 folder so that the Service can see it. I have a FileInfo object representing the file I've created, then I use the CopyTo method on that object, providing the path to the system32 folder using the [System64Folder] property.

I've debugged the custom action, and it is properly creating the file, however the CopyTo the system32 folder doesn't appear to do anything. If I specify a different folder the file is copied correctly--it's only the system32 folder that it doesn't get copied to. No exceptions are thrown by the CopyTo method call.

What could be going wrong? Why isn't the file copied to the system32 folder but is copied to other folders?

The installer is running as an administrator.

Thanks for your help,
Alfred
AlfieJ
Posts: 6
Joined: Thu Mar 03, 2016 8:23 pm

Re: Custom file in system32 folder

After some more debugging, I found out that even though the CopyFile path is "C:\Windows\system32" the file is actually being copied to "C:\Windows\SysWOW64".

The installer package type is set to 32-bit.

The file needs to go into the system32 folder, so how do I do that?

Thank you,
Alfred
AlfieJ
Posts: 6
Joined: Thu Mar 03, 2016 8:23 pm

Re: Custom file in system32 folder

After readings posts by others who have had similar issues, I've now switched the project to be mixed 32/64 mode, but still can't seem to get my file into the system32 folder.

Why is it so hard to just put a file in the folder I know it belongs in?

Thanks,
Alfred
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom file in system32 folder

Hello Alfred and welcome to our forums,

Can you try to use a "Launch file" custom action type to launch your custom action and enable its "Use 64-bit Launcher" option and see if this helps?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
AlfieJ
Posts: 6
Joined: Thu Mar 03, 2016 8:23 pm

Re: Custom file in system32 folder

I've tried launching the copy program but it errors out. I see this in the log file:

Code: Select all

MSI (s) (10:C4) [08:44:15:873]: Note: 1: 1722 2: LaunchFile 3: C:\Windows\Installer\MSI2A15.tmp 4: /RunAsAdmin /HideWindow copy <sourcepath>\<filename> C:\Windows\system32\<filename> /Y 

Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor.  Action LaunchFile, location: C:\Windows\Installer\MSI2A15.tmp, command: /RunAsAdmin /HideWindow copy <sourcepath>\<filename> C:\Windows\system32\<filename> /Y 
In the above snippet I replaced my paths and filename with <sourcepath> and <filename>

Why is this error occurring? I can run the exact same command from a command window and it works just fine, and the file goes exactly where I want it to.
AlfieJ
Posts: 6
Joined: Thu Mar 03, 2016 8:23 pm

Re: Custom file in system32 folder

I finally got it working by executing an inline VBScript as a 64-bit script. Here's the code:

Code: Select all

Dim appdir, system32, filename, source, dest

appdir = Session.Property("APPDIR")
system32 = Session.Property("System64Folder")
filename = Session.Property("FILENAME")

source = appdir & filename
dest = system32 & filename

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

fso.CopyFile source, dest
The property 'FILENAME' contains the name of the file I'm copying.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom file in system32 folder

Hello,

I'm glad you got this working.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”