Monday, August 14, 2006
Scripting and Automation: Creating .bat files for the Windows Mobile Device
A Batch File simply contains a list of commands that need to be run repeatedly. The commands in a batch file could be to copy files, delete files, move files, modify the registry, query the registry, launch applications, etc. A Batch File can contain complex logic such as looping, conditional statements, and use command-line parameters. Batch Files can also be assigned to shortcuts and placed on the Windows desktop so that they can easily be executed.
The Srego CE ToolPack Command-Line utilities mimic many of the desktop commands provided by the Command Prompt, so using the Srego CE ToolPack in your scripts is very easy; just use the ToolPack version of the command you would normally use on the desktop.
Friday, August 04, 2006
The ceDir Utility
The ceDir utility is run on a desktop computer to display a file list from a connected device. The ceDir utility is similar to the Command Prompt’s Dir command except the file list is for the device instead of the desktop computer. Many of the options found in the Dir command are found in ceDir.
Usage:
ceDir [path][filename] [/?] [/MY] [/B] [/-C] [/O] [/T] [/A]
[path][filename] Specifies directory and/or files to list.
[/?] Display usage.
[/MY] Display My Documents directory.
[/B] Minimum Infomation.
[/-C] Do not display the thousand separator.
[/O][-][sortorder] Sort files:
N = by Name (alphabetical)
E = by Extension (alphabetical)
G = group directories first
S = by Size (smallest first)
D = by date/time (oldest first)
- = Prefix will reverse order
[/T][timefield] Specifies Time Field to use:
C = Creation (default)
A = Last Access
W = Last Written
[/A][-][attribute]
D = Directorires
H = Hidden files
S = System files
R = Read-Only files
A = Archive files
[/S] Display all subdirectories
Examples
The default (no parameters) will display the contents of the current directory on the connected device. By default, the current directory is \My Documents, but can be changed with the ceCD command. One or more directories can be specified as parameters. If a directory (like \my documents) includes spaces, you must enclose the path in quotes (“”). The following three instances all show the contents of the \My Documents directory on the device:
C:\TEMP>ceDir (if the current directory is \My Documets)
or
C:\TEMP>ceDir "\my documents"
or
C:\TEMP>ceDir /MY
ceDir - version 03.00.00.01
(c) Srego, Inc - 2006
Current Device Directory: \My Documents
Directory of \My Documents
02/04/2002 08:43:00 AM 1,241,958 demo.gtx
11/25/2004 07:34:46 AM 121,601 test.gtx
12/16/2004 02:16:14 PM 101,160 TTFtest.gtx
12/14/2004 03:40:20 PM 252,668 Madison.gtx
12/06/2004 07:00:21 PM [DIR] My Pictures
11/11/2004 04:47:54 PM 1,830,399 MadisonCo.gtx
02/28/2003 09:18:20 AM 27,900 demoGPS.txt
08/15/2003 11:58:33 AM 41,812 gps.log
02/04/2004 08:08:48 AM 1,041,605 4s1e26.ecw
02/04/2004 08:05:56 AM 1,236,230 4s1e25.ecw
02/22/2005 08:19:54 AM 2,354,049 electGas.gtx
02/26/2004 06:00:02 PM [DIR] My Music
02/26/2004 06:00:02 PM [DIR] Business
02/26/2004 06:00:02 PM [DIR] Personal
02/26/2004 06:00:02 PM [DIR] Templates
10 File(s) 8,249,382 bytes
5 Dir(s)
The /MY option can be used to specify the \my documents directory regardless of the current directory. This option is no different than specifying the full path except that it is only 3 keystrokes instead of 15.Just like Command Prompt Dir command, ceDir can use wildcards in path to filter the output:
C:>ceDir *.gtx
ceDir - version 03.00.00.01
(c) Srego, Inc - 2006
Current Device Directory: \My Documents
Directory of \My Documents
02/04/2002 08:43:00 AM 1,241,958 demo.gtx
11/25/2004 07:34:46 AM 121,601 test.gtx
12/16/2004 02:16:14 PM 101,160 TTFtest.gtx
12/14/2004 03:40:20 PM 252,668 Madison.gtx
11/11/2004 04:47:54 PM 1,830,399 MadisonCo.gtx
02/22/2005 08:19:54 AM 2,354,049 electGas.gtx
6 File(s) 5,901,835 bytes
0 Dir(s)
The /O option can be used to sort the results by a variety of properties. The /ON will sort by name:
C:>ceDir *.gtx /on
ceDir - version 03.00.00.01
(c) Srego, Inc - 2006
Current Device Directory: \My Documents
Directory of \My Documents
02/04/2002 08:43:00 AM 1,241,958 demo.gtx
02/22/2005 08:19:54 AM 2,354,049 electGas.gtx
12/14/2004 03:40:20 PM 252,668 Madison.gtx
11/11/2004 04:47:54 PM 1,830,399 MadisonCo.gtx
11/25/2004 07:34:46 AM 121,601 test.gtx
12/16/2004 02:16:14 PM 101,160 TTFtest.gtx
6 File(s) 5,901,835 bytes
0 Dir(s)
The /O-N will sort by name in reverse order:
C:>ceDir *.gtx /o-n
ceDir - version 03.00.00.01
(c) Srego, Inc - 2006
Current Device Directory: \My Documents
Directory of \My Documents
12/16/2004 02:16:14 PM 101,160 TTFtest.gtx
11/25/2004 07:34:46 AM 121,601 test.gtx
11/11/2004 04:47:54 PM 1,830,399 MadisonCo.gtx
12/14/2004 03:40:20 PM 252,668 Madison.gtx
02/22/2005 08:19:54 AM 2,354,049 electGas.gtx
02/04/2002 08:43:00 AM 1,241,958 demo.gtx
6 File(s) 5,901,835 bytes
0 Dir(s)
The /OS will sort by file size:
C:>ceDir *.gtx /o-s
ceDir - version 03.00.00.01
(c) Srego, Inc - 2006
Current Device Directory: \My Documents
Directory of \My Documents
12/16/2004 02:16:14 PM 101,160 TTFtest.gtx
11/25/2004 07:34:46 AM 121,601 test.gtx
12/14/2004 03:40:20 PM 252,668 Madison.gtx
02/04/2002 08:43:00 AM 1,241,958 demo.gtx
11/11/2004 04:47:54 PM 1,830,399 MadisonCo.gtx
02/22/2005 08:19:54 AM 2,354,049 electGas.gtx
6 File(s) 5,901,835 bytes
0 Dir(s)
Wednesday, August 02, 2006
Determining the Size of a Directory on the Device
Dim filelist As Variant
Dim typelist As Variant
Dim count As Variant
If SregoCETPx1.GetFileListEx("\storage card\my documents\*.*", _
filelist, typelist, count, "/S") Then
Dim total As Double
total = 0
For i = 0 To count - 1
If typelist(i) = 1 Then
total = total + _
SregoCETPx1.GetFileSize(filelist(i), 0)
End If
Next
Debug.Print "Total: " + Str(total)
End If
Tuesday, August 01, 2006
The Undocumented CopyDB Method
Current verisons of the Srego CE ToolPack ActiveX control have an undocumented method. This method is not in the documentation because it did not meet the expectations of the users who wanted it added; however, many may find it useful none the less. The CopyDB method is an equivalent to the Srego CE ToolPack Command-Line tool ceCopyDB. The problem most users found with this method is that once you start it coping a .cdb file to the desktop from the device or an .mdb from the desktop to the device, it doesn't return control to your application until it is finished. So, there is no progress reporting, cancelling, or doing something else while it copies.
long CopyDB(long mode, BSTR sourceFile, BSTR destFile, BSTR options);
- mode - set to 0 for copy from desktop to device; 1 for device to desktop.
- sourceFile and destFile - the appropriate filename on the desktop or device.
- Options - this is a string of option identical to the ceDbCopy.exe. The exception is that you do not use the /D2P, /P2D, /D, or /P flags as they are already specified with the other parameters.
[/SY] Keep tables in sync
[/T table name] Specific table to copy, this option is repeatable
[/O] Allow overwrite
To use the options, you just string them together with a space between the different options:
“/T tab1 /T tab2”
You will have to experiment with this to see what works and what doesn’t.
Example:
Private Sub Command1_Click()
' Copy Desktop to Device
MousePointer = vbHourglass
If SregoCETPx1.CopyDB(0, "c:\temp\test33.mdb", _
"\my documents\test.cdb", "") Then
List1.AddItem "Successfully copied."
Else
temp = SregoCETPx1.GetErrorMessage
While temp <> ""
List1.AddItem temp
temp = SregoCETPx1.GetErrorMessage
Wend
End If
MousePointer = vbDefault
End Sub
Private Sub Command2_Click()
' Copy Device to Desktop
MousePointer = vbHourglass
If SregoCETPx1.CopyDB(1, "\my documents\test.cdb", _
"c:\temp\test1.mdb", "") Then
List1.AddItem "Successfully copied."
Else
temp = SregoCETPx1.GetErrorMessage
While temp <> ""
List1.AddItem temp
temp = SregoCETPx1.GetErrorMessage
Wend
End If
End Sub