?
Solved

Batch file shutdown while still at login screen

Posted on 2004-03-28
4
Medium Priority
?
1,217 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
  • 2
4 Comments
 
LVL 59

Accepted Solution

by:
LeeTutor earned 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Ok I have been working on this for some time having learned and gained certification in XenDesktop 4 along came version 5 which was released last month. Since then I have been working to deploy XenDesktop 5 in a small environment with only 2 virt…
cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
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…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

839 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