有人可以解释为什么批处理中的两条线不起作用吗
您好,我有以下 BAT 文件,除了第 70 行和第 78 行外,一切正常 任何人都可以帮助
Tnx-
@ECHO OFF
; Reseting system color configuration...
@COLOR 17
ECHO ===============================
ECHO == AUTOCAD 2010 De Mar Setup ==
ECHO ===============================
ECHO.
ECHO Creating a backup directory, Please wait...
ECHO.
mkdir C:\"AUTOCAD 2010 BACKUP"
ECHO.
ECHO AUTOCAD 2010 BACKUP directory successfully created...
ECHO.
ECHO Backing up nessesary files, Please wait...
ECHO.
xcopy /s/y C:\"Program Files\AutoCAD 2010\Support\acad2010doc.lsp" C:\"AUTOCAD 2010 BACKUP"
xcopy /s/y C:\"Program Files\AutoCAD 2010\Support\acad.lsp" C:\"AUTOCAD 2010 BACKUP"
xcopy /s/y C:\"Program Files\AutoCAD 2010\Support\acad.pgp" C:\"AUTOCAD 2010 BACKUP"
ECHO.
ECHO Nessesary files successfully Backed-up...
ECHO.
ECHO Deleting conflicting files, Please wait...
ECHO.
del C:\"Program Files\AutoCAD 2010\Support\acad2010doc.lsp"
del C:\"Program Files\AutoCAD 2010\Support\acad.lsp"
del C:\"Program Files\AutoCAD 2010\Support\acad.pgp"
ECHO.
ECHO Obsoleate files successfully deleted...
ECHO.
ECHO Deleting old desktop shortcut, Please wait...
del /s/q/f C:\"documents and settings\AutoCAD 2010.lnk"
ECHO.
ECHO Obsoleate desktop shortcut successfully deleted...
ECHO.
ECHO Refreshing Desktop icons...
ECHO.
rundll32 user32.dll,UpdatePerUserSystemParameters
ECHO.
ECHO Desktop successfully refreshed...
ECHO.
ECHO Creating Customised Shortcut, Please wait...
ECHO.
cscript "C:\VBS\SHORTCUT.vbs"
ECHO.
ECHO Customised shortcut successfully created...
ECHO.
ECHO Deleting AutoCAD 2010 Startup icon, Please wait...
ECHO Deleating obsoleate De Mar 2010 Setup uninstall startup icon...
del /s/q/f C:\"Documents and settings\%USERSPROFILE%\Menu Start\Programs\Hendrika's AutoCAD Instellingen\Uninstall Hendrika's AutoCAD Instellingen.lnk"
ECHO.
ECHO De Mar 2010 Setup uninstall startup icon successfully deleted...
ECHO.
ECHO Copying the UNINSTAAL DE MAR 2010.bat to new location...
xcopy /s/y/f C:\"BAT\UNINSTAAL DE MAR 2010.bat" C:\"Documents and Settings\%ALLUSERSPROFILE%\Menu Start\Programma's\Hendrika's AutoCAD Instellingen\"
MSG * AutoCAD 2010 Setup sucesfully compleated, Enjoy!
重述一下所关注的问题:
del /s/q/f C:\"Documents and settings\%USERSPROFILE%\Menu Start\Programs\Hendrika's AutoCAD Instellingen\Uninstall Hendrika's AutoCAD Instellingen.lnk"
以及
xcopy /s/y/f C:\"BAT\UNINSTAAL DE MAR 2010.bat" C:\"Documents and Settings\%ALLUSERSPROFILE%\Menu Start\Programma's\Hendrika's AutoCAD Instellingen\"
Hi I have the following BAT file all works well except for lines 70 and 78
can anybody help
Tnx-
@ECHO OFF
; Reseting system color configuration...
@COLOR 17
ECHO ===============================
ECHO == AUTOCAD 2010 De Mar Setup ==
ECHO ===============================
ECHO.
ECHO Creating a backup directory, Please wait...
ECHO.
mkdir C:\"AUTOCAD 2010 BACKUP"
ECHO.
ECHO AUTOCAD 2010 BACKUP directory successfully created...
ECHO.
ECHO Backing up nessesary files, Please wait...
ECHO.
xcopy /s/y C:\"Program Files\AutoCAD 2010\Support\acad2010doc.lsp" C:\"AUTOCAD 2010 BACKUP"
xcopy /s/y C:\"Program Files\AutoCAD 2010\Support\acad.lsp" C:\"AUTOCAD 2010 BACKUP"
xcopy /s/y C:\"Program Files\AutoCAD 2010\Support\acad.pgp" C:\"AUTOCAD 2010 BACKUP"
ECHO.
ECHO Nessesary files successfully Backed-up...
ECHO.
ECHO Deleting conflicting files, Please wait...
ECHO.
del C:\"Program Files\AutoCAD 2010\Support\acad2010doc.lsp"
del C:\"Program Files\AutoCAD 2010\Support\acad.lsp"
del C:\"Program Files\AutoCAD 2010\Support\acad.pgp"
ECHO.
ECHO Obsoleate files successfully deleted...
ECHO.
ECHO Deleting old desktop shortcut, Please wait...
del /s/q/f C:\"documents and settings\AutoCAD 2010.lnk"
ECHO.
ECHO Obsoleate desktop shortcut successfully deleted...
ECHO.
ECHO Refreshing Desktop icons...
ECHO.
rundll32 user32.dll,UpdatePerUserSystemParameters
ECHO.
ECHO Desktop successfully refreshed...
ECHO.
ECHO Creating Customised Shortcut, Please wait...
ECHO.
cscript "C:\VBS\SHORTCUT.vbs"
ECHO.
ECHO Customised shortcut successfully created...
ECHO.
ECHO Deleting AutoCAD 2010 Startup icon, Please wait...
ECHO Deleating obsoleate De Mar 2010 Setup uninstall startup icon...
del /s/q/f C:\"Documents and settings\%USERSPROFILE%\Menu Start\Programs\Hendrika's AutoCAD Instellingen\Uninstall Hendrika's AutoCAD Instellingen.lnk"
ECHO.
ECHO De Mar 2010 Setup uninstall startup icon successfully deleted...
ECHO.
ECHO Copying the UNINSTAAL DE MAR 2010.bat to new location...
xcopy /s/y/f C:\"BAT\UNINSTAAL DE MAR 2010.bat" C:\"Documents and Settings\%ALLUSERSPROFILE%\Menu Start\Programma's\Hendrika's AutoCAD Instellingen\"
MSG * AutoCAD 2010 Setup sucesfully compleated, Enjoy!
to recap the lines of concern are:
del /s/q/f C:\"Documents and settings\%USERSPROFILE%\Menu Start\Programs\Hendrika's AutoCAD Instellingen\Uninstall Hendrika's AutoCAD Instellingen.lnk"
and
xcopy /s/y/f C:\"BAT\UNINSTAAL DE MAR 2010.bat" C:\"Documents and Settings\%ALLUSERSPROFILE%\Menu Start\Programma's\Hendrika's AutoCAD Instellingen\"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许最简单的方法就是在这两行之前放置一个
echo
,例如:并
在末尾放置一个:,以便它等待您按 ENTER。
这至少应该向您展示变量替换在脚本中正在做什么。我认为您可能会发现
%ALLUSERSPROFILE%
已经是一个完整的路径名,并且不会友好地注入到另一个路径的中间:我认为它是顺便说一句,
USERPROFILE
(单数),而不是复数USERSPROFILE
。至少我的 WinXP 机器上是这样的。我认为您可能可以使用以下方法修复它:
和:
Probably the easiest thing to do is put an
echo
before both those lines, like:and put a:
at the end so it waits for you to hit ENTER.
That should at least show you what the variable substitutions are doing within the script. I think what you may find is that
%ALLUSERSPROFILE%
is a full path name already and won't take kindly to being injected into the middle of another path:I think it's
USERPROFILE
by the way (singular), not the pluralUSERSPROFILE
. At least that's how it is on my WinXP box.I think you'll probably be able to fix it by using:
and:
尝试以批处理模式执行脚本:
cscript "C:\VBS\SHORTCUT.vbs" //B
但是它会抑制脚本错误并提示!
Try executing the script in batch mode:
cscript "C:\VBS\SHORTCUT.vbs" //B
It will suppress script errors and prompts however!
转到命令提示符并输入
echo %userprofile%
它将返回“C:\Documents and Settings\YourProfileName”
您正在尝试删除不存在的目录..
del /s/q/f C:\"Documents和settings\C:\Documents and Settings\YourProfileName\Menu Start\Programs\Hendrika's AutoCAD Instellingen\Uninstall Hendrika's AutoCAD Instellingen.lnk"
%userprofile%全部准备好包含路径的“C:\Documents and Settings\Username”部分。
%ALLUSERSPROFILE% 也是如此。
Go to a command prompt and type
echo %userprofile%
It will come back with "C:\Documents and Settings\YourProfileName"
You are trying to delete a non-existent directory..
del /s/q/f C:\"Documents and settings\C:\Documents and Settings\YourProfileName\Menu Start\Programs\Hendrika's AutoCAD Instellingen\Uninstall Hendrika's AutoCAD Instellingen.lnk"
%userprofile% all ready contains the "C:\Documents and Settings\Username" part of the path.
Same thing with %ALLUSERSPROFILE%.