ZRCola/bin/MkLnk.wsf
Simon Rozman b3702ed237 Extend copyright year
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-02-11 15:38:57 +01:00

86 lines
3.2 KiB
XML

<?xml version="1.0"?>
<!--
Copyright 1991-2015-2020 Amebis
This file is part of MkLink.
MkLink is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MkLink is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MkLink. If not, see <http://www.gnu.org/licenses/>.
-->
<package>
<job id="MkLnk">
<runtime>
<description>Creates shortcut to a program - Amebis, Copyright © 2015</description>
<unnamed name="&lt;Shortcut.lnk&gt;" required="true" helpstring="Shortcut file to create"/>
<unnamed name="&lt;Target&gt;" required="true" helpstring="Target file the shortcut invokes"/>
<named name="A" type="string" required="false" helpstring="Command line arguments"/>
<named name="F" type="string" required="false" helpstring="Start in folder"/>
<named name="S" type="string" required="false" helpstring="Shortcut key (Example: &quot;ALT+CTRL+F&quot;)"/>
<named name="R" type="string" required="false" helpstring="Run (Valid values: 1=Normal Window, 3=Maximized, 7=Minimized)"/>
<named name="C" type="string" required="false" helpstring="Comment"/>
<named name="I" type="string" required="false" helpstring="Icon (Example: &quot;SHELL32.DLL,1&quot;)"/>
<example>
Example:
MkLnk.wsf &quot;%USERPROFILE%\Desktop\My shortcut.lnk&quot; &quot;%windir%\notepad.exe&quot; /R:3 /C:&quot;Starts the Notepad Maximized&quot;
</example>
</runtime>
<script language="JScript"><![CDATA[
if (WScript.Arguments.Unnamed.Length < 2) {
WScript.Arguments.ShowUsage();
WScript.Quit(1);
}
var
wsh = WScript.CreateObject("WScript.Shell");
try {
var link = wsh.CreateShortcut(WScript.Arguments.Unnamed(0));
// Set shortcut's target.
link.TargetPath = WScript.Arguments.Unnamed(1);
if (WScript.Arguments.Named.Exists("A"))
link.Arguments = WScript.Arguments.Named("A");
if (WScript.Arguments.Named.Exists("F"))
link.WorkingDirectory = WScript.Arguments.Named("F");
if (WScript.Arguments.Named.Exists("S"))
link.HotKey = WScript.Arguments.Named("S");
if (WScript.Arguments.Named.Exists("R"))
link.WindowStyle = parseInt(WScript.Arguments.Named("R"), 10);
if (WScript.Arguments.Named.Exists("C"))
link.Description = WScript.Arguments.Named("C");
if (WScript.Arguments.Named.Exists("I"))
link.IconLocation = WScript.Arguments.Named("I");
link.Save();
} catch (err) {
// Clean-up!
try {
// Delete LNK file.
var fso = WScript.CreateObject("Scripting.FileSystemObject");
fso.DeleteFile(WScript.Arguments.Unnamed(0), true);
} catch (err2) {}
throw err;
}
WScript.Quit(0);
]]></script>
</job>
</package>