﻿kIT Portable Launcher
=========================
Utility allows you to organize the simplest form of portability to non-portable programs.
Utility runs the program (and any executable files) and makes certain actions before run and/or after exit this program:
• import reg-file before running;
• remove existing registry keys before importing;
• backup of existing keys in the reg-file before deleting;
• memorization of existing keys and restore them after program exited;
• save the registry keys after program exited but before restoring.
In addition:
• full support for environment variables and relative paths;
• UNICODE support for import/export reg-files;
• fast start-up, tiny size, low resource consumption.
The program does not produces any access control, so it will be able to make a specific key in the registry only if it is enough rights for the current user.
For example, in the bush can make changes to HKEY_CURRENT_USER, even a normal user.
=========================
kitrun.exe [/f] [/p|/P] [/w|/W] [/d|/D] [/u|/U] [/r|/R]
           [/b|/B (:|<file>)] [/s|/S (:|<file>)] [/k <reg-key>]
           <reg-file> <command-line>
=========================
Required parameters:
<reg-file> — name of the existing reg-file (extension does not matter) to be imported into the registry.
<command-line> — command line for run the program, possibly with parameters, so should be the last element of the string.
=========================
Optional parameters:
/f — force import reg-file.
==========
/p — resolve the relative paths from the kitrun.exe folder.
 /P — resolve the relative paths from the runs program directory (if it's given absolutely, otherwise /P is ignored).
 by default — from the kitrun.exe working directory.
==========
/w — (workdir) set working directory of running program to the folder of kitrun.exe.
  /W — set working directory of running program to the folder of this program (if it's is given absolutely, otherwise /W is ignored).
  by default - to working directory of kitrun.exe.
==========
/d — delete from the registry of existing keys that will be made.
 /D — like /d, but delete entirely the most high-level of the keys.
==========
/u — (unregister) wait until the program exited, and remove the keys from the registry made ​​(without removing previously existed keys).
 /U — like /u, but remove entirely the most high-level of the keys.
==========
/r — (restore) remember the original state of keys, and import them back into the registry after the program exited.
 /R — like /r, but memorized entirely the most high-level of the keys.
==========
/b <file> — (backup) before importing the reg-file save the current contents of the keys in the specified file (extension does not matter) in the syntax of reg-files. If the file name specified by a colon, then takes the name of the main reg-file.
 /B — like /b, but exported entirely the most high-level of the keys.
==========
/s <file> — (save) after the program exited save the current contents of the keys in the specified file (extension does not matter) in the syntax of reg-files. If the file name specified by a colon, then takes the name of the main reg-file.
 /S — like /s, but saved entirely the most high-level of the keys
==========
/k <reg-key> — (key) check this key to the decision to import. The presence of the first key from the reg-file has no effect.
==========
The options can be combined into words. However, a parameter that has subparameter, must be the last set of letters.
=========================
Examples of use:
==========
kitrun path\config.reg path\prog.exe param1 param2
- If the first key of config.reg already present, config.reg not be imported, and immediately start a program with specified parameters.
==========
kitrun /f /U path\config.reg path\prog.exe
- Config.reg imported in any case, after the completion of the program, removed from the roster of the most high-level keys, referred to in config.reg, together with all connected (not even imported from config.reg).
==========
kitrun /f /u path\config.reg path\prog.exe
- Similar to the previous version, but removed only the keys that are imported from config.reg.
==========
kitrun /u path\config.reg path\prog.exe
- On the pristine system config.reg imported, and upon completion of the program the keys away. But if you run the program will create new keys in this branch, then subsequent launches of these parameters will not lead to the import config.reg, since high-level keys will remain in the registry.
==========
kitrun /fp /DUR /S : putty.reg path\putty.exe
- Assuming, that is next to kitrun.exe putty.reg, then run this line provides a kind of sandbox, though clean. PuTTY is started with the settings taken from putty.reg, and after completion of the corresponding branch will be returned in original condition. Most of the letter S preserves even the new keys generated during the operation.
=========================
Working logic:
1) If /f specified, then go to (2), otherwise,
  1.1) If /k specified, check for the specified key in the registry, otherwise
   1.1.1) If /k is omitted, read the first key from the specified reg-file and check its availability in the registry.
 2) If /r (or /R) specified,
     placed in memory of the current contents of insertion of keys (or all of the most high-insertion of keys, if /R).
 3) If /b (or /B) specified,
     keep to the specified file the current contents of insertion of keys (or all of the most high-insertion of keys, if /B).
 4) If /d (or /D) specified,
     remove the keys that will be made (or all the most high-level of these keys, if /D).
 5) If the key selected in step (1) is absent,
     import reg-file specified in the registry.
 6) Execute the specified command line.
 7) If there wasn't specified any key from the /b, /B, /s, /S, /u, /U, /r /R,
     then go to (11)
     otherwise wait until the program exited.
 8) If /s or /S specified,
     keep to the specified file the current contents of insertion of keys (or all of the most high-insertion of keys, if /S).
 9) If /u (or /U) specified,
     remove from the registry keys made (or all of the most high-insertion of keys, if /U).
10) If /r (or /R) specified,
     import memorized the keys to their contents back into the registry.
11) Quit.
=========================
Explanations and special situations:
- Parameter /r (or /R) by itself does not cause the program to remove the existing keys, but only to import the saved. So if you want as accurately as possible to restore the state registry, which was to run the program, you must additionally specify the key /U, which will remove all the affected branches before recovering the stored keys.
- If the primary reg-file and the file parameter /b (or /B) given the same file, then saving it in the current values ​​of the place after reading it for import. That is, old and new values ​​will be swapped. The next time you start with the same parameters in the registry and the file will get its original value. This can be used as a kind of switch.
- Parameter /s (or /S), apparently also triggered after reading reg-file to import, and if there using the same reg-file, and that as the core, it is possible from run to run amend and supplement the reg-file associated with the program. In combination with the / r, you can create a kind of portable profile (sandbox), not depending on the settings of the current user and does not affect them.
- It is important to understand that the basic behavior of the program remains unchanged. If the registry key (the first in the reg-file, or specified through the /k) HAS IN the registry (and /f isn't given), all settings such as /b, /u will be ignored.
- Options /b (or /B) and /r (or /R) mutually independent, although it operate exactly the same data. Permissible to ask them both.
=========================
Limits:
— Binary data values ​​are exported without line breaks (with a "\" character at the end of each line). This does not violate the standard, reg-file is correct.
=========================
History:
1.0 (2011-08-18)
Implemented basic functionality.
Implemented /f.
Implemented /k.
1.2 (2011-08-22)
Implemented /u.
Added /U.
Working directory of the running program is set equal to the current working directory kitrun.exe.
Fixed bug with parameters processing.
Prohibited feedback-effect of the cursor kitrun.exe.
1.3 (2011-08-26)
Message "Wrong usage!" supplemented by the opening in the background readme.txt.
1.4 (2011-08-27)
Fixed a bug due to which /u is satisfied even if the keys have not been imported (as already in the registry and /f is specified)
Added /p and /P.
In all lines, potentially containing the path are replaced by environment variables. I.e. in all but the argument of the parameter /k, including the running program parameters.
1.6 (2011-08-28)
Implemented /b, /B.
Implemented /s, /S.
1.7 (2011-08-29)
Implemented /r, /R.
Implemented /d, /D.
1.8 (2011-08-30)
Implemented UNICODE support: storage in memory, exports, imports.
Remove the restriction on the size of the key name. Now, the maximum size, as spelled out in a standard 16 383 UNICODE-character.
1.9 (2011-09-11)
Removed the appearance of the window "Wrong usage!" in the absence of reg-file, or exe-file. Appears only when an error in the parameters.
The opportunity to combine multiple parameters with one slash.
Options /b, /B, /s, /S supplemented with the possibility of ukzat ":" for the file name. This one takes the name of the primary reg-file.
Fixed transfer program arguments: not recovered quotes in arguments with spaces.
1.9.1 (2011-09-13)
Fix: there was unable to run programs that require elevation (UAC).
Added options /w, /W
Added reg-file validation check.
Added information about the version of the file.
1.9.2 (2011-09-15)
Fixed: Missing exported default (@="").
Fixed: A couple of potential memory leaks.
1.9.3 (2011-09-30)
Fixed: Options /p and /P doesn't worked (after "The opportunity to combine multiple parameters with one slash." In 1.9.0).
Fixed: If a program is absent but reg-file exists, the parameters associated with the process finish waiting, worked for half.
Fixed: Incorrectly rejected reg-files encoded in ANSI (after "Added reg-file validation check." In 1.9.1).
=========================
Contacts:
ApceH Hypocrite: apcehypo@gmail.com
=========================
PS. Sorry my English. Please help me to translate it correctly.