Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm new to batch files and I hope what I'm asking is possible. What I need to do is this. I want to write a batch file for a scheduled task. I read everywhere about setting up a day of the week for a certain event to happen but but not for a longer period of time say 2 months. This is what I would like to happen. Starting from a certain date. Lets say today for example 08/05/2008. 2 months from now give the shutdown command every day after that. I already have a third party piece of software that will allow the shutdown command.

Let me rephrase. I would like to have a login script that runs everytime a user logs in. The shutdown command will be executed evertime after the user logins once the target date is reached.

Sounds like a piece of nuisance-ware to me. You don't need a third party shutdown utility, as Windows has one built in; shutdown.exe.

This is not nuisance-ware I assure you. I was tasked with this project at work. We have a lot of laptops that go in and out(other departments that we arent responsible for). We have no real way to make sure they come back. Until we can budget for Lojack or a better suited program I have to go with what I have. I'm aware that shutdown.exe is available. Due to a active directory environment im not sure if the users are equiped with the correct permissions to use it. As for why im using the shutdown command. I want to get the point accross that the computer needs to come back. a simple notepad popping up would do but honestly I know they would just close it and not bother reading it. With the shutdown command I can specify a delay and they cant cancel the action.

Seems much simpler to just expire the account.
But, to answer the question, try this:
::==========================
:: get ready for month after next@echo off
setLocal EnableDelayedExpansioncall :YMD8
if not exist c:\tmonth call :targset
set /p expire=<c:\tmonth
if %expire% equ %month% echo this is month %month% and time to shut down
if %expire% neq %month% echo we're not there yet; this is only month %month%goto :eof
:YMD8
::== YMD8.bat
>> d.d echo E 0100 B4 2A CD 21 B4 4C CD 21
>> d.d echo N DAY.COM
>> d.d echo RCX
>> d.d echo 8
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 F0 B4 4C CD 21
>> d.d echo N MONTH.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 89 C8 B4 4C CD 21
>> d.d echo N YEAR.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 D0 B4 4C CD 21
>> d.d echo N DAT.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo Qdebug < d.d > nul
del d.ddat
for %%a in (1 2 3 4 5 6 7 8 9 ) do if errorlevel %%a set dat=0%%a
for %%a in ( 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31) do if errorlevel %%a set dat=%%a
echo Date %dat%day
if errorlevel 0 set day=Sunday
if errorlevel 1 set day=Monday
if errorlevel 2 set day=Tuesday
if errorlevel 3 set day=Wednesday
if errorlevel 4 set day=Thursday
if errorlevel 5 set day=Friday
if errorlevel 6 set day=Saturday
echo Day %day%month
for %%a in (1 2 3 4 5 6 7 8 9 ) do if errorlevel %%a set month=0%%a
for %%a in ( 10 11 12) do if errorlevel %%a set month=%%a
echo Month %month%year
if errorlevel 215 set Year=2007
if errorlevel 216 set Year=2008
if errorlevel 217 set Year=2009
if errorlevel 218 set Year=2010
echo Year %Year%del day.com
del month.com
del year.com
del dat.com
::== DONEgoto :eof
:targset
if %month% equ 01 set target=03
if %month% equ 02 set target=04
if %month% equ 03 set target=05
if %month% equ 04 set target=06
if %month% equ 05 set target=07
if %month% equ 06 set target=08
if %month% equ 07 set target=09
if %month% equ 08 set target=10
if %month% equ 09 set target=11
if %month% equ 10 set target=12
if %month% equ 11 set target=01
if %month% equ 12 set target=02> c:\tmonth echo %target%
goto :eof
=====================================
If at first you don't succeed, you're about average.M2

Hi d10,
Yep, you're the one who showed use the debug COM file creation.
=====================================
If at first you don't succeed, you're about average.M2

Thanks you this helps a lot. It would be simpler to set the domain user account to expire you're right. However the users will be most likely using a cached domain login. I also didn't catch if they will need a local user account. So This was the simplest thing I could think of.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |