LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

File Association Through Package Builder

Solved!
Go to solution

Has anyone figured out how to do file association with Package Builder?  I have LV 2014 32bit.  I create an exe and then I have a file type I want to associate with it when the package gets installed.  Because I didn't see anything native I create a batch file and .reg file.  The .reg file associates the file type and the .bat file is needed because you can only invoke .exe and .bat files as post install process (it seems).  When I run these on the deployment machine they work fine.  However, when I try to run it as a post install action on the Advanced tab I get an error.

 

I've figured out why I get the error but cannot come up with a way around it.  It appears that LabVIEW runs the .bat in the WOW64\cmd.exe instead of the windows32\cmd.exe.  I can reproduce this manually.  However, I need to force NI Package Manager to use the windows32\cmd.exe.  So I tried creating yet another batch to try and kick off the first batch file in the correct cmd.exe but couldn't get that working.  Basically my batch file looks like this:

regedit.exe /S "path to reg file"

 

Attached is an image that shows what I mean...sorta....

 

Thoughts????

 

Thanks,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 1 of 3
(2,384 Views)
Solution
Accepted by topic author ~jiggawax~

That is Windows path redirection and pretty hard to work around. No matter if you enter C:\Windows\System32\cmd.exe or C:\Windows\SysWOW64\cmd.exe Windows will always choose the one that is native to the calling process. Since your setup.exe program is a 32 Bit program it ends up calling always the C:\Windows\SysWOW64\cmd.exe program.

 

There are about two solutions though I never had consistent success with 2) despite that Microsoft claims that it should work:

 

1)  Use the system APIs Wow64DisableWow64FsRedirection() and Wow64RevertWow64FsRedirection() to temporarily disable path redirection for the current thread. You need to create an executable for this and do the execution of the command in between the two calls.

However calling 64-bit cmd.exe from a 32 bit process is still not going to work easily. It is the same problem with trying to call a 64 bit executable from 32 bit LabVIEW with System Exec function. Windows doesn't like a 32 bit process to spawn a 64 process (and vice versa). Obviously it can be done as Explorer does it but the system API acrobatics to do so are pretty involved.

 

2) 32-bit applications can access the native system directory by substituting %windir%\Sysnative for %windir%\System32. WOW64 recognizes Sysnative as a special alias used to indicate that the file system should not redirect the access. 

Rolf Kalbermatter
My Blog
Message 2 of 3
(2,370 Views)

Thanks for the response rolfk.  As always you are amazing help.

 

your comment led me to a solution.  I ended up just doing a single exe that does what I need instead of the sandwich method with the revert and disable.  In the future though if I am stuck with a .bat I will take that into consideration.

 

Appreciate it.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 3 of 3
(2,317 Views)