批处理脚本 - 检查myfile.txt中是否存在用户

时间:2016-10-27 13:43:07

标签: batch-file

我是新手,所以...... 到目前为止我有这个: - 从外部应用程序接收用户名 - 特定用户的格式为mylist.txt文件: USERNAME1 USERNAME2 USERNAME3 - CRLF位于每一行的末尾

我正在努力实现以下目标: - 将外部应用程序的已接收用户名与mylist.txt中的用户名进行比较 - 如果用户名在mylist.txt中,则发送邮件“登录的Mylist的USER%username%” - 如果用户名不在mylist.txt上,则发送邮件“USER%username”登录“

到目前为止,我这样做:

    IF /I "%event%" EQU "100" (
     FOR /F "tokens=1 delims= " %%n in (Mylist.txt) DO (
      IF /I %username% EQU %%n (
       ECHO %date% %time% %username% from Mylist.txt LOGON >> TEST.log
       CALL SEND_MAIL.BAT 1 "%date%-%time% USER:%username% from Mylist.txt LOGON")
    ELSE (
     ECHO %date% %time% %username% LOGON >> TEST.log
     CALL SEND_MAIL.BAT 1 "%date%-%time% USER:%username% from LOGON")
     )
    )

如果用户IS在mylist中,执行脚本会向我发送两封用于登录事件的电子邮件。对于不在mylist中的用户,我只收到一封电子邮件,那很好。 我已经尝试过NEQ,但它是一样的。

谢谢...

1 个答案:

答案 0 :(得分:0)

Chart.Series.Clear();
Chart.Header.Text = "Plot";
Chart.Axes.Automatic = true;
Chart.Legend.TopLeftPos = 0;
Chart.Axes.Bottom.Labels.DateTimeFormat = "HH:mm:ss";
Chart.Axes.Bottom.Labels.LabelsAsLocalTime = true;
Chart.Legend.LegendStyle = Steema.TeeChart.WPF.LegendStyles.Series;

FastLine series = new FastLine();
Chart.Series.Add(series);
series.FillSampleValues(1000);
Chart.Tools.Add(_scrollPager = new ScrollPager());
Chart.Tools.Add(_nearestPoint = new NearestPoint());
Chart.Tools.Add(_annotate = new Annotation());

_scrollPager.Series = series;

_nearestPoint.Series = series;
_nearestPoint.Brush.Color = _scrollPager.PointerHighlightColor;
_nearestPoint.DrawLine = false;
_nearestPoint.Size = 6;
_nearestPoint.Direction = NearestPointDirection.Horizontal;

_annotate.Position = AnnotationPositions.RightTop;
_annotate.Text = "YValue:";
_annotate.Shape.Shadow.Visible = false;
_annotate.Shape.Font.Color = Chart.Header.Font.Color;
_annotate.Shape.Color = _scrollPager.PointerHighlightColor;
_annotate.Shape.Pen.Visible = false;
_annotate.TextAlign = TextAlignment.Center;

语法要求 CALL SEND_MAIL.BAT 1 "%date%-%time% USER:%username% from Mylist.txt LOGON" ) ELSE ( 同时包含前一个结束else和开头)