我已安排此以下任务在用户登录后(这是bat文件触发时)每XXX次重复一次。我想在它触发时跳过/不显示messageBox(意味着它在第一次运行时),但是在以下重复中不显示。关于如何解决这种情况有什么建议吗?
@echo off
SET client=Dear ABC,
SET MESSAGE=XYZ
@echo WScript.CreateObject("WScript.Shell").Popup "%client% %MESSAGE% & I will dissapear after 00 seconds.", 00, "title" > %TEMP%\wait.vbs
wscript %TEMP%\wait.vbs
答案 0 :(得分:1)
解决此问题的简单方法如下:
' Checks for the existence of a file which will
' serve as a flag, indicating if the script in
' question has already been run or not, acting
' accordingly afterwards.
Set objShell = CreateObject("WScript.Shell")
Set objFSO=CreateObject("Scripting.FileSystemObject")
homeFolder = objShell.ExpandEnvironmentStrings("%USERPROFILE%")
flagFile= homeFolder & "\flag.txt"
If (objFSO.FileExists(flagFile)) Then
' Display your message
msgbox("This is my message")
'...(do other things you want)
Else
' Do not display your message
' Creates flag to indicate that
' this script has already been executed
Set objFile = objFSO.CreateTextFile(flagFile,True)
'...(do other things you want)
End If