mirror of https://gitlab.com/basile.b/dexed.git
setup program - windows use a vbs to generate a shortcut
instead of the 💩.url
This commit is contained in:
parent
d9e5d9a017
commit
c5571f0708
cesetup
|
@ -53,5 +53,5 @@ object CurrentProject: TCENativeProject
|
||||||
Sources.Strings = (
|
Sources.Strings = (
|
||||||
'cesetup.d'
|
'cesetup.d'
|
||||||
)
|
)
|
||||||
ConfigurationIndex = 2
|
ConfigurationIndex = 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -255,12 +255,17 @@ bool uninstallResource(Resource resource, string path)
|
||||||
{
|
{
|
||||||
const string fname = extractedName(resource, path);
|
const string fname = extractedName(resource, path);
|
||||||
if (!fname.exists) return true;
|
if (!fname.exists) return true;
|
||||||
try remove(fname);
|
tryRemove(fname);
|
||||||
catch (FileException e) return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nuxPostInstall()
|
void tryRemove(string fname)
|
||||||
|
{
|
||||||
|
try remove(fname);
|
||||||
|
catch (FileException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
version(linux) void nuxPostInstall()
|
||||||
{
|
{
|
||||||
File f = new File(shortCutPath ~ "coedit.desktop", FileMode.OutNew);
|
File f = new File(shortCutPath ~ "coedit.desktop", FileMode.OutNew);
|
||||||
f.writeLine("[Desktop Entry]");
|
f.writeLine("[Desktop Entry]");
|
||||||
|
@ -273,30 +278,42 @@ void nuxPostInstall()
|
||||||
f.close;
|
f.close;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nuxPostUninstall()
|
version(linux) void nuxPostUninstall()
|
||||||
{
|
{
|
||||||
try remove(shortCutPath ~ "coedit.desktop");
|
tryRemove(shortCutPath ~ "coedit.desktop");
|
||||||
catch (FileException e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void win32PostInstall()
|
version (win32) void win32PostInstall()
|
||||||
{
|
{
|
||||||
// note: this is not a true shortcut, other options are
|
import std.conv: to;
|
||||||
// - create a true lnk by generating and executing a vbs
|
import std.random: uniform;
|
||||||
// - use winapi...
|
|
||||||
|
// shortcut prior to v 1 upd 2 was actually and url.
|
||||||
|
tryRemove(shortCutPath ~ "Coedit.url");
|
||||||
|
|
||||||
string target = exePath ~ "coedit.exe";
|
string target = exePath ~ "coedit.exe";
|
||||||
File f = new File(shortCutPath ~ "Coedit.url", FileMode.OutNew);
|
string vbsName;
|
||||||
f.writeLine("[InternetShortcut]");
|
do vbsName = environment.get("TEMP") ~ r"\cesh" ~ uniform(0,int.max).to!string ~ ".vbs";
|
||||||
f.writeString("URL=");
|
while (vbsName.exists);
|
||||||
f.writeLine("\"" ~ target ~ "\"");
|
|
||||||
f.writeString("IconFile=");
|
string vbsCode = "
|
||||||
f.writeLine("\"" ~ target ~ "\"");
|
set WshShell = CreateObject(\"WScript.shell\")
|
||||||
f.writeLine("IconIndex=0");
|
strDesktop = WshShell.SpecialFolders(\"Desktop\")
|
||||||
f.close;
|
set lnk = WshShell.CreateShortcut(strDesktop + \"\\Coedit.lnk\")
|
||||||
|
lnk.TargetPath = \"%s\"
|
||||||
|
lnk.Save
|
||||||
|
";
|
||||||
|
File vbs = new File(vbsName, FileMode.OutNew);
|
||||||
|
vbs.writefln(vbsCode, target);
|
||||||
|
vbs.close;
|
||||||
|
executeShell(vbsName);
|
||||||
|
|
||||||
|
tryRemove(vbsName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void win32PostUninstall()
|
version (win32) void win32PostUninstall()
|
||||||
{
|
{
|
||||||
try remove(shortCutPath ~ "Coedit.url");
|
// shortcut prior to v 1 upd 2 was actually and url.
|
||||||
catch (FileException e) {}
|
tryRemove(shortCutPath ~ "Coedit.url");
|
||||||
|
tryRemove(shortCutPath ~ "Coedit.lnk");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue