RCMD

RCMD Version 1.61

This software is provided "as is" without warranty of any kind. The author disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall the author be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.

The RCMD (Remote Command) command line tool enables you to execute commands like dir, del, copy etc. to be executed on your Pocket PC.

Author

Harald-René Flasch
mailto:hfr@hfrmobile.com
http://www.hfrmobile.com

Commands

  • attrib
  • copy
  • ctest
  • del
  • dir
  • exist
  • md
  • pswedit
  • rd
  • ren
  • sbackup
  • tedit
  • tskedit

Further help topics

  • Options
  • Return values
  • Syntax & Terms
  • Filename Replacement

History

The following table contains all released versions of RCMD and short description for each version:

Version Description
1.61
  • fixed minor bug in sbackup command and adjusted help a bit
  • fixed stupid bug in sbackup command (crashed when file name had more than 99 characters)
  • improved setup a bit
1.6
  • added ctest command
  • added pswedit command
  • added /y option for copy command
  • improved help
  • I recognized that some users are violating my disclaimer (free for personal use). RCMD is not free for commercial use! So I decided to add a license check. If you like to use RCMD you need a license key now. You can obtain a license via donation. Thank you!
1.52
  • added Daylight Workaround for sbackup
1.51
  • added /d parameter for attrib command
  • fixed some minor bugs in tskedit command and improved help
1.5
  • improved copy command so that the "Unsupported protocol" error does not occur
  • added ren command
  • added Filename Replacement
  • improved help
1.33
  • fixed problem with tedit command. Now RCMD remembers the window position of the tedit editor window again
  • maybe fixed problem with "access violation" to memory 0x000000 at program startup
  • improved help
1.32
  • fixed problem if using RCMD as user which is not in an administrators group
1.31
  • installation checks to ensure that RCMD was installed correctly
1.3
  • improved help
  • added exist command
  • added /pause option
  • fixed general problem: if no files where found no error was returned
  • improved copy command
1.2
  • added tskedit command
  • improved setup
  • improved help
1.1
  • improved help (including /help command)
  • added sbackup command
  • improved tedit command (improved RCMD tedit editor: remember size and position, Strg+S shortcut for saving, supporting tab key for editing)
  • improved copy command (also fixed problem with ftp protocol)
  • added md command
  • added rd command
  • added /errorlevel parameter)
  • various internal improvements
1.0
  • first release with a basic set of commands: dir, del, copy, attrib and tedit


Options

This topic describes the RCMD options. An option must go first. The general syntax is:
RCMD [option(s)] [<command> [command option(s)]]

Here is a list of all options:

Option | Description
/?, /h | Displays help.
/??, /hh | Displays samples.
/help [command] | Opens the RCMD help for the specfied command. If no command was specified the help index will be opened.
/disclaimer | Displays the RCMD disclaimer.
/nologo | Suppresses displaying program information. "Connect to device..." and "OK" information will be displayed.
/nologo2 | Works like /nologo2 but also suppresses connecting information.
/errorlevel | Displays the "DOS" return value. See also return values.
/pause | Pauses after executing all options and commands. This option works like the DOS pause command but in RCMD it is just an option.


Return values

After executing a command RCMD returns a value to his caller. This return value can be used in batch files (e.g. *.cmd or *.bat). You can use the %errorlevel% environment variable in order to retrieve the return value. For example if you call "rcmd" without parameters the return value will be 2. If you call "rcmd /nologo2" the return value will be 0.

Since Version 1.1 you can use the /errorlevel parameter in order to display the RCMD return value.

Here is a complete list of all possible return values:

Value | Description
0 | RCMD successfully executed (and parameters where specified)
1 | Internal error. Maybe missing the DLL mfc42.dll
2 | No parameter was specified. This is just a 'warning'
3 | There was no active connection. Connect your Pocket PC before using rcmd. You may connect your Pocket PC via Microsoft ActiveSync or WMDC (Windows Mobile Device Center). This return value may only occur since version 1.6 of RCMD! There exists an undocumented registry key to set a time-out. The default value indicates that never a time-out will occur. See FAQ 10 at hfrmobile.com!
4 | You have specified an invalid command and/or parameter.
5 | Corrupt installation of RCMD.
6-7 | Not used in this version of RCMD. Reserved for future use.
8 | Used by the exist command.
9 | There was an error while using the /help parameter. Make sure that RCMD was installed correctly and the help file exists.
10 | There was an error while executing the dir command.
11 | There was an error while executing the del command.
12 | There was an error while executing the copy command.
13 | There was an error while executing the attrib command.
14 | There was an error while executing the tedit (text edit) command. An error occures if the file could not be found or if not enaugh memory was available to save the file.
15 | There was an error while executing the sbackup command.
16 | There was an error while executing the md (make directory) command.
17 | There was an error while executing the rd (remove directory) command.
18 | There was an error while executing the tskedit (task edit) command.
19 | There was an error while executing the ren (rename) command.
20 | There was an error while executing the pswedit (PocketWord edit) command. Available since Version 1.6!


Syntax & Terms

This topic describes the general syntax of RCMD and some important words and symbols which are used in this help.

Note
  • There must be an active ActiveSync connection in order make RCMD working
  • All commands and their parameters are case sensitive
  • If no directory is specified the root directory "\" is assumed
  • If you provide a path as a parameter the path name has to end with "\" (e.g. \temp\*.*). If you use \temp this will mean the file "temp" in the root directory "\". See also dir command!
  • If there are spaces in a path you have to use quotation marks. CAUTION: If the path ends with \" you have to use two backslashes (e.g. "\Dir With Spaces\\")
  • Some commands are for use with Windows CE only! A command like rcmd dir c:\*.* will cause always the following error: Invalid protocol: Win32

Term | Description
PDA | Personal Digital Assistant. For example a Pocket PC is a PDA.
filespec | File specification. A directory name with wildcards (e.g. \Temp\*.txt means "all text files in the \temp directory"). If a directory or filename contains spaces you have to enclose the filepsec with quotes.
src | src stands for "source" (e.g. a source directory, file, or a "filespec")
dst | dst stands for "destination" (e.g. a source directory or a destination file)
[ ] | Square brackets means that something is optional (e.g. dir [filespec] means that for the dir command the filespec is optional)
< > | These kind of brackets means that something is mandatory and needed for a successful execution (e.g. del <filespec> means that the filespec is mandatory for the del command)
| | This symbol means "or". (e.g. <alpha | beta> means that you have to use alpha or beta)


Filename Replacement

Some RCMD commands support the new feature which is called "Filename Replacement". This means that some special placeholders can be used for filenames. At the moment only the ren command supports this new feature which is available since Version 1.5!

Place holder | Description
{TICKCOUNT} | Milliseconds since the desktop system was started. The value is unique.
{DD}, {D} | Day.
{MM}, {M} | Month.
{YYYY}, {YY} | Year.
{hh}, {h} | Hour.
{mm}, {m} | Minute.
{ss}, {s} | Second.
{n}, {n:?} | Current number. The number start with 1 each time RCMD is started. The '?' stands for the width of the generated numbers. For example {n:3} will cause: 001, 002, 003 and so forth. You can use 2 to 8 for '?'.
{N}, {N:?} | Current number. Works like {n} or {n:?} but the numbers start with 0.


RCMD attrib

attrib

The attrib command is similar to the attrib command in a normal command prompt window. The RCMD version of this command also displays if a file is encrypted with the CCrryyppttoo application or not.

Syntax: attrib [filespec] [parameter]

Paramter | Description
none | If you specify no parameter all files and their attributes from the root directory "\" are displayed.
/ic | Ignores the CCrryyppttoo integration. Use this parameter if you need not to know if a file is encrypted or not. Using this parameter will increase performance.
/d Processes folders as well.
This may not work for PPC2002 devices but should work for WM2003 and WM2005 devices.
I have tested the following:
  • LOOX 600 with PPC2002: NOT worked
  • SP3i Smartphone with WM2003: OK
+a | Adds the archive bit to the files specified by the filespec
-a | Removes the archive bit from the files specified by the filespec
+r | Adds the read-only bit to the files specified by the filespec
-r | Removes the read-only bit from the files specified by the filespec. Maybe you use this parameter before using the del if you have to delete read-only files.
+s | Adds the system bit to the files specified by the filespec.
-s | Removes the system bit from the files specified by the filespec. Make sure that you know what you are doing!
+h | Adds the hidden bit to the files specified by the filespec. This makes the files invisible to the most file explorers. If you use the Voyager file explorer you have to disable the "Show hidden files" option in order to make these files invisible to Voyager!
-h | Removes the hidden bit from the files specified by the filespec. This makes the files visible to file explorers.


RCMD copy

copy

The copy command is similar to the copy command in a normal command prompt window but supports more file protocols. Supported protocols are Win32, WinCE, http and ftp.

Syntax: copy <src> <dst> [parameter]

Paramter | Description
/i | Displays additional information. This information contains the source and destination file name which is currently copied.
/dp | Displays the progress of copying file the current file. The progress of copying is displayed with dots where one dot equals to 8 KB of copied data.
/y | Available since v1.6! Overwrite existing destination file(s).
/sfa | Synchronize file attributes from source and destination file. The destination file gets the file attributes from the source file. This parameter can only be used if the source and destination file using the Win32 or WinCE protocol. This parameter will not work for ftp or http!
/sft | Synchronize file times. This parameter has the same behavior like the /sfa parameter.
/usr:<name> | Specifies an user name for ftp file download. If no name is specified anonymous will be assumed.
/pss:<pass> | Specifies a password for ftp file download. Since the password is provided with the parameter the password would be displayed!
/PSS | Specifies a password for ftp file download. The password must be typed in before the file could be downloaded. The password will not be displayed!

If no protocol for <src> was specified, Win32 and the current directory on the desktop machine will be used as source. See second sample below.

The copy command does not support UNC paths. You may use the following workaround for your commands:

net use t: \\server\share
rem your copy commands here
net use t: /delete

The copy command supports the following scenarios:

Source | Direction | Destination
Win32 | <==> | WinCE
Win32 | <==> #1 | Win32
WinCE | <==> | WinCE
http | ==> | WinCE
http | ==> #1 | Win32
ftp | ==> | WinCE
ftp | ==> #1 | Win32

#1 For these scenarios there is no logical reason that there has to be an active connection to the Windows CE device. But there has to be an active connection because all RCMD commands expect that there is an active connection! If you like to execute the copy command without a connection you should visit the FAQ page at www.hfrmobile.com to get information about an undocummented feature of RCMD.

The copy command in combination with ftp does not support the following URL formats:
  • ftp://servername:port/somedir
  • ftp://username@somedir.server.ext

Samples:
  • rcmd copy "C:\Some Dir\eNews\*.htm" \eNews\ /i
  • rcmd copy sample.htm \eNews\ /dp
  • rcmd copy "C:\Some Dir\*.*" "\Some Dir\\" /dp /sfa /sft
  • rcmd /errorlevel copy \SD−MMCard\Sample\test.doc c:\temp\test.doc
  • rcmd copy ftp://abc.def.at/sample.jpg \temp\sampledownload.jpg /i /usr:bob /PSS


RCMD ctest

ctest

The ctest command checks if there is a device connected to the desktop machine. If there is a problem (e.g. no time-out configured) this command will not return. You can specify a time-out (in secods) using the Registry only! For more information see FAQ 10 at hfrmobile.com!

This command is available since Version 1.6!


RCMD del

del

The del command is similar to the del command in a normal command prompt window. If you provide no filespec (rcmd del) the del command does nothing and returns with an error.

Syntax: del <filespec> [parameter]

Paramter | Description
none | Deletes specified files. Read-only files could not be deleted. You may use the attrib command with -r before.
/p | Prompts for each file before deleting them. So the user has the possibility to skip files which should not be deleted.


RCMD dir

dir

The dir command is similar to the dir command in a normal command prompt window. The RCMD version of the dir command supports some parameters which are described in the table below. The dir command can be used to list the contents of a directory located on a PDA.

Syntax: dir [filespec] [parameter]

Paramter | Description
none | If you provide no parameter (rcmd dir) the dir command displays all files and directories from the root folder of the connected PDA.
/b | Displays all files and directories using a simple format (no date/time, file size etc.)

RCMD beginners often suffer this mistake: rcmd dir \temp

The following table will show you what this means and how to make it correctly:

filespec | Description
\Temp | Will display the file or directory "temp" which is located in the root directory "\" of the PDA.
\Temp\ | Does display "no" files in the \Temp directory because there are no wildcards after the second "\"! This format may be used as a destination directory for the copy command.
\Temp\*.* | This is the correct way and will display all files and folders in the directory "temp" which is located in the root directory "\" of the PDA


RCMD exist

exist

The exist command can be used to determine if a file or set of files exists or not. If an error occurs (e.g. wrong parameter specified) or if no specified files exist the command returns 8. If one or more files exist the return value will be 0.

In order to see the return value use the /errorlevel parameter!

Syntax: exist <filespec> [parameter]

Paramter | Description
/i | Displays the number of found files. If no files are found the return value of the exist command will be 8 otherwise 0.


RCMD md

md

The md command can be used to create a directory on a PDA. You have to provide the whole path for the directory to create.

Syntax: md <dir>

This command does not have any parameters.

Sample:
md \temp\test1
This sample creates the directory test1 in the \temp\ directory. The \temp\ must exist and the test1 directory must not exist otherwise an error will be returned.


RCMD pswedit

pswedit

The pswedit command can be used to edit a Pocket Word file remotely. You should have Microsoft Word installed or another application which can handle ".psw" files if you like to use this command. The remote file must exist. This command is available since Version 1.6!

Syntax: pswedit <name> [parameter]

Paramter | Description
/notasksave | If this parameter was specified RCMD does not ask to save the file. In this case the file is always stored even you do not choose 'Save' in Microsoft Word.
/askdelete | If you use this parameter RCMD asks you if you like to delete the local temporary file which is used to edit the file. If this parameter is not used the temporary file is always deleted after closing Microsoft Word.

What doing if losing the ActiveSync connection?
If losing the ActiveSync connection while using pswedit you can save your changes using the following steps:
  • Save the file to a different location (=Backup) and copy the entire content of the Word file to the clipboard
  • Close Microsoft Word
  • Delete the temporary file pswedit.psw which is located in the TEMP folder
  • Establish an ActiveSync connection and execute the commnad again
  • Paste the contents back to Microsoft Word
  • If successfully delete the backup file


RCMD rd

rd

The rd command can be used to remove a directory from a PDA. The directory must be empty otherwise an error will be returned. You have to provide the whole path for the directory to delete.

Syntax: rd <dir>

This command does not have any parameters.

Sample:
rd \temp\test1
This sample deletes the directory test1 from the \temp\ directory. The \temp\ and the test1 directories must exist and the test1 directory must be empty otherwise an error will be returned.


RCMD ren

ren

The ren command can be used to rename a file or a set of files. For the source file(s) you have to provide a full qualified path but for the destination file(s) you can omit the path if you like.

This command supports "Filename Replacement" for the destination filenames.

The ren command can also be used to move files to another directory. If you like to move files with this command just provide another destination path for <dst>.

Syntax: ren <src> <dst> [parameter]

Paramter | Description
/i | Displays source and destination file name.

Samples:
  • rcmd ren \temp\test.txt newname.txt /i
  • rcmd ren \temp\*.txt {TICKCOUNT}.txt /i
  • rcmd ren \temp\something.log {YYYY}−{MM}−{DD}.log /i
  • rcmd ren \temp\1736426.txt \temp\abc.txt /i
  • rcmd ren \temp\abc.txt \temp\dir1\movedfile.txt /i
  • rcmd ren \temp\*.txt {n:4}.txt /i


RCMD sbackup

sbackup

The sbackup (simple backup) command can be used to backup files located on a PDA to a desktop PC. This command does the same like the CECOPY application which will be discontinued in the future. You should prefer RCMD sbackup instead of CECOPY.

Note:
  • Destination directory must exist
  • Root directory "\" is not supported
  • No subdirectories will be archived

Syntax: sbackup <</id:file> </chk:text> | </id:file> </src:dir> </dst:dir>> [option(s)]

Paramter | Description
/id:<file> | sbackup uses so called "ID files" in order to distinguish between various memory cards. Put a text file (e.g. sbackup.id) into the root directory of each of your memory cards. This text file should contain only one line which is the id for the memory card. If the ID file could not be found RCMD sbackup returns with an error.
/chk:<text> | Determines if the text specified with this parameter is equal to the ID in the ID file. If they are not equal RCMD sbackup returns with an error.
/src:<dir> | The source directory on the PDA.
/dst:<dir> | The destination directory on the desktop PC. You can use the place holder $(ID) in the directory name which is replaced with content of the ID file.
/s | Uses a simple format for output.

The backup mechanism works as follows: All files from the source directory are copied to the destination directory if the source file is newer than the destination file. If source and destination file are equal (file time) the file is not copied. In case that the source file is older an error is displayed. If the destination file does not exist a new file will be created. After the copy operation the file times of source and destination file are synchronized.

CAUTION:
If you have enabled the setting 'Automatic adjust clock for daylight saving changes' and this setting will take effect (winter time --> summer time) you will have to delete all files at the desktop PC side and execute sbackup again because the destination files will be one hour newer than the source files even they have not changed! In the other case (summer time --> winter time) all destination files will be one hour older so all files will be archived again.
Info: sbackup does not check the archive bit of files because some Windows CE applications (e.g. Pocket Excel) do not handle the archive bit correctly.

Since Version 1.52 there is a workaround for the daylight issue! Use RCMD_sbackup_DaylightWorkaround_ON.reg to enable the workaround and RCMD_sbackup_DaylightWorkaround_OFF.reg to disable the workaround after backup!

Sample:
The following sample assumes that you have installed Version 1.1 in the default directory. The sample first checks if the correct SD (Secure Digital) memory card is inserted into the PDA. If not an error is displayed an nothing will be archived. Otherwise starts archiving some directories and their files. This sample also assumes that the all destination directories exists. You may use this sample as a template for your backup scenarios and save it in a file called mybackupSD1.cmd.

Info: If you have installed RCMD in its default directory and if you are using a text editor like Notepad which usually open and save files in ANSI format ensure that you provide the correct application path ("Ren," or "René") because command scripts (.cmd or .bat) have to be saved in OEM format! Since version 1.2 you have the possibility to let the Setup add the RCMD application path to the environment. This makes the line set PATH=... in the following script unnecessary!

@echo off

::
:: Set environment variables (DSTROOT which will be the root directory for all backup
:: directories and enhance the PATH variable with the path of the RCMD installation directory).
::
 set DSTROOT=C:\BACKUP\SDCard1
set PATH=%PATH%;C:\Program Files\hfrmobile.com\Remote Command 1.6

::
:: check if inserted memory card has the id SDCard1
::
 rcmd /nologo2 sbackup "/id:\SD-MMCard\cecopy.id" "/chk:SDCard1" /s

::
:: If id is not correct do nothing.
::
 if "%errorlevel%" == "0" goto start
goto wrongcard

::
:: Id was correct so we can start the backup...
::
 :start
echo Start sbackup...

rcmd /nologo2 sbackup "/src:\SD-MMCard\MyDataA" "/dst:%DSTROOT%\MyDataA" /s
rcmd /nologo2 sbackup "/src:\SD-MMCard\MyDataB" "/dst:%DSTROOT%\MyDataB" /s
rcmd /nologo2 sbackup "/src:\SD-MMCard\MyDataN" "/dst:%DSTROOT%\MyDataN" /s

goto end

::
:: Id was not correct so we cannot backup. An appropriate
:: error message will be displayed by RCMD.
::
 :wrongcard
echo.
goto end

:end
pause


RCMD tedit

tedit

The tedit (text edit) command can be used to open a text file on a PDA. Using this command you have to specify exactly one file to open (not a filespec).

The file will be opened in a simple text editor called RCMD tedit. This command is useful if you often have to edit a text file (e.g. todo list) which is located on your PDA. Maybe you write a batch file in order to open this file with just one (double) click!

Syntax: tedit <file> [parameter]

Paramter Description
/Fn This parameter can be used to specify a font which should be used in the RCMD tedit text editor.
"n" is the font code. Following values are possible:
  • 0 = non monospace system font (like Arial)
  • 1 = monospace system font (like Courier New). This is the default font for RCMD tedit!
  • 2 = non monospace system font (bold)
  • 3 = monospace system font (bold)

Hotkey | Description
Strg+S, Alt+S | Save file (only if the file has been changed since the last save action)
Alt+C | Close RCMD tedit. If the file has not been saved a message box will be displayed which asks the user to discard the changes or to cancel closing RCMD tedit

Sample:
rcmd tedit "\My Documents\ToDoList.txt" /F3
This sample opens the ToDoList.txt file in the \My Documents folder using a bold monospace system font.

CAUTION:
If the connection was lost and the file not saved you will get an error message (Cannot set file pointer!) if you try to save the file even you connect the device again.

Nevertheless it is possible to save your work with a little trick: Connect your device again. After that click the right mouse button in the text area of the tedit text editor in order to popup a context menu. Then use the menu item 'Select all' in order to select the entire text. After the whole text is selected use the 'Copy' command from the context menu to temporary store the text on the clipboard. Then close the file without saving (saving is not possible!). Now you have to open your (old) file again and use the menu item 'Select all'. After that use the menu item 'Paste' which copies the text from the clipboard to the tedit text editor. Now save your work! Be careful if you have to do this procedure!

I highly recommend to save your opened file from time to time during it is opened across an ActiveSync connection!


RCMD tskedit

tskedit

The tskedit command can be used to edit Pocket Outlook tasks without having Microsoft Outlook installed and without having an ActiveSync partnership (so using guest mode). The name is the exact name of the task item which you like to edit. If the name contains spaces you need to use quotation marks. Using the tskedit command you can use formatting like bold italic underline and of course colors!

You should have Microsoft Word installed or another application which can handle ".pwi" files.

If Microsoft Outlook is installed on the desktop system it may take some seconds until the changes appear in the task list of Microsoft Outlook.

If the task item has no body text the tskedit command will not work! In this case you have to add some text to the body field (e.g. using Pocket Outlook).

Syntax: tskedit <name> [parameter]

Paramter | Description
/notasksave | If this parameter was specified RCMD does not ask to save the file to Pocket Outlook. In this case the task is always stored even you do not choose 'Save' in Microsoft Word.
/askdelete | If you use this parameter RCMD asks you if you like to delete the local temporary file which is used to edit the task. If this parameter is not used the temporary file is always deleted after closing Microsoft Word.

The products mentioned above (Outlook, Word etc.) are products from MicrosoftTM. The tskedit command was tested with Microsoft Word 2000 and Microsoft Word XP.

Using default font
It is recommended to set the default font using Microsoft Word. This font will be used if you edit the task using Pocket Outlook.

What doing if losing the ActiveSync connection
If losing the ActiveSync connection while editing a task using tskedit you can save your changes using the following steps: Copy the entire Text to the clipboard and reconnect your device and open the task again. Select the entire text and use "paste" to restore your changes.


RCMD Author

Author

This is a "hidden" page about the author (me ;-)) of Remote Command (RCMD). You may click on the image on the author page of my homepage... ;-)

Picture of the author

Name: | Harald-René Flasch
Contact: | hfr@hfrmobile.com
Homepage: | http://www.hfrmobile.com