为特定用户运行.bat

时间:2012-04-26 07:45:05

标签: batch-file windows-xp authentication logoff

我有一个Excel文件说Log.xls跟踪他的登录&注销时间。我希望在特定用户登录时以及在他退出时打开它。

我为此找到了解决方案,

  1. 写一个.bat文件说OpenLog.bat打开Log.xls

    @ECHO OFF 
    @ECHO "Please Wait, Your log file is about to open... Please Fill Your Work Log..."
    @CD E:\Anoop\Documents
    @CALL Log.xls
    @ECHO "Have a nice time"
    
  2. 运行gpedit.msc

    在用户配置下 - > Windows设置 - >打开脚本

    将Bat文件名添加到其中。

  3. 我希望在Windows XP计算机上为特定用户帐户运行此Log.xls。

1 个答案:

答案 0 :(得分:0)

好的,我们假设用户名是“John”

@ECHO OFF
if '%username%' == 'John' goto label1 else exit
label1:
ECHO "Please Wait, Your log file is about to open... Please Fill Your Work Log..."
CD E:\Anoop\Documents
CALL Log.xls
ECHO "Have a nice time"