This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to make an msysGit shortcut
You can use the script /share/msysGit/add-shortcut.tcl to create an msysGit shortcut. The following arguments are handled: q QuickLaunch (default) d Desktop s StartMenu (TopLevel) s2 StartMenu (Programs>msysGit>msysGit) a All Users' StartMenu (TopLevel) a2 All Users' StartMenu (Programs>msysGit>msysGit) (This reinstates the program create-shortcut in /share/msysGit which was removed from /share/WinGit in favor of the InnoSetup based installer.) Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
- Loading branch information
Showing
4 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.o | ||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
create-shortcut.exe: create-shortcut.o | ||
$(CC) $(CFLAGS) -o $@ $< -luuid -lole32 | ||
strip $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/mingw/bin/tclsh | ||
|
||
switch -regexp [lindex $argv 0] { | ||
"^(|help|-h|-help|--help)$" { | ||
puts "Usage: $argv0 \[option\]" | ||
puts "Options:" | ||
puts "" | ||
puts " QuickLaunch create a QuickLaunch icon" | ||
puts " Desktop create an icon on the Desktop" | ||
puts " StartMenu create an icon in your start menu" | ||
puts " StartMenu2 create an icon in start menu's Programs>msysGit" | ||
puts " AllUsersStartMenu create an icon in All Users' start menu" | ||
puts " AllUsersStartMenu2 create an icon in All Users'" | ||
puts " start menu's Programs>msysGit" | ||
puts "" | ||
puts "Short options are q, d, s, s2, a and a2." | ||
exit 1 | ||
} | ||
"^(quicklaunch|QuickLaunch|q)$" { | ||
set targetDirectory \ | ||
"$env(APPDATA)/Microsoft/Internet Explorer/Quick Launch" | ||
} | ||
"^(Desktop|desktop|d)$" { | ||
set targetDirectory "$env(USERPROFILE)/Desktop" | ||
} | ||
"^(StartMenu|startmenu|start|s)$" { | ||
package require registry 1.0 | ||
set key "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows" | ||
set key "$key\\CurrentVersion\\Explorer\\Shell Folders" | ||
set targetDirectory [registry get $key "Start Menu"] | ||
} | ||
"^(StartMenu2|startmenu2|start2|s2)$" { | ||
set startMenuName "msysGit" | ||
package require registry 1.0 | ||
set key "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows" | ||
set key "$key\\CurrentVersion\\Explorer\\Shell Folders" | ||
set programs [registry get $key "Programs"] | ||
file mkdir $programs/$startMenuName | ||
set targetDirectory $programs/$startMenuName | ||
} | ||
"^(AllUsersStartMenu|allusersstartmenu|allusers|a)$" { | ||
package require registry 1.0 | ||
set key "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows" | ||
set key "$key\\CurrentVersion\\Explorer\\Shell Folders" | ||
set targetDirectory [registry get $key "Common Start Menu"] | ||
} | ||
"^(AllUsersStartMenu2|allusersstartmenu2|allusers2|a2)$" { | ||
set startMenuName "msysGit" | ||
package require registry 1.0 | ||
set key "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows" | ||
set key "$key\\CurrentVersion\\Explorer\\Shell Folders" | ||
set programs [registry get $key "Common Programs"] | ||
file mkdir $programs/$startMenuName | ||
set targetDirectory $programs/$startMenuName | ||
} | ||
default { | ||
puts "Unknown argument: [lindex $argv 0]" | ||
exit 1 | ||
} | ||
} | ||
|
||
cd [file dirname $argv0] | ||
|
||
regsub "^(.*)/etc/inputrc" $env(INPUTRC) "\\1" msysRoot | ||
exec make | ||
|
||
set binDirectory "$msysRoot/bin" | ||
set resDirectory "$msysRoot/share/resources" | ||
|
||
exec ./create-shortcut.exe --work-dir "$binDirectory" \ | ||
--icon-file "$resDirectory/msysgitlogo.ico" \ | ||
--arguments "--login -i" \ | ||
"$binDirectory/sh.exe" \ | ||
"$targetDirectory/msysGit.lnk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#include <stdio.h> | ||
#include <shlobj.h> | ||
|
||
void die(const char *message) | ||
{ | ||
CoUninitialize(); | ||
fprintf(stderr, "%s\n", message); | ||
fprintf(stderr, "last error: %d\n", GetLastError()); | ||
exit(1); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
const char *progname = argv[0]; | ||
const char *work_dir = NULL, *arguments = NULL, *icon_file = NULL; | ||
const char *description = NULL; | ||
int show_cmd = 1; | ||
|
||
static WCHAR wsz[1024]; | ||
HRESULT hres; | ||
IShellLink* psl; | ||
IPersistFile* ppf; | ||
|
||
|
||
while (argc > 2) { | ||
if (argv[1][0] != '-') | ||
break; | ||
if (!strcmp(argv[1], "--work-dir")) | ||
work_dir = argv[2]; | ||
else if (!strcmp(argv[1], "--arguments")) | ||
arguments = argv[2]; | ||
else if (!strcmp(argv[1], "--show-cmd")) | ||
show_cmd = atoi(argv[2]); | ||
else if (!strcmp(argv[1], "--icon-file")) | ||
icon_file = argv[2]; | ||
else if (!strcmp(argv[1], "--description")) | ||
description = argv[2]; | ||
else { | ||
fprintf(stderr, "Unknown option: %s\n", argv[1]); | ||
return 1; | ||
} | ||
|
||
argc -= 2; | ||
argv += 2; | ||
} | ||
|
||
if (argc > 1 && !strcmp(argv[1], "--")) { | ||
argc--; | ||
argv++; | ||
} | ||
|
||
if (argc < 3) { | ||
fprintf(stderr, "Usage: %s [options] <source> <destination>\n", | ||
progname); | ||
return 1; | ||
} | ||
|
||
hres = CoInitialize(NULL); | ||
if (FAILED(hres)) | ||
die ("Could not initialize OLE"); | ||
|
||
hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, | ||
&IID_IShellLink, (void **)&psl); | ||
|
||
if (FAILED(hres)) | ||
die ("Could not get ShellLink interface"); | ||
|
||
hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, | ||
(void **) &ppf); | ||
|
||
if (FAILED(hres)) | ||
die ("Could not get PersistFile interface"); | ||
|
||
hres = psl->lpVtbl->SetPath(psl, argv[1]); | ||
if (FAILED(hres)) | ||
die ("Could not set path"); | ||
|
||
if (work_dir) | ||
psl->lpVtbl->SetWorkingDirectory(psl, work_dir); | ||
|
||
if (show_cmd) | ||
psl->lpVtbl->SetShowCmd(psl, show_cmd); | ||
|
||
if (icon_file) | ||
psl->lpVtbl->SetIconLocation(psl, icon_file, 0); | ||
if (arguments) | ||
psl->lpVtbl->SetArguments(psl, arguments); | ||
if (description) | ||
psl->lpVtbl->SetDescription(psl, description); | ||
|
||
wsz[0] = 0; | ||
MultiByteToWideChar(CP_ACP, | ||
0, argv[2], -1, wsz, 1024); | ||
hres = ppf->lpVtbl->Save(ppf, | ||
(const WCHAR*)wsz, TRUE); | ||
|
||
ppf->lpVtbl->Release(ppf); | ||
psl->lpVtbl->Release(psl); | ||
|
||
if (FAILED(hres)) | ||
die ("Could not save link"); | ||
|
||
CoUninitialize(); | ||
return 0; | ||
} |