Hi, folks.
Today I will present you small and neat technique that will allow us to expand command power of macros without using comparatively heavyweight and 3rd-party-dependent AutoIt scripts (you are forced to store 2 files in extension package as well as to have AutoIt installed to recompile scripts if needed).
It will be great if we could replace all that stuff with universal and compact command line 'framework' isn't it?! :cool:
And what are you thinking? I have investigated such a 'framework'!
Well. No more empty words.
There are 2 beautiful apps out there.
First is
NirCMD: powerful command-line processor able to make numerous useful things for us.
Just look at
its syntax and commands list and sure you'll be impressed with all the possibilities!
It's only drawback is its 'consoleness' it works in CMD-window and you know it isn't good thing in user's eyes. Blinking black window... Brrrrr...
Here the next app goes.
CHP (Create Hidden Process) is a program to silently launch GUI and console apps in a hidden window.
So we can simply cascade both apps in one command - and get WINDOWLESS operations being processed!
The tutorial itself
1. Download
NirCMD, open archive and take only 1 file -
nircmdc.exe. This is console version of utility that is most suitable for operating from kmm
exec statement.
2. Place this file (once again -
nircmdC.exe. Not
nircmd.exe!!!) in
tools subfolder of KM.
3. Download CHP and place in the same folder.
4. When creating macros define 2 variables:
$CHPpath=getfolder(RootFolder)."\\tools\\chp.exe";
$NIRpath=getfolder(RootFolder)."\\tools\\nircmdc.exe";
It worth to make them global as they will be used by a number of future or rewritten macros.
5. Look at this template statement:
exec($CHPpath." ".$NIRpath." closeprocess ultrasurf");
this one silently closes Ultrasurf, for example, in my test macro. (instead of using system
taskkill command that is not universal across different Windows - particularly XP has other command instead)
Just playing with NirCMD commands I've created and tested (all works!) such a commands like:
exec($CHPpath." ".$NIRpath." urlshortcut \"http://www.nirsoft.net\" \"~$folder.desktop$\" \"NirSoft\" ");
(creates URL-shortcut to NirSoft homepage on your desktop)
or
exec($CHPpath." "."powercfg /x -monitor-timeout-ac 0");
(forces monitor never to switch off when AC-powered - changes
current power scheme)
etc.
So you are welcome folks to play with!
This 'framework' is able to do a big work earlier relying on AutoIt: make changes in Registry, run and close (kill) processes, work with windows, emulate keypresses, copy-paste data, create shortcuts, set system wide timers, manage logoffs/shutdowns and much more!
We'll be able to make KM real control center for our PC!
¡Vamos!
Edited 3 time(s). Last edit at 11/14/2017 07:39PM by rodocop.