NirComLine v1.40
Copyright (c) 2003 - 2004 Nir Sofer

Description

NirComLine is a small command-line utility that allows you to do some useful tasks without displaying any user interface. By running NirComLine with simple command-line option, you can write and delete values and keys in the Registry, write values into INI file, dial to your internet account or connect to a VPN network, restart windows or shut down the computer, create shortcut to a file, change the created/modified date of a file, change your display settings, and more...

System Requirements

This utility can work in all 32-bit Windows operating systems: Windows 9x/ME, Windows NT, Windows 2000, and Windows XP. However, some of NirComLine commands works only on Windows NT/2000/XP.

Versions History

Date Version Description
05/05/20041.40
  • New commands: wait, setvolume, setsysvolume, execmd, exec.
  • New commands for executing NirComLine on remote machines: remote and multiremote.
  • Folder and system variables.
  • New option in setfiletime command - set the file time to the current time (now parameter)
  • New parameter in shortcut command - hot key.
01/03/20041.30
  • New commands: qboxcom, beep, stdbeep, cdrom, urlshortcut, monitor, screensaver, standby, and hibernate.
  • Fixed the bug with ~x string sequences.
08/01/20041.20
  • New commands: setdialuplogon, script
  • Special string sequences (~q, ~t, ~n and so on) to allow you to embed quotes and new line characters into the parameters of any command.
19/11/20031.11 New options in shortcut command
10/10/20031.10 New commands: killprocess, service, memdump, win, lockws.
09/09/20031.00 First release.

License

This utility is released as freeware for personal and non-commercial use. You are allowed to freely distribute this utility via floppy disk, CD-ROM, Internet, or in any other way, as long as you don't charge anything for this. If you distribute this utility, you must include all files in the distribution package, without any modification !

Using NirComLine utility

This utility is a standalone executable, and it doesn't require any installation process or additional DLLs. just copy the executable to any folder you want, and run it with the desired command-line option, according to your needs.

General Syntax Of NirComLine

NirComLine.exe {showerror} [command] [command parameters]
The showerror parameter is optional. If you specify this parameter, an error message will be displayed on the screen if an error is occurred during the execution of the command. Otherwise, any error will be ignored. For example:
NirComLine.exe showerror rasdial "dial1"
NirComLine.exe rasdial "dial1"
In above 2 examples, NirComLine will try to dial with the "dial1" entry. If the dialing process is failed on the first example, an error message describing the problem will be displayed. If the dialing process is failed on the second example, error message won't be displayed.

Special String Sequences

Starting from version 1.20, NirComLine allows you to insert special characters into any parameter in NirComLine commands.
The following table describes the special string Sequences that you can use:
Sequence Description
~n New line characters (CR-LF)
~q Double-quote character: "
~t Tab character
~xnn Allows you to represent any character by providing its ascii code in 2-digit Hexadecimal number.
For Example: ~x41 ('A' character), ~x27 (single-quote character)
~%variable% Represents a system variable. For more information about this option, read below
~~ Represents a single '~' character.

Example:
infobox "This is the first line~n~qThis is a second line, in quotes~q" "Example"
The above example displays a message-box containing 2 lines.

System Variables

Starting from version 1.40, NirComLine provides special variables that represents folders and other variables on your system. Each variable starts with '~' character, followed by the variable name enclosed with '%' characters. For example: ~%folder.desktop% represents your desktop folder.

The following table specifies the variables that you can use:
Variable Name Description
sys.varname You can use this option to represent any environment variable on your system.
For example:
~%sys.username%, ~%sys.windir%, ~%sys.computername%, ~%sys.logonserver%, ~%sys.temp%, and so on...
folder.desktop Represents the user's desktop folder.
folder.start_menu Represents the user's start-menu folder.
folder.programs Represents the user's programs folder (under the start-menu folder).
folder.startup Represents the user's startup folder.
folder.recent Represents the user's recent folder.
folder.favorites Represents the user's favorites folder.
folder.cookies Represents the user's cookies folder.
folder.appdata Represents the user's Application Data folder. (For example: C:\Documents and Settings\Administrator\Application Data)
folder.common_desktop Represents the common desktop folder.
folder.common_start_menu Represents the common start menu folder.
folder.common_programs Represents the common programs folder.
folder.common_startup Represents the common startup folder.
folder.common_favorites Represents the common favorites folder.
folder.windows Represents the windows folder. (e.g.: C:\Windows)
folder.system Represents the system folder. (e.g.: C:\Windows\System32)

Examples:

  • Create a shortcut under the start menu-programs folder:
    shortcut "c:\winnt\system32\calc.exe" "~%folder.programs%\My Programs" "Calculator"
  • Delete a shortcut in the user's desktop:
    execmd del "~%folder.desktop%\calc.lnk"
  • Display the current logged-on user:
    infobox "The current logged-on user is ~%sys.username%" "logged-on user"

Executing NirComLine commands on remote computers

Starting from version 1.40, you can execute all NirComLine commands in remote computers. However, you should be aware of the following restrictions and problems:
  • This option is only available for Windows NT, Windows 2000 and Windows XP. You cannot use it on Windows 9x machines.
  • You must log on to the remote machine as administrator.
  • The Schedule service in the remote machine must be started. (By default, the Schedule service is automatically started in all NT/2000/XP machines, so you don't have to worry too much about this)
  • Due to some limitations of the Schedule service, you have to wait up to 60 seconds until the command is actually executed in the remote machine.
  • The command in the remote machine is executed under 'SYSTEM' account, and thus some commands may not work in the same way as you execute them locally.

There are 2 commands for executing NirComLine in remote machines:

  • remote - for executing command on a single remote computer.
  • multiremote - for executing command on multiple remote computers.

NirComLine Commands

Command Syntax And Description
remote
remote {copy} [\\computer] [NirComLine command]
Executes NirComLine command in a remote computer. if {copy} parameter is specified, NirComLine will copy itself to the Windows directory of the remote machine. You must specify this parameter if NirComLine doesn't exist in the Windows directory of the remote machine.
Examples:

remote copy \\comp1 exitwin poweroff
remote \\comp2 infobox "This is a message from NirComLine" "Hello !"
remote \\comp3 lockws
multiremote
multiremote {copy} [computers file] [NirComLine command]
Executes NirComLine command in multiple remote machines. if {copy} parameter is specified, NirComLine will copy itself to the Windows directory of the remote machines. You must specify this parameter if NirComLine doesn't exist in the Windows directory of the remote machines.
The [computers file] parameter is a file that contains the computers list separated by Enter characters (CRLF).
Example for computers list file:
\\comp1
\\comp2
\\winxp1
\\winxp2
\\nirsoft

The command specified in [NirComLine command] will be executed in all computers specified in the computers file.
Examples:
  • Turn off all computers specified in computers.txt
    multiremote "c:\temp\computers.txt" exitwin poweroff force
  • Lock all computers specified in computers.txt
    multiremote "c:\temp\computers.txt" lockws
  • Copy NirComLine to all computers specified in computers.txt, and then turn off their monitors.
    multiremote copy "c:\temp\computers.txt" monitor off
infobox
infobox [message text] [title]
Displays a simple message box on the screen.
Example:
infobox "This is a message box !" "message"
qbox
qbox [message text] [title] [program to run]
Displays a question dialog-box on the screen. If the user answers "Yes", run a program
Example:
qbox "Do you want to run the calculator ?" "question" "calc.exe"
qboxcom
qboxcom [message text] [title] [NirComLine Command]
Displays a question dialog-box on the screen. If the user answers "Yes", execute the NirComLine command in the third parameter.
Examples:
qboxcom "Do you want to lock your workstation ?" "question" lockws
qboxcom "Do you want to turn off the monitor ?" "monitor" monitor off
script
script [Script File]
This command allows you to execute a sequence of commands stored inside the file specified in [Script File] parameter.
Example:
script "c:\temp\msg.ncl"
Example for a script:
infobox "Hello !" "This is the first message"
infobox "Hello !" "This is the second message"
infobox "Hello !" "This is the third message"
regsetval
regsetval [type] [key] [value name] [value]
Writes a value to the Registry. the [type] parameter can be "sz" or "expand_sz" for strings, "dword" for 32-bit number, or "binary" for binary data. If the key you specify in [key] parameter doesn't exist, it'll automatically be created.
Examples:
regsetval dword "HKEY_CURRENT_USER\Software\Test" "Value1" "0xaabbccdd"
regsetval dword "HKEY_CURRENT_USER\Software\Test" "Value2" "10561"
regsetval sz "HKEY_CURRENT_USER\Software\Test" "Value3" "string value"
regsetval binary "HKEY_CURRENT_USER\Software\Test" "Value4" "6a cb ab dd 80 86 95"
regdelval
regdelval [key] [value]
Deletes a value from the Registry.
Example:
regdelval "HKEY_CURRENT_USER\Software\Test" "Value1"
regdelkey
regdelkey [key]
Deletes entire key from the Registry. This command will failed if the specified key has one or more subkeys.
Example:
regdelkey "HKEY_CURRENT_USER\Software\Test"
inisetval
inisetval [INI filename] [section] [key] [value]
Writes a value into INI file. If the file doesn't exist, it'll automatically be created.
Example:
inisetval "c:\windows\test.ini" "section1" "TestValue" "1"
inidelval
inidelval [INI filename] [section] [key]
Deletes a key-value pair inside INI file.
Example:
inidelval "c:\windows\test.ini" "section1" "TestValue"
inidelsec
inidelval [INI filename] [section]
Deletes entire section in INI file, including all values in it.
Example:
inidelsec "c:\windows\test.ini" "section1"
rasdial
rasdial [Entry Name] {Phonebook File} {User Name} {Password} {Domain}
Dials to RAS entry (VPN or phone line), without displaying any user interface. Except the [Entry Name] parameter, all other parameters are optional. If you don't specify the optional parameters or you specify empty string (""), the default values are used.
Examples:
rasdial "My Internet"
rasdial "VPN1" "" "user1" "abc1234" "domain1"
inetdial
inetdial [Entry Name]
Dials to RAS entry (VPN or phone line), and display informational dialog-box during the dialing process.
This command is only supported If Internet Explorer version 4.0 or greater is installed. Be aware that this command might not work on old versions of Windows 98.
Examples:
inetdial "VPN1"
rasdialdlg
rasdialdlg [Entry Name] {Phonebook File} {Phone Number or IP Address}
Displays a RAS entry for dialing. The {Phonebook File} and {Phone Number} parameters are optional. If you don't specify the {Phonebook File} parameter or you specify an empty string ,the default phonebook is used.
This command is only supported on Windows NT, Windows 2000, and Windows XP. It's not supported on Windows 98/ME.
Examples:
rasdialdlg "Internet1" "" "9876543"
rasdialdlg "VPN1"
rashangup
rashangup [Entry Name]
Hangs up a RAS connection. You can use this command to disconnect a connection that you previously created with inetdial or rasdial commands.
Examples:
rashangup "VPN1"
setdialuplogon
setdialuplogon [Entry Name] [User Name] {Password} {Domain} {Phonebook File}
Modifies the user name, password and domain of a dial-up item.
The parameters:
  • [Entry Name]: The name of the dial-up entry
  • [User Name]: The user-name to set into the specified dial-up entry.
  • {Password}: The password to set into the specified dial-up entry.
  • {Domain}: The domain name to set into the specified dial-up entry.
  • {Phonebook File}: The phonebook file containing the entry you want to change. If you don't specify this parameter, the default phonebook is used.
Examples:
setdialuplogon "VPN1" "user1" "asder443" "domain1"
setdialuplogon "Internet1" "nirs3" "q5r4df7yh5"
exitwin
exitwin [shutdown type] {additional option}
This command terminates the current session of Windows. The [shutdown type] parameter can be one of the following values:
  • logoff: Shut down all running processes, log off the current user, and display the log on dialog to allow another user to log into the system.
  • reboot: Shut down the entire system, and then reboot.
  • poweroff: Shut down the entire system, and then turn off the power. (Only for systems that support this feature !)
  • shutdown: Simply shut down the entire system, without reboot and without turning the power off.
You can also use one of the following additional options:
  • force: Forces all applications to terminate immediately. Using this option can caused the current running application to lose data. Use it only in extreme cases !
  • forceifhung: Forces applications to terminate if they are not responding. This option is only available in Windows 2000/XP.

Examples:
exitwin reboot
exitwin poweroff force
exitwin logoff forceifhung
initshutdown
initshutdown {message} {timeout value in seconds} {force} {reboot}
Initiate a system shutdown. This command is somewhat similar to exitwin command, but it has some other features that exitwin doesn't support. This command is not supported on Windows 95/98/ME. All parameters of this command are optional. If you don't specify any parameter, the system shutdown is initiated without displaying message and without waiting.
The parameters:
  • {message}: The message to display before starting the system shut down.
  • {timeout value in seconds}: The number of seconds to wait before starting the system shut down.
  • {force}: Forces all applications to terminate, even without saving your work.
  • {reboot}: Reboot after the system shutdown.

Examples:
initshutdown "shutting down the system within 60 seconds" 60 reboot
initshutdown "" 0 force
abortshutdown
abortshutdown
Abort the system shutdown that initiated with initshutdown command. This command doesn't accept any additional parameters.
Example:
abortshutdown
lockws
lockws
Lock the workstation. After locking your workstation, you must type your password in order to continue your work. This command is only available on Windows 2000 and Windows XP.
monitor
monitor [action]
Changes the state of the display monitor. The [action] parameter may contain the following values:
  • off: Turn off the monitor
  • on: Turn on the monitor
  • low: Set the monitor to low power state.

This command only works in systems that support this feature.
Examples:
monitor off
monitor on
screensaver
screensaver
Starts the default screen saver.
standby
standby {force}
Shuts down the computer and puts it in 'standby' mode. If the {force} parameter is specified, the system is forced to go into standby mode without asking for permission from all applications. Generally, it's not recommended to use this parameter.
This command works only in systems that supports standby mode.
Example:

standby force
standby
hibernate
hibernate {force}
Shuts down the computer and puts it in 'hibernate' mode. If the {force} parameter is specified, the system is forced to go into hibernate mode without asking for permission from all applications. Generally, it's not recommended to use this parameter.
This command works only in systems that supports hibernate mode.
Example:

hibernate force
hibernate
shortcut
shortcut [filename] [folder] [shortcut title] {arguments} {icon file} {icon resource number} {ShowCmd} {Start In Folder} {Hot Key}
Creates a shortcut to a file.
The parameters:
  • [filename]: Create a shortcut to this filename.
  • [folder]: Specify the destination folder that inside it the shortcut will be created. You can specify any valid folder (like "c:\temp\1234") or one of the following special folder values:
    • /desktop - Creates the shortcut in the user desktop folder.
    • /startup - Creates the shortcut in the user startup folder.
    • /programs - Creates the shortcut in the user start menu\programs folder.
    • /start_menu - Creates the shortcut in the user start menu folder
    • /common_desktop - Creates the shortcut in the desktop folder of all users.
    • /common_startup - Creates the shortcut in the startup folder of all users.
    • /common_programs - Creates the shortcut in the start menu\programs folder of all users.
    • /common_start_menu - Creates the shortcut in the start menu folder of all users
  • [shortcut title]: The text displayed in the shortcut.
  • {arguments}: Optional parameter - Additional arguments to execute the filename.
  • {icon file}: Optional parameter - Use this parameter if your want that the shortcut will be displayed with icon other than the default one.
  • {icon resource number}: Optional parameter - The resource number inside the icon file.
  • {ShowCmd}: Optional parameter - Use this parameter if you want to maximize or minimize the window of the program. Specify "max" to maximize the window or "min" to minimize it.
  • {Start In Folder}: Optional parameter - Specifies the "Start In" folder. If you don't specify this parameter, the "Start In" folder is automatically filled with the folder of the program you specify in [filename] parameter.
  • {Hot Key}: Optional parameter - Specifies an hot-key that will activate the shortcut. For example: Alt+Ctrl+A, Alt+Shift+F8, Alt+Ctrl+Shift+Y

Examples:
shortcut "f:\winnt\system32\calc.exe" /desktop "Windows Calculator"
shortcut "f:\Program Files\KaZaA\Kazaa.exe" "c:\temp\MyShortcuts" "Kazaa"
shortcut "f:\Program Files" "c:\temp\MyShortcuts" "Program Files Folder" "" "f:\winnt\system32\shell32.dll" 45
shortcut "f:\Program Files" "c:\temp\MyShortcuts" "Program Files Folder" "" "" "" "max"
urlshortcut
urlshortcut [URL] [Folder] [Shortcut Title]
Creates a shortcut to URL address. (Like the shortcuts in Favorities of Internet Explorer) The [Folder] parameter specifies the destination folder that inside it the shortcut will be created. If you want to create the shortcut inside your default Favorities folder, use ~%folder.favorites% variable.
Examples:
urlshortcut "http://nirsoft.mirrorz.com" "~%folder.favorites%" "NirSoft Web Site"
urlshortcut "http://www.google.com" "~%folder.favorites%\Search Engines" "Google"
urlshortcut "http://www.yahoo.com" "c:\temp" "Yahoo"
exec
exec [show/hide] [application + command-line]
Runs an application, and optionally specify one or more command-line parameters for the executed application. The [show/hide] parameter specifies whether the running application will be visible or not. If 'hide' is specified, the running application won't be visible to the user.
Example:
exec show "f:\winnt\system32\calc.exe"
exec hide "c:\temp\wul.exe" /savelangfile
execmd
execmd [command]
Executes a command of Command-Prompt (Console Window) without displaying anything on the screen.
Examples:
execmd del "~%folder.desktop%\calc.lnk"
execmd mkdir f:\temp\desktop1
execmd copy "~%folder.desktop%\*.lnk" f:\temp\desktop
shexec
shexec [operation] [filename]
Opens or Prints a filename according to the definition of the file extension in the Registry. For example: a filename with .doc extension will be opened with MS-Word, a filename with .html extension will be opened with your default browser. If you specify a valid web site address, the Web site will be opened in your default browser. the [operation] parameter can be "open" or "print".
Examples:
shexec "open" "c:\my documents\abc.doc"
shexec "print" "d:\files\1.pdf"
shexec "open" "http://nirsoft.mirrorz.com"
setfiletime
setfiletime [filename or wildcard] [Created Date] {Modified Date} {Accessed Date}
Changes the Created/Modified/Accessed of one or more files. The first parameter can be a single filename or wildcard string. The dates parameters must be specified in the following format: "dd-mm-yyyy hh:nn:ss" if a date parameter is not specified or you specify an empty string (""), the date won't be changed. If you specify "now" as date parameter, the current date and time will be used
Example:
setfiletime "c:\temp\*.exe" "15-05-2004 11:22:12" "22-01-2005 21:22:55"
setfiletime "c:\temp\myfile.txt" "24-06-2003 17:57:11" "" "22-11-2005 10:21:56"
setfiletime "c:\temp\myfile.txt" now now
setdisplay
setdisplay [width] [height] [color bits] {-updatereg} {-allusers}
Changes your display settings. The [width] and [height] parameters represents the number of pixels on your screen. The [color bits] parameter represents the number of colors shown on your screen (8 - 256 color, 16 - 16bit color, 24 - 24bit color, and so on). If you specify the {-updatereg} parameter, the new settings will be saved in the Registry. If you specify both {-updatereg} and {-allusers} parameters, the new settings will be saved in the Registry for all users.
Example:
setdisplay 800 600 24 -updatereg
setdisplay 1024 768 8
killprocess
killprocess [process]
Terminates the specified process. In the [process] parameter, you can specify the full path of the process filename (e.g: 'C:\Program Files\Internet Explorer\iexplore.exe') or the name of the process only, without the path (e.g.: iexplore.exe). You can also specify the Process ID, by adding the '/' character as a prefix (e.g. /1120).
Examples:
killprocess iexplore.exe
killprocess "c:\winnt\system32\calc.exe"
killprocess /1830
memdump
memdump [process] [dump file] [bytes per line] {bytes to read} {start address} {nohex} {noascii}
Reads the memory of process according to the parameters you specify, and writes it into a text file.
The parameters:
  • [process]: The process that you want to dump its memory. You can specify the full path of the process filename, the process name only, or the Process ID - by adding the '/' chararcter as prefix (e.g.: /520)
  • [dump file]: The filename to save the memory content of the specified process.
  • [bytes per line]: Number of memory bytes per line in the saved dump file.
  • {bytes to read}: Number of bytes to read.
  • {start address}: Start the dumping process from this memory address.
  • {nohex}: Optional. If you specify this parameter, the memory data won't be saved in Hexadecimal format.
  • {noascii}: Optional. If you specify this parameter, the memory data won't be saved in Ascii format.

Examples:
memdump iexplore.exe "c:\temp\dump.txt" "16" "0x10000" "0x400000"
memdump calc.exe "c:\temp\calc.txt" "32" "0x30000" "0x400000" nohex
memdump /525 "c:\temp\dump.txt" "16" "0x100000" "0x120000" noascii
service
service {\\Computer} [action] [service name]
Changes the status and the startup type of services and drivers.
The parameters:
  • {\\Computer}: Optional. Specifies the name of the remote computer. If you omit this parameter, the local computer is used.
  • [action]: The action you want to do. This parameter may contain one of the following values:
    • start: Starts the specified service or driver.
    • stop: Stops the specified service or driver.
    • pause: Pauses the specified service or driver.
    • continue: Continues the specified service or driver.
    • restart: Stops and then starts again the specified service or driver.
    • auto: Changes the startup type of the specified service or driver to Automatic.
    • manual: Changes the startup type of the specified service or driver to Manual.
    • disabled: Changes the startup type of the specified service or driver to Disabled.
    • boot: (Only for drivers) Changes the startup type of the specified driver to 'Boot'.
    • system: (Only for drivers) Changes the startup type of the specified driver to 'System'.
  • [service name]: The name of the service or driver.

Examples:
service start schedule
service \\remote stop schedule
service restart w3svc
win
win [action] [find] [window to find]
This command allows you to close, hide, show, maximize, and minimize the specified window.
The parameters:
  • [action]: The action you want to do on the specified window:
    • close: Closes the specified window.
    • hide: Hides the specified window.
    • show: Shows again the specified window. (after hiding it with 'hide' command)
    • max: Maximizes the specified window.
    • min: Minimizes the specified window.
    • normal: Restores the specified window to normal state, after minimizing or maximizing it.
  • [find]: The method to find the window
    • handle: Finds the desired window by specifying the handle of the window in [window to find] parameter.
    • class: Finds the desired window by specifying the class name of the window in [window to find] parameter.
    • title: Finds the desired window by specifying the exact title of the window in [window to find] parameter.
    • stitle: Finds the desired window by specifying the first few characters of the window in [window to find] parameter.
  • [window to find]: Specifies the window by handle, class name, or title, according to the value of the previous parameter.

Examples:
win close title "calculator"
win hide stitle "calculat"
win show class "SciCalc"
win max handle 0x00009c01
cdrom
cdrom [action] {drive:}
This command allows you to open and close the door of your CD-ROM drive. The [action] parameter can be 'open' or 'close'. If you don't specify the {drive:} parameter, the default CD-ROM will be used.
Examples:
cdrom open
cdrom close
cdrom open J:
cdrom close R:
beep
beep [Frequency] [Duration]
Plays a beep. The [Frequency] parameter specifies the frequency, in hertz. The [Duration] parameter specifies the duration of the sound in milliseconds. Under Windows 95/98/ME, the above parameters are ignored, and only a standard Windows beep is played.
Example:
beep 500 2000
stdbeep
stdbeep
Plays the standard beep of Windows.
Example:
stdbeep
setvolume
setvolume [device] [left-volume] [right-volume]
Set the volume level of your sound device. The [device] parameter represents the device identifier. In most cases, you should use '0' value for this parameter. The [left-volume] and [right-volume] parameters should contain a value between 0 (silence) and 65535 (full volume) that represents the volume level for left and right channels.
Examples:
setvolume 0 0 0
setvolume 0 32768 32768
setvolume 0 0xffff 0
setsysvolume
setsysvolume [volume]
Set the sound volume for your system. Changing this value also affects the sound volume settings under 'Control Panel'. The [volume] parameter should contain a value between 0 (silence) and 65535 (full volume).
Examples:
setsysvolume 0x8000
setsysvolume 0
setsysvolume 25000
wait
wait [milliseconds]
Simply wait the specified number of milliseconds.
Examples:
wait 1000
wait 500

Feedback

If you have any problem, suggestion, comment, or you found a bug in my utility, you can send a message to nirsofer@yahoo.com

Download NirComLine (22KB)