• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 556
  • Last Modified:

Batch File Not To Run Everyday

I have a batch file which is to uninstall frminstal & install framepkg.exe.
I had placed in the server, so after my users login to domain , the batch file run on all computers.
But  I don't want the batch file to run everyday, may once a week. Is there a way ?
  • 3
1 Solution
Yes, there is.  You can do a comparison of the %date% variable so that the batch only runs on a specific day of the week.
you can schedule on the server
There is a command "at" from command prompt. using which you can schedule for a particular time.
The "at" is not going to work, because we are dealing with user logon scripts vs. a batch file scheduled to run on the server itself.
ktancl88Author Commented:
Dear mds-cos,

How does this %date% variable be added in to the batch file? How does it work?

Are you able to show me an example ?
Here is the simple way.  There are other ways, but I think this is proably the most straight-forward if you are using DOS level scripting.  I am using two scripts to very easily break apart the day and the date parts of the system variable %date%.

If you don't want to do this, dig into DOS scripting a bit.  There are other ways to accomplish the same thing.  And of course you could also move to vb script if you want a more powerful scripting language.

user.bat (or .cmd if you prefer)
rem  ! Main user login script !
.... Whatever else your login script does (time sync, drive mapping, printer mapping, etc.)

rem  script to uninstall frminstal & install framepkg.exe
call \\%loginserver%\netlogon\frameinstall.bat %date%

... Whatever additional you want your login script to do

frameinstall.bat (or .cmd if you prefer)
rem ! Script to uninstall frminstal & install framepkg.exe !
rem ! but only run every Friday                                       !

rem  if today is not friday exit the script
IF NOT "%1" == "Fri" goto :EOF

...your commands to uninstall frminstal
...your commands to install framepkg

:EOF  (this label is actually optional, since the :EOF label is now assumed by goto)


Featured Post

When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now