Solved

Batch file shutdown while still at login screen

Posted on 2004-03-28
4
1,211 Views
Last Modified: 2011-10-03
I have a scheduled backup file that runs everynight as an unattended program that starts whithout loging into the system.  My problem is that after the backup I wish to shutdown the computer but the command below will not log off unless I am totally logged on as an account.  

Is there a way to add a shutdown command to a batch file that will shut down the computer without being logged on?

What I have that does not work is:

if %DayofWeek%==Sun   (
      echo Sunday Backup
c:
cd "c:\Program Files\stomp\backup MyPC"
start /wait bewin32.exe /Start SundayDiff
start /wait bewin32.exe /Start Sunday_EFGFull
c:
cd c:\windows\system32
call shutdown.exe -s -t 00 -c "Shutting Down NOW"
)

0
Comment
Question by:rronne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 59

Accepted Solution

by:
LeeTutor earned 50 total points
ID: 10705788
>call shutdown.exe -s -t 00 -c "Shutting Down NOW"

I use shutdown.exe in a shortcut that I can click on my Desktop when I want to shut down the computer.  I wonder if that "call" is necessary in the batch statement?  I seem to recall that "call" is supposed to be used in batch files to call batch subroutines... Try removing the "call" in the last statement and see what happens.
0
 
LVL 17

Expert Comment

by:Eagle6990
ID: 10707377
Also, what is the point of doing echos if no user is logged in to see it?

I can't find any proof right now because I can't run a sample script on my system here, but try removing call as Lee stated, but also remove .exe on shutdown.  I've seen this cause problem.
0
 

Author Comment

by:rronne
ID: 10710280
LeeTutor,
   I had in fact thought of that myself and have also now tried  -

if %DayofWeek%==Mon (
      echo Monday Backup
c:
cd "c:\Program Files\stomp\backup MyPC"
REM start /wait bewin32.exe /Start MondayDiff
c:
cd c:\windows\system32
shutdown -s -t 00 -c "Shuting Down NOW"

)

but still the shutdown will not perform if I run this while at the loggin.

PS  The echo command is only there so that I can see it for testing when I was actually logged on,  My batch file actually has and entry for each day of the week and I wanted to make sure it was going to the correct date.

0
 

Author Comment

by:rronne
ID: 10714321
LeeTutor,
   I don't know why my tests last night did not seem to do the shutdown, but today when I came down to my computer to check on the backup it was properly shutdown and since I did not do that I have to assume that the batch file ran correctly early this morning (1am).

  I had taken the Call out of the original shutdown line before I was trying your suggestion on a test file.  Anyway I will keep my fingers crossed that the following code seems to be working (at least it did early this morning)

@echo off
REM ***********************
REM extract current date
REM ***********************
cls
echo ---------------------
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set DayOfWeek=%%i
set Month=%%j
set Day=%%k
set Year=%%l
set Date=%%i   %%j/%%k/%%l
)

echo %Date%
echo ---------------------
echo %DayofWeek%
echo *********************
::****************************************************
:::::::::::::::   SUNDAY   :::::::::::::::::::::::::::
if %DayofWeek%==Sun   (
      echo Sunday Backup
c:
cd "c:\Program Files\stomp\backup MyPC"
start /wait bewin32.exe /Start SundayDiff
start /wait bewin32.exe /Start Sunday_EFGFull
c:
cd c:\windows\system32
shutdown.exe -s -t 00 -c "Shutting Down NOW"

)
::****************************************************
:::::::::::::::   MONDAY   :::::::::::::::::::::::::::
if %DayofWeek%==Mon (
      echo Monday Backup
c:
cd "c:\Program Files\stomp\backup MyPC"
start /wait bewin32.exe /Start MondayDiff
c:
cd c:\windows\system32
shutdown.exe -s -t 00 -c "Shutting Down NOW"


)
::****************************************************
:::::::::::::::   TUESDAY  :::::::::::::::::::::::::::
if %DayofWeek%==Tue (
      echo Tuesday Backup
c:
cd "c:\Program Files\stomp\backup MyPC"
Start /wait bewin32.exe /Start TuesdayDiff
c:
cd c:\windows\system32
shutdown.exe -s -t 00 -c "Shutting Down NOW"

)
::****************************************************
::::::::::::::: WEDNESDAY  :::::::::::::::::::::::::::
if %DayofWeek%==Wed   (
      echo Wednesday Backup
c:
cd "c:\Program Files\stomp\backup MyPC"
Start /wait bewin32.exe /Start WednesdayDiff
Start /wait bewin32.exe /Start WednesdayFull
c:
cd c:\windows\system32
shutdown.exe -s -t 00 -c "Shutting Down NOW"
)
::****************************************************
::::::::::::::      THURSDAY    :::::::::::::::::::::::
if %DayofWeek%==Thu   (
      echo Thursday Backup
c:
cd "c:\Program Files\stomp\backup MyPC"
Start /wait bewin32.exe /Start ThursdayDiff
c:
cd c:\windows\system32
shutdown.exe -s -t 00 -c "Shutting Down NOW"
)
::****************************************************
::::::::::::::      FRIDAY    :::::::::::::::::::::::
if %DayofWeek%==Fri   (
      echo Friday Backup
c:
cd "c:\Program Files\stomp\backup MyPC"
Start /wait bewin32.exe /Start FridayDiff
c:
cd c:\windows\system32
shutdown.exe -s -t 00 -c "Shutting Down NOW"
)
::****************************************************
:::::::::::::::   SATURDAY :::::::::::::::::::::::::::
if %DayofWeek%==Sat   (
      echo Saturday Backup
c:
cd "c:\Program Files\stomp\backup MyPC"
Start /wait bewin32.exe /Start SaturdayDiff
Start /wait bewin32.exe /Start Saturday_CDFull
c:
cd c:\windows\system32
shutdown.exe -s -t 00 -c "Shutting Down NOW"
)
::****************************************************
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question