1 // git-gui Windows shortcut support
2 // Copyright (C) 2007 Shawn Pearce
4 var WshShell = WScript.CreateObject("WScript.Shell");
5 var argv = WScript.Arguments;
6 var argi = 0;
7 var lnk_path = argv.item(argi++);
8 var ico_path = argi < argv.length ? argv.item(argi++) : undefined;
9 var dir_path = argi < argv.length ? argv.item(argi++) : undefined;
10 var lnk_exec = argi < argv.length ? argv.item(argi++) : undefined;
11 var lnk_args = '';
12 while (argi < argv.length) {
13 var s = argv.item(argi++);
14 if (lnk_args != '')
15 lnk_args += ' ';
16 if (s.indexOf(' ') >= 0) {
17 lnk_args += '"';
18 lnk_args += s;
19 lnk_args += '"';
20 } else {
21 lnk_args += s;
22 }
23 }
25 var lnk = WshShell.CreateShortcut(lnk_path);
26 if (argv.length == 1) {
27 WScript.echo(lnk.TargetPath);
28 } else {
29 lnk.TargetPath = lnk_exec;
30 lnk.Arguments = lnk_args;
31 lnk.IconLocation = ico_path + ", 0";
32 lnk.WorkingDirectory = dir_path;
33 lnk.Save();
34 }