如何让windows中的cmd中一个命令的输出作为另外一个命令的参数
比如dir/s/bf:\test.cmd的结果作为copyab.123后面接着的目录可以用c、cmd命令最初的目的就是实现创建一个bat文件在别人电脑上打开之后会自动添加...
比如dir/s/b f:\test.cmd的结果作为 copy ab.123 后面接着的目录
可以用c 、cmd命令 最初的目的就是实现创建一个bat文件在别人电脑上打开之后会自动添加到开机启动项 求高手 展开
可以用c 、cmd命令 最初的目的就是实现创建一个bat文件在别人电脑上打开之后会自动添加到开机启动项 求高手 展开
1个回答
展开全部
【背景】
折腾:
【记录】尝试给右键打开Cygwin的mintty中加上log文件功能
期间,已知:
cmd中,运行:
E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
可以得到:
20130906_224844
希望将此值,传递到:
E:\dev_install_root\cygwin\bin\mintty.exe –log=E:\201309.log
中,把201309替换掉,即类似于这样的含义:
E:\dev_install_root\cygwin\bin\mintty.exe –log=E:\(E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S).log
【折腾过程】
1.关于cmd中的重定向,只是>,貌似没法简单的实现这类效果。
2.然后参考了一堆的教程:
CMD命令for语句的用法详解
关于cmd命令的重定向输出
Using command redirection operators
CMD命令行高级教程精选合编
试了半天:
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_224844
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=<E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=|E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_230226
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S | set CUR_DATETIME=
/usr/bin/date: write error
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S > set CUR_DATETIME=
/usr/bin/date: extra operand `CUR_DATETIME='
Try `/usr/bin/date --help' for more information.
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_230315
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S > set CUR_DATETIME=
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=`E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S`
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
`E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S`
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=<E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>CUR_DATETIME=2013
'CUR_DATETIME' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=2013
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
2013
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_231133
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S 1>&1
重定向句柄 1 时,
无法复制此句柄。
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=|'E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S '
文件名、目录名或卷标语法不正确。
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=|E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_231328
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
2013
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=<E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=|E:\dev_install_root\cygwin\bin\date.exe
Fri Sep 6 23:14:31 2013
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=<E:\dev_install_root\cygwin\bin\date.exe
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
%CUR_DATETIME%
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\mintty.exe --log=E:\`E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%
H%M%S`.log
C:\Users\Administrator.PC-20130611GART>
结果还是没达到目标。
3.参考:
Variables: extract part of a variable (substring)
去试试。
C:\Users\Administrator.PC-20130611GART>SET _test=123456789abcdef0 && SET _result=%_test:~0,5% && ECHO %_result%
%_result%
C:\Users\Administrator.PC-20130611GART>SET _test=123456789abcdef0 & SET _result=%_test:~0,5% & ECHO %_result%
%_test:~0,5%
C:\Users\Administrator.PC-20130611GART>SET _test=123456789abcdef0 | SET _result=%_test:~0,5% | ECHO %_result%
12345
4.再参考:
Howto: Get variable substrings in Bat/Cmd scripts
去试试:
C:\Users\Administrator.PC-20130611GART>date
当前日期: 2013/09/06 周五
输入新日期: (年月日)
C:\Users\Administrator.PC-20130611GART>time
当前时间: 23:31:07.82
输入新时间:
C:\Users\Administrator.PC-20130611GART>date /t
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>time /t
23:31
C:\Users\Administrator.PC-20130611GART>time /?
显示或设置系统时间。
TIME [/T | time]
显示当前时间设置和输入新时间的提示,请键入
不带参数的 TIME。要保留现有时间,请按 Enter。
如果命令扩展被启用,TIME 命令会支持 /T 命令行开关;该命令行开关告诉
命令只输出当前时间,但不提示输入新时间。
C:\Users\Administrator.PC-20130611GART>date --help
系统无法接受输入的日期。
输入新日期: (年月日)
C:\Users\Administrator.PC-20130611GART>date /?
显示或设置日期。
DATE [/T | date]
显示当前日期设置和输入新日期的提示,请键入
不带参数的 DATE。要保留现有日期,请按 Enter。
如果命令扩展被启用,DATE 命令会支持 /T 开关;
该开关指示命令只输出当前日期,但不提示输入新日期。
C:\Users\Administrator.PC-20130611GART>echo %date%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>echo %date:~4,10%
/09/06 周五
C:\Users\Administrator.PC-20130611GART>echo %date:~,4%
2013
C:\Users\Administrator.PC-20130611GART>echo %date:~5,2%
09
C:\Users\Administrator.PC-20130611GART>echo %date:~8,2%
06
C:\Users\Administrator.PC-20130611GART>echo %time%
23:34:25.60
C:\Users\Administrator.PC-20130611GART>echo %time~,2%
%time~,2%
C:\Users\Administrator.PC-20130611GART>echo %time~0,2%
%time~0,2%
C:\Users\Administrator.PC-20130611GART>echo %time%
23:34:57.07
C:\Users\Administrator.PC-20130611GART>echo %time:~,2%
23
C:\Users\Administrator.PC-20130611GART>echo %time:~3,2%
35
C:\Users\Administrator.PC-20130611GART>echo %time:~6,2%
22
C:\Users\Administrator.PC-20130611GART>echo %time:~9,2%
17
C:\Users\Administrator.PC-20130611GART>set DATE=date | echo %DATE%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>set CURDATE=date | echo %CURDATE%
%CURDATE%
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% | echo %CURDATE%
%CURDATE%
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date%
C:\Users\Administrator.PC-20130611GART>echo %CURDATE%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && echo %CURDATE%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>set CURTIME=%date% && echo %CURTIME%
%CURTIME%
C:\Users\Administrator.PC-20130611GART>set CURTIME=%time% && echo %CURTIME%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>set CURTIME=%time% && echo %CURTIME%
23:39:42.27
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,4%
20130906 周
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%
20130906
C:\Users\Administrator.PC-20130611GART>set CURTIME=%date% && echo %CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
C:\Users\Administrator.PC-20130611GART>set CURTIME=%date% && echo %CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
23395517
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%date% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CURTIME:~
,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
20130906_203/9/6
C:\Users\Administrator.PC-20130611GART>set CURTIME=%time% && echo %CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
203/9/6
C:\Users\Administrator.PC-20130611GART>set CURTIME=%time% && echo %CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
23431515
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CURTIME:~
,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
20130906_23431811
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CURTIME:~
,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log
20130906_23434965.log
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && set LOGFILE=%CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CU
RTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log && echo %LOGFILE%
%LOGFILE%
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && set LOGFILE=%CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CU
RTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log && echo %LOGFILE%
20130906_23440529.log
C:\Users\Administrator.PC-20130611GART>
5.然后再去最后测试,能否真正用于mintty的log参数:
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && set CURLOGFILE=%CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_
%CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log && E:\dev_install_root\cygwin\bin\mintty.exe --log=E:\%CURLOGFILE%
虽然打开mintty了,也创建log文件了,可惜只是:
%CURLOGFILE%
而不是预想的日期的值。
但是,试了第二次,结果就可以了:
即,用:
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && set CURLOGFILE=%CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log && E:\dev_install_root\cygwin\bin\mintty.exe --log=E:\%CURLOGFILE%
的cmd命令,打开了mintty,
且的确生成了对应的log文件:
E:\20130906_23454766.log
效果还是不错的。
6.不知道,此处是否是有其他问题。搞得第二次才可以。
然后,把此部分的设置,尝试去添加到原先的注册表中。
之前是这样的,只有-e参数:
现在去添加变为:
set DATENOW=%date% && set TIMENOW=%time% && set CURLOG=%DATENOW:~,4%%DATENOW:~5,2%%DATENOW:~8,2%_%TIMENOW:~,2%%TIMENOW:~3,2%%TIMENOW:~6,2%%TIMENOW:~9,2%.log && E:\dev_install_root\cygwin\bin\mintty.exe --log=E:\%CURLOG% -e E:\dev_install_root\cygwin\bin\bash -c "/bin/xhere /bin/bash.exe '%L'"
即:
然后,再去测试一下:
效果是:
找不到应用程序
难道是command的值,太长了?(刚才在regedit中,都无法显示全。。。)
折腾:
【记录】尝试给右键打开Cygwin的mintty中加上log文件功能
期间,已知:
cmd中,运行:
E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
可以得到:
20130906_224844
希望将此值,传递到:
E:\dev_install_root\cygwin\bin\mintty.exe –log=E:\201309.log
中,把201309替换掉,即类似于这样的含义:
E:\dev_install_root\cygwin\bin\mintty.exe –log=E:\(E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S).log
【折腾过程】
1.关于cmd中的重定向,只是>,貌似没法简单的实现这类效果。
2.然后参考了一堆的教程:
CMD命令for语句的用法详解
关于cmd命令的重定向输出
Using command redirection operators
CMD命令行高级教程精选合编
试了半天:
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_224844
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=<E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=|E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_230226
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S | set CUR_DATETIME=
/usr/bin/date: write error
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S > set CUR_DATETIME=
/usr/bin/date: extra operand `CUR_DATETIME='
Try `/usr/bin/date --help' for more information.
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_230315
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S > set CUR_DATETIME=
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=`E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S`
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
`E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S`
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=<E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>CUR_DATETIME=2013
'CUR_DATETIME' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=2013
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
2013
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_231133
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S 1>&1
重定向句柄 1 时,
无法复制此句柄。
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=|'E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S '
文件名、目录名或卷标语法不正确。
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=|E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
20130906_231328
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
2013
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=<E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=|E:\dev_install_root\cygwin\bin\date.exe
Fri Sep 6 23:14:31 2013
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
+%Y%m%d_%H%M%S
C:\Users\Administrator.PC-20130611GART>set CUR_DATETIME=<E:\dev_install_root\cygwin\bin\date.exe
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
%CUR_DATETIME%
C:\Users\Administrator.PC-20130611GART>echo %CUR_DATETIME%
C:\Users\Administrator.PC-20130611GART>E:\dev_install_root\cygwin\bin\mintty.exe --log=E:\`E:\dev_install_root\cygwin\bin\date.exe +%Y%m%d_%
H%M%S`.log
C:\Users\Administrator.PC-20130611GART>
结果还是没达到目标。
3.参考:
Variables: extract part of a variable (substring)
去试试。
C:\Users\Administrator.PC-20130611GART>SET _test=123456789abcdef0 && SET _result=%_test:~0,5% && ECHO %_result%
%_result%
C:\Users\Administrator.PC-20130611GART>SET _test=123456789abcdef0 & SET _result=%_test:~0,5% & ECHO %_result%
%_test:~0,5%
C:\Users\Administrator.PC-20130611GART>SET _test=123456789abcdef0 | SET _result=%_test:~0,5% | ECHO %_result%
12345
4.再参考:
Howto: Get variable substrings in Bat/Cmd scripts
去试试:
C:\Users\Administrator.PC-20130611GART>date
当前日期: 2013/09/06 周五
输入新日期: (年月日)
C:\Users\Administrator.PC-20130611GART>time
当前时间: 23:31:07.82
输入新时间:
C:\Users\Administrator.PC-20130611GART>date /t
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>time /t
23:31
C:\Users\Administrator.PC-20130611GART>time /?
显示或设置系统时间。
TIME [/T | time]
显示当前时间设置和输入新时间的提示,请键入
不带参数的 TIME。要保留现有时间,请按 Enter。
如果命令扩展被启用,TIME 命令会支持 /T 命令行开关;该命令行开关告诉
命令只输出当前时间,但不提示输入新时间。
C:\Users\Administrator.PC-20130611GART>date --help
系统无法接受输入的日期。
输入新日期: (年月日)
C:\Users\Administrator.PC-20130611GART>date /?
显示或设置日期。
DATE [/T | date]
显示当前日期设置和输入新日期的提示,请键入
不带参数的 DATE。要保留现有日期,请按 Enter。
如果命令扩展被启用,DATE 命令会支持 /T 开关;
该开关指示命令只输出当前日期,但不提示输入新日期。
C:\Users\Administrator.PC-20130611GART>echo %date%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>echo %date:~4,10%
/09/06 周五
C:\Users\Administrator.PC-20130611GART>echo %date:~,4%
2013
C:\Users\Administrator.PC-20130611GART>echo %date:~5,2%
09
C:\Users\Administrator.PC-20130611GART>echo %date:~8,2%
06
C:\Users\Administrator.PC-20130611GART>echo %time%
23:34:25.60
C:\Users\Administrator.PC-20130611GART>echo %time~,2%
%time~,2%
C:\Users\Administrator.PC-20130611GART>echo %time~0,2%
%time~0,2%
C:\Users\Administrator.PC-20130611GART>echo %time%
23:34:57.07
C:\Users\Administrator.PC-20130611GART>echo %time:~,2%
23
C:\Users\Administrator.PC-20130611GART>echo %time:~3,2%
35
C:\Users\Administrator.PC-20130611GART>echo %time:~6,2%
22
C:\Users\Administrator.PC-20130611GART>echo %time:~9,2%
17
C:\Users\Administrator.PC-20130611GART>set DATE=date | echo %DATE%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>set CURDATE=date | echo %CURDATE%
%CURDATE%
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% | echo %CURDATE%
%CURDATE%
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date%
C:\Users\Administrator.PC-20130611GART>echo %CURDATE%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && echo %CURDATE%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>set CURTIME=%date% && echo %CURTIME%
%CURTIME%
C:\Users\Administrator.PC-20130611GART>set CURTIME=%time% && echo %CURTIME%
2013/09/06 周五
C:\Users\Administrator.PC-20130611GART>set CURTIME=%time% && echo %CURTIME%
23:39:42.27
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,4%
20130906 周
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%
20130906
C:\Users\Administrator.PC-20130611GART>set CURTIME=%date% && echo %CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
C:\Users\Administrator.PC-20130611GART>set CURTIME=%date% && echo %CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
23395517
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%date% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CURTIME:~
,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
20130906_203/9/6
C:\Users\Administrator.PC-20130611GART>set CURTIME=%time% && echo %CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
203/9/6
C:\Users\Administrator.PC-20130611GART>set CURTIME=%time% && echo %CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
23431515
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CURTIME:~
,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%
20130906_23431811
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && echo %CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CURTIME:~
,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log
20130906_23434965.log
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && set LOGFILE=%CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CU
RTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log && echo %LOGFILE%
%LOGFILE%
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && set LOGFILE=%CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CU
RTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log && echo %LOGFILE%
20130906_23440529.log
C:\Users\Administrator.PC-20130611GART>
5.然后再去最后测试,能否真正用于mintty的log参数:
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && set CURLOGFILE=%CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_
%CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log && E:\dev_install_root\cygwin\bin\mintty.exe --log=E:\%CURLOGFILE%
虽然打开mintty了,也创建log文件了,可惜只是:
%CURLOGFILE%
而不是预想的日期的值。
但是,试了第二次,结果就可以了:
即,用:
C:\Users\Administrator.PC-20130611GART>set CURDATE=%date% && set CURTIME=%time% && set CURLOGFILE=%CURDATE:~,4%%CURDATE:~5,2%%CURDATE:~8,2%_%CURTIME:~,2%%CURTIME:~3,2%%CURTIME:~6,2%%CURTIME:~9,2%.log && E:\dev_install_root\cygwin\bin\mintty.exe --log=E:\%CURLOGFILE%
的cmd命令,打开了mintty,
且的确生成了对应的log文件:
E:\20130906_23454766.log
效果还是不错的。
6.不知道,此处是否是有其他问题。搞得第二次才可以。
然后,把此部分的设置,尝试去添加到原先的注册表中。
之前是这样的,只有-e参数:
现在去添加变为:
set DATENOW=%date% && set TIMENOW=%time% && set CURLOG=%DATENOW:~,4%%DATENOW:~5,2%%DATENOW:~8,2%_%TIMENOW:~,2%%TIMENOW:~3,2%%TIMENOW:~6,2%%TIMENOW:~9,2%.log && E:\dev_install_root\cygwin\bin\mintty.exe --log=E:\%CURLOG% -e E:\dev_install_root\cygwin\bin\bash -c "/bin/xhere /bin/bash.exe '%L'"
即:
然后,再去测试一下:
效果是:
找不到应用程序
难道是command的值,太长了?(刚才在regedit中,都无法显示全。。。)
追问
这个我看过了的 谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询