Console applications and batch files are regularly run at Windows startup and in schedule. The main inconvenience of this is that every application creates a new console window which flickers on the screen. Hidden Start (or Hstart) is a small startup manager that
allows console applications to be started without any windows in the background and much more. Hstart is usually started by entering the following command line:
hstart /NOCONSOLE "batch_file_1.bat" "batch_file_2.bat" "batch_file_3.bat"
Hstart is very effective if you are using console utilities for everyday tasks: daily backups, automatic source code compilation and code signing. Please
read the examples section below to see how it works out.
Hstart is very small (~40 Kb), but it allows you to:
- start multiple applications in the specified order synchronously;
- start console applications without any windows in the background;
- start non-elevated applications from elevated scripts and batch files (new in v3.0);
- handle UAC privilege elevation under Windows Vista and above;
- set the working directory and priority class of the created processes;
- set the startup delay before command execution;
- show success and error messages after command execution.
Using Hstart, it is also possible to run batch files in the background and save console output into a log file:
hstart /NOCONSOLE /IDLE /D="E:\Backups\"
"cmd.exe /c "E:\Backups\backup.bat > backup-log.txt""
It is very effective if you are using console utilities for daily backups. The command line switch /IDLE means that the backup process will run with the lowest priority class, and /D="" sets the starting directory of the batch file (necessary if it uses relative paths).
What is new in the latest versions?
Hstart 3.0 contains a number of innovative features that make it easier to work with complex command lines and handle UAC privilege elevation on Windows Vista and above. Please read this carefully before using the newest version of Hstart.
User-friendly quote processing
Starting from version 2.0, Hstart uses its own algorithm to parse complex command line arguments. It enumerates all the opening/closing quotation marks and handles embedded quotes in a more user-friendly manner. Double-quoting is the way that you have to escape a single embedded quotation mark.
Important note for existing users
If you are moving from Hstart v1.x to the newest version, you have to recheck and possibly rewrite all your Hstart command lines. The following command line switches may help you to move quickly:
- /TEST - enable the "test mode" to see what parameters are passed to Hstart and how they are processed;
- /NQ - use the old algorithm to parse command line arguments, provided by CommandLineToArgvW function (for backward compatibility only, it is highly NOT recommended for new scripts).
Here is how it works out:
hstart /TEST "cmd.exe /k "echo "a phrase" "" with spaces "" eof""
Compare with the old algorithm:
hstart /NQ /TEST "cmd.exe /k \"echo \"a phrase\" \" with spaces \" eof\""
This will execute cmd.exe with the following parameters:
cmd.exe /k "echo "a phrase" " with spaces " eof"
And you will see: "a phrase" " with spaces " eof
Test mode
The /TEST command line switch allows you to see what parameters are passed to Hstart and how they are processed:
hstart /TEST "notepad "C:\Windows\System32\drivers\etc\hosts""
You will be prompted with an information message before executing any commands:
It is highly recommended to check all command lines with the /TEST switch before using Hstart in a real-world environment.
Message after command execution
Hstart allows you to run console applications completely hidden, and now there is a simple way to tell the user whether the command is executed correctly or not:
hstart /WAIT /MSG="Your command executed successfully."
/TITLE="Congratulations!!!" "Success.exe -parameters"
This will bring up the following message after command execution:
Here is how to set up an error message:
hstart /WAIT /ERRMSG="An error occurred while processing your request."
/ERRTITLE="Unknown Error" "Failure.exe -parameters"
The error message will be displayed only if the executed command failed:
Note that the /WAIT switch is required to determine the return code of the executed command. For a real-life example, please see
Example 3: Code Signing with one click.
Run applications from the Windows Shell
Essentially, the new /SHELL command line switch works in the same way as the Windows Run dialog: the given parameters are passed to the Windows Shell to be handled rather than by calling the application directly. This makes it possible for the Shell to select an appropriate program to run for a given filename.
The /SHELL command line switch is also required when running elevated and UIAccess applications under Windows Vista and 7.
UAC privilege elevation under Windows Vista
Especially for Windows Vista users, Hstart 3.0 provides two new command line switches: /RUNAS and /UAC. The first switch is equal to the "Run as administrator" Shell command:
hstart /RUNAS "notepad.exe" "cmd.exe" "inputdoc.exe"
After running this command line, you will see three UAC confirmation dialogs: first for Notepad, second for Command Prompt and third for an unsigned application (inputdoc.exe). Here is the third UAC dialog:
Compare with the following command line:
hstart /UAC "notepad.exe" "cmd.exe" "inputdoc.exe"
In this case, you will see only one UAC confirmation dialog asking you to run Hstart executable with administrative privileges:
Hstart executable is
digitally signed, so it can be used to launch other unsigned applications at Windows startup without being blocked by UAC.
It is also possible to run a batch file with full administrative privileges (for example, to be able to write to %ProgramFiles% or system directories) in hidden mode:
hstart /RUNAS /NOCONSOLE "D:\Batch Files\Requires_Admin_Privileges.bat"
The /NOCONSOLE and /NOWINDOW command line switches work also for PowerShell and Ruby scripts as well as for CMD windows.
Start non-elevated applications from elevated (new in v3.0)
On Windows Vista, programs started from an elevated application or script would also run in elevated mode with full administrative rights. Hstart 3.0 gives an easy and native way to start a non-elevated program from the command line or a batch file, even if the command line process is elevated.
hstart /NONELEVATED "D:\Batch Files\Non_Elevated_Script.bat"
Installers that always run with full administrative rights on Vista computers can benefit from using Hstart with the /NONELEVATED switch and run other programs or scripts with the rights of the currently logged on user.
Note that /WAIT and /[PRIORITY] flags are ignored if you specify the /NONELEVATED command line switch. Though you can still use the /NOCONSOLE switch to run application in hidden mode and pass multiple command lines to Hstart.
Examples of Usage
Here are a few real-world examples of using Hstart:
Hidden Start 3.2 (32-bit and 64-bit),
powered by ntwind.com
undefined: undefined »