2004-08-16 17:41:11 +01:00
|
|
|
// =================================================================
|
|
|
|
// Logtalk - Object oriented extension to Prolog
|
2005-02-21 02:40:52 +00:00
|
|
|
// Release 2.23.0
|
2004-08-16 17:41:11 +01:00
|
|
|
//
|
2005-01-13 12:22:42 +00:00
|
|
|
// Copyright (c) 1998-2005 Paulo Moura. All Rights Reserved.
|
2004-08-16 17:41:11 +01:00
|
|
|
// =================================================================
|
|
|
|
|
|
|
|
if (WScript.Arguments.Unnamed.Length > 0) {
|
|
|
|
usage_help();
|
|
|
|
WScript.Quit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
WScript.Echo('');
|
|
|
|
WScript.Echo('Creating a shortcut named "Logtalk - SWI-Prolog" for running Logtalk');
|
|
|
|
WScript.Echo('with SWI-Prolog...');
|
|
|
|
WScript.Echo('');
|
|
|
|
|
|
|
|
var WshShell = new ActiveXObject("WScript.Shell");
|
|
|
|
|
|
|
|
var prolog_path = WshShell.RegRead("HKLM\\Software\\SWI\\Prolog\\home") + "\\bin\\plwin.exe";
|
|
|
|
|
|
|
|
var FSObject = new ActiveXObject("Scripting.FileSystemObject");
|
|
|
|
|
|
|
|
if (!FSObject.FileExists(prolog_path)) {
|
|
|
|
WScript.Echo("Error! Cannot find plwin.exe at the expected place!");
|
|
|
|
WScript.Quit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
var WshSystemEnv = WshShell.Environment("SYSTEM");
|
|
|
|
var WshUserEnv = WshShell.Environment("USER");
|
|
|
|
var logtalk_home;
|
|
|
|
|
2004-12-05 21:52:49 +00:00
|
|
|
if (WshSystemEnv.Item("LOGTALKHOME"))
|
2004-08-16 17:41:11 +01:00
|
|
|
logtalk_home = WshSystemEnv.Item("LOGTALKHOME");
|
|
|
|
else if (WshUserEnv.Item("LOGTALKHOME"))
|
|
|
|
logtalk_home = WshUserEnv.Item("LOGTALKHOME")
|
|
|
|
else {
|
|
|
|
WScript.Echo("Error! The environment variable LOGTALKHOME must be defined first!");
|
|
|
|
usage_help();
|
|
|
|
WScript.Quit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
logtalk_home = logtalk_home.replace(/\\/g, "\\\\");
|
|
|
|
|
|
|
|
if (!FSObject.FolderExists(logtalk_home + "\\bin"))
|
|
|
|
FSObject.CreateFolder(logtalk_home + "\\bin");
|
|
|
|
|
2004-11-29 20:36:31 +00:00
|
|
|
var f = FSObject.CreateTextFile(logtalk_home + "\\bin\\logtalk_swi.pl", true);
|
2004-08-16 17:41:11 +01:00
|
|
|
f.WriteLine(":- system_module.");
|
|
|
|
f.Close();
|
|
|
|
|
2004-11-29 20:36:31 +00:00
|
|
|
WshShell.Run("cmd /c type " + logtalk_home + "\\compiler\\logtalk.pl" + " >> " + logtalk_home + "\\bin\\logtalk_swi.pl", true);
|
2004-08-16 17:41:11 +01:00
|
|
|
|
2004-11-29 20:36:31 +00:00
|
|
|
f = FSObject.CreateTextFile(logtalk_home + "\\bin\\logtalk_swi.rc", true);
|
2004-08-16 17:41:11 +01:00
|
|
|
|
2004-11-29 20:36:31 +00:00
|
|
|
f.WriteLine(":- consult('$LOGTALKUSER/configs/swihook.pl').");
|
|
|
|
f.WriteLine(":- consult('$LOGTALKUSER/configs/swi.config').");
|
|
|
|
f.WriteLine(":- consult('$LOGTALKHOME/bin/logtalk_swi.pl').");
|
|
|
|
f.WriteLine(":- consult('$LOGTALKUSER/libpaths/libpaths.pl').");
|
2004-08-16 17:41:11 +01:00
|
|
|
f.Close();
|
|
|
|
|
|
|
|
var ProgramsPath = WshShell.SpecialFolders("AllUsersPrograms");
|
2004-09-15 00:11:12 +01:00
|
|
|
|
|
|
|
if (!FSObject.FolderExists(ProgramsPath + "\\Logtalk"))
|
|
|
|
FSObject.CreateFolder(ProgramsPath + "\\Logtalk");
|
|
|
|
|
|
|
|
var link = WshShell.CreateShortcut(ProgramsPath + "\\Logtalk\\Logtalk - SWI-Prolog.lnk");
|
2004-11-29 20:36:31 +00:00
|
|
|
link.Arguments = "-f %LOGTALKHOME%\\bin\\logtalk_swi.rc";
|
2004-08-16 17:41:11 +01:00
|
|
|
link.Description = "Runs Logtalk with SWI-Prolog";
|
|
|
|
link.IconLocation = "app.exe,1";
|
|
|
|
link.TargetPath = prolog_path;
|
|
|
|
link.WindowStyle = 1;
|
|
|
|
link.WorkingDirectory = logtalk_home;
|
|
|
|
link.Save();
|
|
|
|
|
|
|
|
WScript.Echo('Done. The "Logtalk - SWI-Prolog" shortcut was been added to the');
|
2004-11-29 20:36:31 +00:00
|
|
|
WScript.Echo('Start Menu Programs. Make sure that the environment variables');
|
|
|
|
WScript.Echo('LOGTALKHOME and LOGTALKUSER are defined for all users wishing');
|
|
|
|
WScript.Echo('to use the shortcut.');
|
|
|
|
WScript.Echo('');
|
2004-08-16 17:41:11 +01:00
|
|
|
|
|
|
|
WScript.Quit(0);
|
|
|
|
|
|
|
|
function usage_help() {
|
|
|
|
WScript.Echo('');
|
|
|
|
WScript.Echo('This script creates a shortcut named "Logtalk - SWI-Prolog" for');
|
|
|
|
WScript.Echo('running Logtalk with SWI-Prolog. The script must be run by a user');
|
|
|
|
WScript.Echo('with administrative rights. The LOGTALKHOME environment variable');
|
|
|
|
WScript.Echo('must be defined before running this script.');
|
|
|
|
WScript.Echo('');
|
|
|
|
WScript.Echo('Usage:');
|
|
|
|
WScript.Echo(' ' + WScript.ScriptName + ' help');
|
|
|
|
WScript.Echo(' ' + WScript.ScriptName);
|
|
|
|
WScript.Echo('');
|
|
|
|
}
|