swissjay
(Just in Town)
2010-10-19 05:23 PM
AddProgramItem Problem with "Program Files(x86)" Folder

Hello Everyone

I try to create Shortcuts for the New Office Version on a Windows 2008 R2 Server. This Windows is an 64-Bit Release, therefore all 32-Bit Application incl. MS Office are installed under C:\Program Files (x86). e.g. Office path: C:\Program Files (x86)\Microsoft Office\Office14

I try to create a Shortcut for Access with the following code:

AddProgramGroup ("Microsoft Office 2010")
AddProgramItem ("C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE", "Microsoft Access 2010", "", "", "C:\Program Files (x86)\Microsoft Office\Office14", 0, 0)

This isnt working at all. For 64-Bit Application installed under C:\Program Files all work well...

Have you an idea how to solve it?

Cheers

Jerome


Mart
(KiX Supporter)
2010-10-19 07:18 PM
Re: AddProgramItem Problem with "Program Files(x86)" Folder

I'm not using any 64 bit stuff yet but you might want to have a look at
 Code:
SetOption( "Wow64FileRedirection", "ON")

All SetOption options and what they do are listed on page 98 and 99 of the 4.61 manual.


swissjay
(Just in Town)
2010-10-20 11:12 AM
Re: AddProgramItem Problem with "Program Files(x86)" Folder

I found a Workaraund: Using DOS-names 8.3 Format works.

C:\Program Files(x86) = C:\Progra~2

User dir /x command to see 8.3 Format names

e.g.

AddProgramGroup ("Microsoft Office 2010")
AddProgramItem ("C:\Progra~2\Microsoft Office\Office14\MSACCESS.EXE", "Microsoft Access 2010", "", "", "C:\Progra~2\Microsoft Office\Office14", 0, 0)

Thanks for reading.

Cheers


Glenn BarnasAdministrator
(KiX Supporter)
2010-10-20 01:14 PM
Re: AddProgramItem Problem with "Program Files(x86)" Folder

Here's some kix code to automatically determine the path:
 Code:
    ; 32b Program Files path
    ; Determine the 8.3 name of the appropriate 32-bit (x86) Program Files path
    ; Get the full path
    $_Rc = IIf(InStr('%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%', 'AMD64'), '%ProgramFiles(x86)%', '%ProgramFiles%')
    ; now get the 8.3 name
    $_Value = Left($_Rc, 3)
    $_Rc = WshPipe('%COMSPEC% /c dir ' + $_Value + ' /X | %WINDIR%\System32\Find.exe /i "' + SubStr($_Rc, 4) + '"')
    $_Value = $_Value + Trim(SubStr($_Rc[0][0], 40, 12))
This relies on our modified version of WSHPipe, downloadable from our Kix library on our web site. This does the detection and assures that it is properly translated to the 8.3 name.

Glenn


BradV
(Seasoned Scripter)
2010-10-20 01:49 PM
Re: AddProgramItem Problem with "Program Files(x86)" Folder

Somehow I think it might work if you used single quotes instead of double quotes. Try:

 Code:
AddProgramItem ('C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE', "Microsoft Access 2010", "", "", 'C:\Program Files (x86)\Microsoft Office\Office14', 0, 0)


or

 Code:
$Loc = "C:\Program Files " + Chr(40) + "x86" + Chr(41) + "\Microsoft Office\Office14"
AddProgramItem ($Loc + "\MSACCESS.EXE", "Microsoft Access 2010", "", "", $Loc, 0 0)


Glenn BarnasAdministrator
(KiX Supporter)
2010-10-20 05:43 PM
Re: AddProgramItem Problem with "Program Files(x86)" Folder

The problem with the OP's code is that it hard codes a location, and that path is valid only on x64 systems. Wrapping it in quotes will make the code work, but only for a specific system configuration.

The code I posted uses the environment vars to determine the OS architecture and 32-bit PF path. This method will work on any system regardless of where the program files folder is, and will work on all architectures.

The resulting value will be the 8.3 folder name of the 32-bit program files path.

Glenn


AllenAdministrator
(KiX Supporter)
2010-10-21 03:12 PM
Re: AddProgramItem Problem with "Program Files(x86)" Folder

I don't use AddProgramItem, so I haven't done any tests... but just based on this thread, wouldn't this qualify as a bug?

NTDOCAdministrator
(KiX Master)
2015-09-01 09:12 AM
Re: AddProgramItem Problem with "Program Files(x86)" Folder

Normally would not dig up and post to a topic this old but since I have code that pretty much already tells you where it's installed I'll post for those that happen along her in a Google search somehow.

Using the registry location for AppPath will tell you where the application is installed.

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

Read it and use in var as needed.