有人可以解释为什么批处理中的两条线不起作用吗

发布于 2024-10-16 12:00:29 字数 2587 浏览 7 评论 0原文

您好,我有以下 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

慈悲佛祖 2024-10-23 12:00:29

也许最简单的方法就是在这两行之前放置一个 echo ,例如:

echo del /s/q/f C:\"Docu ...

pause

在末尾放置一个:,以便它等待您按 ENTER

这至少应该向您展示变量替换在脚本中正在做什么。我认为您可能会发现 %ALLUSERSPROFILE% 已经是一个完整的路径名,并且不会友好地注入到另一个路径的中间:

C:\Documents and Settings\Pax\My Documents> echo %ALLUSERSPROFILE%
C:\Documents and Settings\All Users
C:\Documents and Settings\Pax\My Documents> echo %USERPROFILE%
C:\Documents and Settings\Pax

我认为它是顺便说一句,USERPROFILE(单数),而不是复数USERSPROFILE。至少我的 WinXP 机器上是这样的。

我认为您可能可以使用以下方法修复它:

del /s/q/f "%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" "%ALLUSERSPROFILE%\Menu Start\Programma's\Hendrika's AutoCAD Instellingen\"

Probably the easiest thing to do is put an echo before both those lines, like:

echo del /s/q/f C:\"Docu ...

and put a:

pause

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:

C:\Documents and Settings\Pax\My Documents> echo %ALLUSERSPROFILE%
C:\Documents and Settings\All Users
C:\Documents and Settings\Pax\My Documents> echo %USERPROFILE%
C:\Documents and Settings\Pax

I think it's USERPROFILE by the way (singular), not the plural USERSPROFILE. At least that's how it is on my WinXP box.

I think you'll probably be able to fix it by using:

del /s/q/f "%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" "%ALLUSERSPROFILE%\Menu Start\Programma's\Hendrika's AutoCAD Instellingen\"
没企图 2024-10-23 12:00:29

尝试以批处理模式执行脚本:
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!

柏拉图鍀咏恒 2024-10-23 12:00:29

转到命令提示符并输入

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% 也是如此。

      (You ARE typing USERprofile and not USER**S**profile, right? ;-)  )

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%.

      (You ARE typing USERprofile and not USER**S**profile, right? ;-)  )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文