Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Batch file shutdown while still at login screen

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

618 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