Renames windows launcher name to one using the application name.

cusax-fix
Damian Minkov 13 years ago
parent 8610f37848
commit 2c6d57dcc2

@ -372,7 +372,7 @@
</target>
<target name="build-installation-wix-base"
depends="clean-install-windows">
depends="clean-install-windows,define-ant-contrib-task">
<property name="windows.package.name"
value="${package.name}-${sip-communicator.version}-${windows.package.name.suffix}"/>
<property name="windows.msi.package.name"
@ -389,6 +389,41 @@
<entry key="changes_html" value="updates/index.html" />
</propertyfile>
<!-- removes spaces from application name if any -->
<propertyregex property="app.exe.filename"
input="${application.name}"
regexp=" "
replace=""
override="true"
global="true"
defaultValue="${application.name}"/>
<!-- removes '-' from app.exe.filename if any -->
<propertyregex property="app.exe.filename"
input="${app.exe.filename}"
regexp="-"
replace=""
override="true"
global="true"
defaultValue="${app.exe.filename}"/>
<!-- removes '_' from app.exe.filename if any -->
<propertyregex property="app.exe.filename"
input="${app.exe.filename}"
regexp="-"
replace=""
override="true"
global="true"
defaultValue="${app.exe.filename}"/>
<!-- if wix.app.launcher.name is not set use app.exe.filename
If using wix.app.launcher.name make sure not to use spaces,-,_
in the name.
-->
<condition property="wix.app.launcher.name"
value="${app.exe.filename}">
<not>
<isset property="wix.app.launcher.name" />
</not>
</condition>
<!--
Prepare for the execution of heat.exe (which is part of the
preparation for the execution of candle.exe).
@ -406,9 +441,10 @@
<arg value="MINGW_HOME=${mingw.home}" />
<arg value="TARGET_DIR=${light.dir}" />
<arg value="PRODUCTBUILDVERSION=${sip-communicator.version}" />
<arg value="TARGET_BASENAME=${wix.app.launcher.name}" />
</exec>
<antcall target="wix-sign-file">
<param name="file.to.sign" value="${light.dir}/run.exe"/>
<param name="file.to.sign" value="${light.dir}/${wix.app.launcher.name}.exe"/>
</antcall>
<delete>
<fileset dir="${light.dir}">
@ -655,6 +691,7 @@
<!-- Finish the preparation for the execution of candle.exe -->
<filter token="APP_EMAIL" value="${application.email}" />
<filter token="APP_NAME" value="${application.name}" />
<filter token="APP_LAUNCHER_NAME" value="${wix.app.launcher.name}" />
<filter token="APP_WEB" value="${application.web}" />
<filter token="APP_PUBLISHER" value="${application.publisher}" />
<filter token="PRODUCTBUILDVERSION" value="${sip-communicator.version}" />

@ -26,7 +26,7 @@
Key="shell\open\command"
KeyPath="yes"
Type="string"
Value='"[INSTALLDIR]run.exe" %1' />
Value='"[INSTALLDIR]@APP_LAUNCHER_NAME@.exe" %1' />
</RegistryKey>
</Component>
<Component
@ -45,7 +45,7 @@
Key="shell\open\command"
KeyPath="yes"
Type="string"
Value='"[INSTALLDIR]run.exe" %1' />
Value='"[INSTALLDIR]@APP_LAUNCHER_NAME@.exe" %1' />
</RegistryKey>
</Component>
<Component
@ -64,7 +64,7 @@
Key="shell\open\command"
KeyPath="yes"
Type="string"
Value='"[INSTALLDIR]run.exe" %1' />
Value='"[INSTALLDIR]@APP_LAUNCHER_NAME@.exe" %1' />
</RegistryKey>
</Component>
@ -80,7 +80,7 @@
KeyPath="yes"
Name="@APP_NAME@"
Type="string"
Value="[INSTALLDIR]run.exe" />
Value="[INSTALLDIR]@APP_LAUNCHER_NAME@.exe" />
</RegistryKey>
</Component>
@ -97,7 +97,7 @@
KeyPath="yes"
Name="IMApplication"
Type="string"
Value="run.exe" />
Value="@APP_LAUNCHER_NAME@.exe" />
</RegistryKey>
</Component>
<?if $(var.Platform) = x64 ?>
@ -114,7 +114,7 @@
KeyPath="yes"
Name="IMApplication"
Type="string"
Value="run.exe" />
Value="@APP_LAUNCHER_NAME@.exe" />
</RegistryKey>
</Component>
<?endif ?>

@ -75,7 +75,7 @@
Id="Shortcut_Desktop"
Icon="Icon.ico"
Name="@APP_NAME@"
Target="[INSTALLDIR]run.exe"
Target="[INSTALLDIR]@APP_LAUNCHER_NAME@.exe"
WorkingDirectory="INSTALLDIR" />
<RegistryValue
Key="Software\Microsoft\@APP_NAME@"
@ -93,7 +93,7 @@
Id="Shortcut_StartMenu"
Icon="Icon.ico"
Name="@APP_NAME@"
Target="[INSTALLDIR]run.exe"
Target="[INSTALLDIR]@APP_LAUNCHER_NAME@.exe"
WorkingDirectory="INSTALLDIR" />
<RegistryValue
Key="Software\Microsoft\@APP_NAME@"
@ -111,7 +111,7 @@
Id="Shortcut_Startup"
Icon="Icon.ico"
Name="@APP_NAME@"
Target="[INSTALLDIR]run.exe"
Target="[INSTALLDIR]@APP_LAUNCHER_NAME@.exe"
WorkingDirectory="INSTALLDIR" />
<RegistryValue
Key="Software\Microsoft\@APP_NAME@"
@ -477,7 +477,7 @@
<Property Id="CREATE_SIP_REGISTRY_ENTRIES" Value="1" />
<Property Id="CREATE_XMPP_REGISTRY_ENTRIES" Value="1" />
<Property Id="IS_AUTOUPDATE" Value="0" Hidden="yes" />
<Property Id="WixShellExecTarget" Value="[#run.exe]" />
<Property Id="WixShellExecTarget" Value="[#@APP_LAUNCHER_NAME@.exe]" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="!(loc.ExitDialogOptionaCheckBoxText)" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />

@ -46,7 +46,7 @@ $(cygwin.target.dir)/$(TARGET_BASENAME).exe: $(cygwin.target.dir)/config.h regis
$(cygwin.target.dir)/config.h:
-rm.exe -f ../../../../resources/install/windows/config.h
echo.exe -e '#define PRODUCTNAME "$(PRODUCTNAME)"\n#define PRODUCTBUILDVERSION "$(PRODUCTBUILDVERSION)"' > $(cygwin.target.dir)/config.h
echo.exe -e '#define PRODUCTNAME "$(PRODUCTNAME)"\n#define PRODUCTBUILDVERSION "$(PRODUCTBUILDVERSION)"\n#define TARGET_BASENAME "$(TARGET_BASENAME)"\n#define TARGET_BASENAME_EXE "$(TARGET_BASENAME).exe"' > $(cygwin.target.dir)/config.h
$(cygwin.target.dir)/run.res: $(cygwin.target.dir)/config.h run.rc
$(WINDRES) -I../../../../resources/install/windows -I$(target.dir) run.rc -O coff -o $(target.dir)/run.res

@ -33,8 +33,8 @@ BEGIN
VALUE "CompanyName", "jitsi.org"
VALUE "FileDescription", PRODUCTNAME
VALUE "FileVersion", PRODUCTBUILDVERSION
VALUE "InternalName", "run"
VALUE "OriginalFilename", "run.exe"
VALUE "InternalName", TARGET_BASENAME
VALUE "OriginalFilename", TARGET_BASENAME_EXE
VALUE "ProductName", PRODUCTNAME
VALUE "ProductVersion", PRODUCTBUILDVERSION
END

@ -8,9 +8,11 @@
import java.io.*;
import net.java.sip.communicator.util.*;
import com.sun.jna.*;
import com.sun.jna.platform.win32.*;
import com.sun.jna.win32.*;
import net.java.sip.communicator.util.*;
/**
* Take care of application auto startup. Reading and writing the registry.
@ -31,6 +33,19 @@ public class WindowsStartup
private static String REGISTRY_STARTUP_KEY =
"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
/**
* Process Status API. Used to obtain current running executable name.
*/
public interface PSAPI extends StdCallLibrary
{
PSAPI INSTANCE = (PSAPI)Native.loadLibrary("psapi", PSAPI.class);
int GetModuleFileNameExA (
WinNT.HANDLE process,
Pointer hModule,
byte[] lpString,
int nMaxCount);
};
/**
* Checks whether startup is enabled.
* @param appName the application name.
@ -44,6 +59,21 @@ public static boolean isStartupEnabled(String appName)
appName);
}
/**
* Returns the currently running process executable name with path.
* @return the currently running process executable name with path.
*/
public static String getModuleFilename()
{
byte[] exePathName = new byte[512];
WinNT.HANDLE process = Kernel32.INSTANCE.GetCurrentProcess();
int result = PSAPI.INSTANCE.GetModuleFileNameExA(
process, new Pointer(0), exePathName, exePathName.length);
return Native.toString(exePathName).substring(0, result);
}
/**
* Creates or deletes registry key for application autostart.
*
@ -59,11 +89,32 @@ public static void setAutostart(String appName,
{
if(isAutoStart)
{
String executableFileName = null;
String filePath = getModuleFilename();
if(filePath != null && filePath.length() > 0)
{
int ix = filePath.lastIndexOf(File.separatorChar);
if(ix > 0)
executableFileName = filePath.substring(ix + 1);
}
if(executableFileName == null)
{
logger.warn("Missing information for process, " +
"shortcut will be created any way using defaults.");
// if missing we will use application name
// removing spaces,_,-
executableFileName = appName.replaceAll(" ", "")
.replaceAll("_", "").replaceAll("-","") + ".exe";
}
Advapi32Util.registrySetStringValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_STARTUP_KEY,
appName,
workingDirectory + File.separator + "run.exe");
workingDirectory + File.separator + executableFileName);
}
else
{

Loading…
Cancel
Save