?
Solved

Batch file shutdown while still at login screen

Posted on 2004-03-28
4
Medium Priority
?
1,214 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 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