|
hj_18
中级用户
  
积分 255
发帖 57
注册 2003-6-26
状态 离线
|
『第 76 楼』:
很好的程序
使用 LLM 解释/回答一下
我现在单位里的电脑是联想的,带有慧盾保护,C盘上无法保存数据,因此像Mozilla Firefox和Thunderbird的安装,配置文件都不能保存,还有许多程序都是要在C:\Documents and Settings下放东西,又不能移动文件夹的位置,确实很麻烦。我最近是这么来保存和备份的,有一次在还原卡解开的时候,我编辑“我的电脑”属性中的“Path"变量,把winrar的路径放进去,然后写个保存设置的文件:
mkbksd.bat
@rar a -u -as -ep3 -r e:\hj\backup\bk\bkfxsd.rar "C:\Documents and Settings\Administrator\Application Data\Mozilla"
@rar a -u -as -ep3 -r e:\hj\backup\bk\bkbirdsd.rar "C:\Documents and Settings\Administrator\Application Data\Thunderbird"
恢复设置
restore.bat
e:
@cd "e:\hj\backup\bk"
REM 尝试用关机备份文件恢复
@rar x -ep3 -o+ bkfxsd.rar
@rar x -ep3 -o+ bkbirdsd.rar
我想如果不能修改Path的内容,也可以在脚本中把rar打上绝对路径,简单用用还是可以的,当然不能和楼主的大作相提并论,只是我想说原来我也有写个这样的脚本的计划,现在就省力开心多了。
Now the computer in my unit is a Lenovo with Huidun protection. Data cannot be saved on the C drive. Therefore, the installations and configuration files of Mozilla Firefox and Thunderbird cannot be saved. Also, many programs need to put things in "C:\Documents and Settings", and the folder location cannot be moved, which is really troublesome. Recently, this is how I save and back up. Once when the restore card was unlocked, I edited the "Path" variable in the properties of "My Computer", put the path of winrar in it, and then wrote a file to save settings:
mkbksd.bat
@rar a -u -as -ep3 -r e:\hj\backup\bk\bkfxsd.rar "C:\Documents and Settings\Administrator\Application Data\Mozilla"
@rar a -u -as -ep3 -r e:\hj\backup\bk\bkbirdsd.rar "C:\Documents and Settings\Administrator\Application Data\Thunderbird"
Restore settings
restore.bat
e:
@cd "e:\hj\backup\bk"
REM Try to restore with the shutdown backup file
@rar x -ep3 -o+ bkfxsd.rar
@rar x -ep3 -o+ bkbirdsd.rar
I think if the content of Path cannot be modified, the absolute path of rar can also be put in the script. It can be used simply. Of course, it cannot be compared with the great work of the building owner. Just I want to say that I also had the plan to write such a script, and now it is labor-saving and happy.
|
|
2006-9-15 20:22 |
|
|
htysm
高级用户
   
积分 866
发帖 415
注册 2005-12-4
状态 离线
|
『第 77 楼』:
使用 LLM 解释/回答一下
这要花费多大的精力啊。
What a lot of effort this must take.
|
|
2006-9-15 22:08 |
|
|
htysm
高级用户
   
积分 866
发帖 415
注册 2005-12-4
状态 离线
|
『第 78 楼』:
程序有待改善。
使用 LLM 解释/回答一下
这个程序不完善呀,我刚才测试了一下,添加了一个备份作业,然后又删除了这项备份,可程序生成的备份文件并没有删除,并且自启动项里的启动项目也没有删除。:o
This program is not perfect. I just tested it. I added a backup job and then deleted this backup, but the backup file generated by the program was not deleted, and the startup item in the startup items did not delete either. :o
|
|
2006-9-15 22:46 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 79 楼』:
使用 LLM 解释/回答一下
Originally posted by htysm at 2006-9-15 22:46:
这个程序不完善呀,我刚才测试了一下,添加了一个备份作业,然后又删除了这项备份,可程序生成的备份文件并没有删除,并且自启动项里的启动项目也没有删除。:o
请问你是用这个程序自带的删除功能来删除的吗?如果用自带的来删除,应该删得了启动项目里的启动项的呀,我都测试了好久的。如果确实不能删除,请把你的操作详细地叙述一遍,看是哪个地方出了问题。
你说程序生成的备份文件没有删除,是指放在%programfiles%下的bat文件没有删除,还是指备份成功后copy过去的文件没有被删除?如果是后一种的话,那正是备份任务所需要的呀:就算程序删除了,但是文件还是保留下来了。如果是前者,还有请你把操作详细地描述一下。
Originally posted by htysm at 2006-9-15 22:46:
This program is not perfect. I just tested it. I added a backup job and then deleted this backup, but the backup file generated by the program was not deleted, and the startup item in the startup item was not deleted either. :o
Did you use the built-in delete function of this program to delete it? If you use the built-in one to delete, it should be able to delete the startup item in the startup item. I have tested it for a long time. If it really cannot be deleted, please describe your operation in detail to see which part is wrong.
You said that the backup file generated by the program was not deleted. Does it mean the bat file placed under %programfiles% was not deleted, or the file copied after the backup was successful was not deleted? If it is the latter, then it is exactly what the backup task needs: even if the program deletes it, the file is still retained. If it is the former, please describe your operation in detail.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-9-15 23:05 |
|
|
hj_18
中级用户
  
积分 255
发帖 57
注册 2003-6-26
状态 离线
|
『第 80 楼』:
使用 LLM 解释/回答一下
我建议试试unxutils,等会儿再聊。
I suggest trying unxutils, talk later.
|
|
2006-9-16 01:03 |
|
|
hj_18
中级用户
  
积分 255
发帖 57
注册 2003-6-26
状态 离线
|
『第 81 楼』:
使用 LLM 解释/回答一下
其实DOS下的批处理命令是很简陋的,很多时候要做出我们心目中想要的效果比较难,这时候不妨使用一些移植到windows下的Unix工具,很可能事半功倍。
见
http://unxutils.sourceforge.net/
比如把路径名与文件名分开可以用dirname等等,在我写脚本时发现很有用,以下是我的一个在右键菜单中加入 tar & gzip 压缩的脚本,一个草稿。水平很低,拿出来给大家笑笑。
set tmpdir=e:\temp\
set progdir="D:\Program Files\UnxUtils\usr\local\wbin\"
%progdir%echo -n -E %1 >%tmpdir%1.txt
%progdir%dirname %1 >%tmpdir%2.txt
%progdir%gawk "{print length($0)+2}" %tmpdir%2.txt > %tmpdir%3.txt
for /F %%i in (%tmpdir%3.txt) do %progdir%gawk "{print substr($0,\"%%i\")}" %tmpdir%1.txt > %tmpdir%4.txt
for /F "delims=?" %%j in (%tmpdir%4.txt) do set bsname=%%j
%progdir%gawk "BEGIN{FS=\".\"}$0 ~/\..?.?.?$/{NF=NF-1;print $0}" %tmpdir%4.txt >%tmpdir%5.txt
%progdir%test -s %tmpdir%5.txt
if %ERRORLEVEL%==1 goto noext
for /F "delims=?" %%i in (%tmpdir%5.txt) do %progdir%tar cvf "%%i.tar" "%bsname%" && %progdir%gzip "%%i.tar"
goto end
:noext
for /F "delims=?" %%i in (%tmpdir%4.txt) do %progdir%tar cvf "%%i.tar" "%bsname%" && %progdir%gzip "%%i.tar"
rem del /Q /S %tmpdir%1.txt
rem del /Q /S %tmpdir%2.txt
:end
修改注册表
Windows Registry Editor Version 5.00
@="用tar压缩"
@="D:\\Program Files\\UnxUtils\\bin\\mktgz.bat \"%L\""
@="用tar压缩"
@="D:\\Program Files\\UnxUtils\\bin\\mktgz.bat \"%L\""
Actually, the batch commands under DOS are quite rudimentary. Many times, it's difficult to achieve the effect we want. At this time, it's a good idea to use some Unix tools ported to Windows, which is likely to get twice the result with half the effort.
See http://unxutils.sourceforge.net/
For example, you can use dirname to separate the path name from the file name, etc. I found it very useful when writing scripts. The following is a draft of my script to add tar & gzip compression to the right-click menu. My level is very low, so I put it out for everyone to have a laugh.
set tmpdir=e:\temp\
set progdir="D:\Program Files\UnxUtils\usr\local\wbin\"
%progdir%echo -n -E %1 >%tmpdir%1.txt
%progdir%dirname %1 >%tmpdir%2.txt
%progdir%gawk "{print length($0)+2}" %tmpdir%2.txt > %tmpdir%3.txt
for /F %%i in (%tmpdir%3.txt) do %progdir%gawk "{print substr($0,\"%%i\")}" %tmpdir%1.txt > %tmpdir%4.txt
for /F "delims=?" %%j in (%tmpdir%4.txt) do set bsname=%%j
%progdir%gawk "BEGIN{FS=\".\"}$0 ~/\..?.?.?$/{NF=NF-1;print $0}" %tmpdir%4.txt >%tmpdir%5.txt
%progdir%test -s %tmpdir%5.txt
if %ERRORLEVEL%==1 goto noext
for /F "delims=?" %%i in (%tmpdir%5.txt) do %progdir%tar cvf "%%i.tar" "%bsname%" && %progdir%gzip "%%i.tar"
goto end
:noext
for /F "delims=?" %%i in (%tmpdir%4.txt) do %progdir%tar cvf "%%i.tar" "%bsname%" && %progdir%gzip "%%i.tar"
rem del /Q /S %tmpdir%1.txt
rem del /Q /S %tmpdir%2.txt
:end
Modify the registry
Windows Registry Editor Version 5.00
@="Compress with tar"
@="D:\\Program Files\\UnxUtils\\bin\\mktgz.bat \"%L\""
@="Compress with tar"
@="D:\\Program Files\\UnxUtils\\bin\\mktgz.bat \"%L\""
|
|
2006-9-16 03:08 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 82 楼』:
使用 LLM 解释/回答一下
Originally posted by hj_18 at 2006-9-16 03:08:
比如把路径名与文件名分开可以用dirname等等
其实,如果只是把路径名与文件名分离开的话,不用第三方软件,CMD中的for语句就可以办到,%%~pi 表示路径名,%%~ni 表示文件名,%%~nxi 表示带扩展名的文件名……呵呵,经过微软的不断改造,CMD已经非常强大了,只是限于我们的认识,还难以发挥它的全部功能而已。看似难以完成的工作,随着你认识的不断深入,就会发现你离成功越来越近,只到最后通过CMD来解决难题,不断有新的发现,不断有新的惊喜,这就是CMD命令行的魅力所在,这也是我们还在对CMD命令行孜孜不倦地探索的动力。呵呵,一点小感慨,扯得有点远了。
Originally posted by hj_18 at 2006-9-16 03:08:
For example, you can use dirname to separate the path name from the file name, etc.
Actually, if you just need to separate the path name from the file name, you don't need third-party software. The for statement in CMD can do it. %%~pi represents the path name, %%~ni represents the file name, %%~nxi represents the file name with extension... Hehe, through continuous improvement by Microsoft, CMD has become very powerful. It's just limited by our understanding, and it's difficult to give full play to all its functions. What seems difficult to complete, as your understanding deepens, you will find that you are getting closer to success. Finally, you can solve problems through CMD, keep making new discoveries, and keep having new surprises. This is the charm of the CMD command line, and this is also the motivation for us to keep exploring the CMD command line tirelessly. Hehe, a little sentiment, a bit off topic.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-9-19 06:19 |
|
|
hj_18
中级用户
  
积分 255
发帖 57
注册 2003-6-26
状态 离线
|
『第 83 楼』:
使用 LLM 解释/回答一下
我只是觉得dos不能把一个命令的输出结果直接赋值给一个变量,还要用个临时文件for一下,有点烦。而且像IF语句什么的不能跟复合语句体,几个语句要在一行上写完,格式上不好看。用FOR从文件中读取东西,怎么都不如gawk什么的方便。我还是试试perl什么的算了。
I just feel that DOS can't directly assign the output result of a command to a variable, and I have to use a temporary file and FOR, which is a bit annoying. Also, things like IF statements can't be followed by compound statement bodies, and several statements have to be written on one line, which is not nice in terms of format. Using FOR to read things from a file is never as convenient as gawk and so on. I might as well try perl or something.
|
|
2006-9-19 21:03 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 84 楼』:
使用 LLM 解释/回答一下
DOS可以把一个命令的输出结果直接赋给一个变量啊,只是一个变量每次只能接收一行的内容而已,完全可以不用临时文件的;如果用到了临时文件,要么就是你的功力还不够,要么就是临时文件有其他用途,要么……要么就是所有的命令行工具都无法绕过去的某种限制。
if语句还是可以跟复合语句体的啊,你在if set command的set语句和command语句中都可以用一对括号把复合语句体包括进去,可能你用得比较少吧。
DOS can directly assign the output result of a command to a variable. It's just that a variable can only receive one line of content at a time, and you can completely do without temporary files. If you use temporary files, either your skills are not enough, or the temporary files have other uses, or... or it's some kind of limitation that all command-line tools can't get around.
The if statement can still be followed by a compound statement body. You can enclose the compound statement body with a pair of parentheses in both the set statement and the command statement of if set command. Maybe you use it less.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-9-20 00:58 |
|
|
caicai
新手上路

积分 14
发帖 7
注册 2006-9-20
状态 离线
|
『第 85 楼』:
使用 LLM 解释/回答一下
第一次见到那么强大的批处理脚本,支持一下!
The first time I saw such a powerful batch script, give it a thumbs up!
|
|
2006-9-20 08:57 |
|
|
hj_18
中级用户
  
积分 255
发帖 57
注册 2003-6-26
状态 离线
|
『第 86 楼』:
使用 LLM 解释/回答一下
Originally posted by namejm at 2006-9-20 12:58 AM:
DOS可以把一个命令的输出结果直接赋给一个变量啊,只是一个变量每次只能接收一行的内容而已,完全可以不用临时文件的;如果用到了临时文� ...
那能不能教教我,举个实例好吗?我实在是搞不明白,谢谢。
啊,看了楼顶的帖子,明白了第二个问题。
今天会了第一个问题。
http://www.cn-dos.net/forum/viewthread.php?tid=23405&fpage=1&highlight=
Last edited by hj_18 on 2006-9-27 at 20:08 ]
Originally posted by namejm at 2006-9-20 12:58 AM:
DOS can directly assign the output result of a command to a variable. However, a variable can only receive the content of one line at a time. It can completely be done without temporary files; if temporary files are used...
Can you please teach me? Give an example. I really don't understand. Thank you.
Ah, after reading the post at the top, I understood the second question.
Today I understood the first question.
http://www.cn-dos.net/forum/viewthread.php?tid=23405&fpage=1&highlight=
Last edited by hj_18 on 2006-9-27 at 20:08 ]
|
|
2006-9-20 21:08 |
|
|
TQang
新手上路

积分 2
发帖 1
注册 2006-9-14
状态 离线
|
『第 87 楼』:
使用 LLM 解释/回答一下
xcopy_parameter参数没用上,是不是有点BUG
The xcopy_parameter parameter was not used. Is there a bit of a bug?
|
|
2006-9-20 23:14 |
|
|
uemuem
初级用户
 
积分 153
发帖 68
注册 2006-10-12 来自 上海
状态 离线
|
『第 88 楼』:
使用 LLM 解释/回答一下
友情提醒,这里有个小错误:
echo ecoh 不存在,可能已被改名、移动或者删除
这里的ECOH应该是ECHO吧,呵呵
不完善,没法恢复备份文件!
Last edited by uemuem on 2006-10-13 at 23:14 ]
Friendly reminder, there is a small error here:
echo ecoh does not exist, maybe it has been renamed, moved or deleted
Here ECOH should be ECHO, hehe
Incomplete, unable to restore the backup file!
Last edited by uemuem on 2006-10-13 at 23:14 ]
|

个人主页-找餐厅:http://www.canting.cc |
|
2006-10-13 23:12 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 89 楼』:
使用 LLM 解释/回答一下
ecoh确实是echo的笔误,多谢你的提醒,已经修改。
请问你是在什么情况下恢复不了备份文件的?
ecoh is indeed a typo for echo, thank you for your reminder, it has been modified.
May I ask under what circumstances you can't restore the backup file?
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-10-14 00:27 |
|
|
uemuem
初级用户
 
积分 153
发帖 68
注册 2006-10-12 来自 上海
状态 离线
|
『第 90 楼』:
使用 LLM 解释/回答一下
Originally posted by namejm at 2006-10-14 00:27:
ecoh确实是echo的笔误,多谢你的提醒,已经修改。
请问你是在什么情况下恢复不了备份文件的?
前面那个是提示出错,所以我看出来了
在源文件不存在,备份文件存在的情况下,不能把备份文件恢复到源文件的位置,也没有提示出错。。。
具体哪里出问题我也不太清楚,代码我也看不太懂,说实话!:lol:
Originally posted by namejm at 2006-10-14 00:27:
ecoh is indeed a typo of echo, thanks for your reminder, it has been modified.
In what situation are you unable to restore the backup file?
The previous one was a prompt for an error, so I noticed it
In the case where the source file does not exist but the backup file exists, the backup file cannot be restored to the source file's location, and there is no error prompt...
I don't know exactly where the problem is, and I can't understand the code either, to be honest! :lol:
|

个人主页-找餐厅:http://www.canting.cc |
|
2006-10-14 01:57 |
|