Исходник простого инсталлятора на JavaScript (WSH)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
objArgs=WScript.Arguments;
var where = new String();
var WshShell = WScript.CreateObject("WScript.Shell");
if(objArgs.length<1){
where = WshShell.SpecialFolders("Programs");
} else {
where = objArgs(0);
}
var fso, f1;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (!fso.FolderExists(where)) fso.CreateFolder(where);
if (!fso.FileExists(where+"\\Lab9.exe")) {
f1 = fso.GetFile(WshShell.CurrentDirectory+"\\Lab9.exe");
f1.Move(where+"\\Lab9.exe");
}
if (!fso.FileExists(where+"\\Uninstaller.js")) {
f1 = fso.GetFile(WshShell.CurrentDirectory+"\\Uninstaller.js");
f1.Move(where+"\\Uninstaller.js");
}
WshShell.RegWrite("HKCU\\Software","Lab9");
WshShell.RegWrite("HKCU\\Software\\Lab9\\Path", where, "REG_SZ");