"命令的语法不正确"问题

时间:2016-10-21 18:46:08

标签: windows batch-file

我的批处理文件出现问题。我正在尝试使用BGInfo在其桌面上显示用户的IP地址。我的代码是:

If Not Exist "C:\Users\%username%\Information"
(
    copy "\\heartbeat\shared\Information\bginfo.exe" "C:\Users\%username%\bginfo.exe"    
    copy "\\heartbeat\shared\Information\display.bgi" "C:\Users\%username%\display.bgi"
)
C:\Users\%username%\bginfo.exe "C:\Users\%username%\display.bgi" /timer:0

我被告知IF语句的语法不正确。不确定是什么问题。

1 个答案:

答案 0 :(得分:0)

试试这个:

@Echo Off
If Not Exist "%UserProfile%\Information\" MD "%UserProfile%\Information"
If Not Exist "%UserProfile%\Information\bginfo.exe" (
    Copy "\\heartbeat\shared\Information\bginfo.exe" "%UserProfile%\Information")
If Not Exist "%UserProfile%\Information\display.bgi" (
    Copy "\\heartbeat\shared\Information\display.bgi" "%UserProfile%\Information")
Start "" /D"%UserProfile%\Information" bginfo.exe display.bgi /timer:0 /nocliprompt /silent