为什么我的批处理文件在 Windows CE 中不起作用?

Why doesn't my batch file work in Windows CE?

我的脚本没有在 Windows CE 版本 8 上执行。

我正在从用户那里获取文件路径作为输入,附加文件名并尝试 'start' 它。

但是 @ echo off 未被考虑,当 运行 在设备中输入时,所有命令都显示在控制台中。此外,启动命令的 none 和 set /p 命令都是 运行。显示错误

@ echo off
if exist clientshutdown3.exe (
   start clientshutdown3.exe
   start ConmanClient3.exe
   start CMAccept3.exe
   start MSVSMON.EXE
 ) else (
   set /p mypath=Enter path of pdf file: 
)

if defined mypath start "" "%mypath%\clientshutdown3.exe" 
if defined mypath start "" "%mypath%\ConmanClient3.exe" 
if defined mypath start "" "%mypath%\CMAccept3.exe" 
if defined mypath start "" "%mypath%\MSVSMON.EXE"

Windows CE 命令shell 没有NT 兄弟那么强大。 CE下不支持Set /P。

shell 自 v5 以来没有改变。 (https://en.wikipedia.org/wiki/Windows_Embedded_Compact)

以下是 v5 支持的命令及其参数的列表。 http://nellisks.com/ref/dos/ce/SET.html

如果您确实需要使用 shell.

解决此问题,您可以使用另一种语言轻松地编写此行为。

祝你好运。

根据维基百科 the console in WinCE is also cmd.exe。但是它们并不相同 cmd.exe,因此它们的功能会有所不同

来自 Command Processor Commands (Windows CE 5.0) on MSDN it seems Windows CE's cmd.exe is very primitive and more like command.com than Windows NT's cmd.exe. For example it doesn't support exit /B or copy /B and so on. Similarly it doesn't have set /P, set /A or set "with=quote" 的列表,仅支持

SET [variable=[string]]

我还发现了另一个Script Commands for Windows Mobile Devices. In this list the if command的详细列表声称只有以下形式

if [not] errorlevel number scriptCommand 
if [not] string1==string2 command 
if [not] exist filename command 
if [not] procexists processName command

此列表中没有 if defined。但是 document on MSDN 不同意,因为它没有列出奇怪的 procexists 形式,而是 IF [NOT] DEFINED variable command 一个

然而,双方都同意 if 不能有 else,因此您的 if/else 块也不起作用。即使它有 if defined,脚本的最后几行也不会起作用,因为您使用了 start "",这在 WinCE 中不可用。您必须使用 START command [parameters] 而不是

总之,if/elseset /Pstart ""(可能还有 if defined

会出现问题