1

我正在登录和注销会话中编写 Windows 脚本主机代码。当用户登录系统时,会记录时间戳,当用户再次注销时,会记录时间戳。我在下面提到了代码,但收到了一个错误作为预期的标识符,我发现很难解决它。

REM 登录脚本:

for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 "%computername%"') do set IP=%%i

echo %username% logged ON %computername%, IP=%IP% @ %time% %date% >> F:\$\%username%.txt

REM 注销脚本:

echo %username% logged OFF %computername% @ %time% %date% >> F:\$\%username%.txt 

REM 启动脚本:

for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 "%computername%"') do set IP=%%i
echo Started up, IP=%IP% @ %time% %date% >> F:\$\%computername%.txt

REM 关闭脚本:

echo Shutdown @ %time% %date% >> F:\$\%computername%.txt  
4

0 回答 0