Skip to content
Mark Chandler edited this page May 13, 2014 · 1 revision

Install scripts allow items to do advanced things once the item has been installed.

There are currently 4 functions that can be called:

 - PreInstall
 - PostInstall
 - PreUninstall
 - PostUninstall

There is also another function that gets called to add tools:

 - ToolSetup

and as the name suggests, pre gets called before, post after and one for installing the item and one for uninstalling the item

Api For install hooks:

fs.IsValidFile(file)
fs.IsValidFolder(folder)
fs.CopyFile(src, dest)
fs.GetFileSize(file)
fs.DeleteFile(file)
fs.DeleteFolder(path)
fs.SetFolderPermissions(folder) //sets it so non admins can read/write

os.win.SetRegistryKey(key, value)
os.win.GetRegistryKey(key)
os.win.DelRegistryKey(key)

os.win.SetFirewallAllow(exePath, displayName)
os.win.DelFirewallAllow(exePath)

os.win.SetCompatiblityMode(exePath, os, flags)

os can be one of:
	os.win.compmode.IGNORE
	os.win.compmode.OS_WIN95
	os.win.compmode.OS_WIN98
	os.win.compmode.OS_NT4SP5
	os.win.compmode.OS_WIN2000

flags can be bitwised:
	os.win.compmode.IGNORE
	os.win.compmode.FLAG_256COLOR
	os.win.compmode.FLAG_640X480
	os.win.compmode.FLAG_DISABLE_THEMES
	os.win.compmode.FLAG_DISABLE_DWM
	os.win.compmode.FLAG_RUN_AS_ADMIN
	os.win.compmode.FLAG_HIGH_DPI_AWARE

Set os and flags to os.win.compmode.IGNORE to remove settings

item.GetPath(key)

key can be one of:
	item.path.MY_DOCUMENTS
	item.path.USER_APP_DATA

item.GetSpecialWildcardPath(wildcard)

Wildcard can be one of:
	PROGRAM_FILES
	DOCUMENTS
	JAVA_PATH
	APP_DATA

item.GetInstallPath()

Api for tool setup:

item.AddTool(name, exePath, args, return)
item.GetInstallPath()

Example Script:

a_reg = {
	main: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Bohemia Interactive Studio\\ARMA 2\\MAIN",
	data: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Bohemia Interactive Studio\\ARMA 2\\Data",
	path: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Bohemia Interactive Studio\\ARMA 2 OA\\Expansions\\ARMA 2\\PATH",
	moddir: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Bohemia Interactive Studio\\ARMA 2 OA\\Expansions\\ARMA 2\\MODDIR",
	loadafter: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Bohemia Interactive Studio\\ARMA 2 OA\\Expansions\\ARMA 2\\LOADAFTER",
	loadbefore: "HKEY_LOCAL_MACHINE\\SOFTWARE\\Bohemia Interactive Studio\\ARMA 2 OA\\Expansions\\ARMA 2\\LOADBEFORE"
};

PostInstall = function(){
	os.win.SetRegistryKey(a_reg.main, item.GetInstallPath());
	os.win.SetRegistryKey(a_reg.data, item.GetInstallPath());
	os.win.SetRegistryKey(a_reg.path, "SOFTWARE\\Bohemia Interactive Studio\\ARMA 2");
	os.win.SetRegistryKey(a_reg.moddir, 'CA');
	os.win.SetRegistryKey(a_reg.loadafter, 'ARMA 2 OA');
	os.win.SetRegistryKey(a_reg.loadbefore, '');
};

PostUninstall = function(){
	os.win.DelRegistryKey(a_reg.main);
	os.win.DelRegistryKey(a_reg.data);
	os.win.DelRegistryKey(a_reg.path);
	os.win.DelRegistryKey(a_reg.moddir);
	os.win.DelRegistryKey(a_reg.loadafter);
	os.win.DelRegistryKey(a_reg.loadbefore);
};

ToolSetup = function(){
	item.AddTool("Activation", item.getInstallPath() + "setup.exe", "", "");
};