批量回收路径

时间:2013-01-29 06:56:35

标签: batch-file

所以,我在将其中一行替换为文件时遇到问题。 代码如下:

IF NOT EXIST "%rutaSteamIdle%\tf2idle.ini" (
(
ECHO [Settings]
ECHO steam_location = C:\Program Files (x86)\Steam
ECHO secondary_steamapps_location = 
ECHO sandboxie_location = C:\Program Files\Sandboxie
ECHO api_key = 02FE9AB5998EA5F8A3E0DA7C4C47F3C7
ECHO backpack_viewer = Backpack.tf
ECHO launch_options = +exec idle.cfg -textmode -nosound -low -novid -nopreload -nojoy -sw +sv_lan 1 -width 640 -height 480 +map itemtest
ECHO launch_delay_time = 120
ECHO log_file_formatting = {date}, {time}, {itemtype}, {item}, {id}, {account}{nline}
ECHO easy_sandbox_mode = no
ECHO sys_tray_notifications = hats,tools
ECHO close_to_tray = False
ECHO log_web_view = On
ECHO log_web_view_port = 5000
ECHO ui_no_of_columns = 2
ECHO ui_window_size = (1024, 768)
ECHO ui_account_box_font_size = 12
ECHO ui_account_box_icon_size = 40
ECHO ui_account_box_icon = 
ECHO ui_log_entry_toggles = system,hats,weapons,tools,crates
ECHO log_poll_time = 1
ECHO ui_log_background_colour = 000000
ECHO ui_log_font_colour = FFFFFF
ECHO ui_log_font_size = 12
ECHO ui_log_font_family = TF2 Build
ECHO ui_log_font_style = 0
ECHO ui_log_font_weight = 50
ECHO ui_log_font_strikeout = False
ECHO ui_log_font_underline = False
)>>"%rutaSteamIdle%\tf2idle.ini"
)

运行时,我会'闪烁'(cmd窗口在关闭之前保持打开一秒钟)以下错误:

\Steam was unexpected at this time.

我在这里遗漏了什么吗? 如果我像这样划线:

ECHO steam_location = "C:\Program Files (x86)\Steam"

它正确地回应,但遗憾的是,这是我不能做的事情。

2 个答案:

答案 0 :(得分:1)

这是因为Steam的路径包含一个右括号。你需要像这样逃避它:

ECHO steam_location = C:\Program Files (x86^)\Steam

cmd的解析器对这些东西不太好。这是在带括号的块内,因此第一个未转义(或引用,但引用不起作用,因为echo也将输出引号)右括号将结束块。之后在同一行中的部分将被解释为下一个命令,在这种情况下\Steam会导致您收到错误消息。

答案 1 :(得分:0)

你也可以试试这个......

SET "steam_location=C:\Program Files (x86)\Steam"
ECHO %steam_location%

它会输出

  

C:> ECHO C:\ Program Files(x86)\ Steam

     

C:\ Program Files(x86)\ Steam

我希望这有效:)