1

I'm trying to shutdown my PC using a batch script, but when I type "@echo shutdown /r", CMD just displays "shutdown /r" on the screen, instead of doing the command. I'm currently new to batch scripting, so forgive me on my knowledge on the command prompt and batch scripting.

Here is my code (I don't think this will help):

    @echo off 
    title Shutdown.bat
    color 0a
    echo:

    echo Your PC will shutdown (testing).
    pause>nul

    @echo shutdown /r
    pause>nul
Deus luna
  • 19
  • 1
  • 2
  • `echo on` switches echo on -- see [`echo /?`](http://ss64.com/nt/echo.html)... – aschipfl Oct 31 '16 at 22:16
  • I don't know of an answer to your question, but I have a workaround: just have two lines, one echoing the output and one actually doing the work. So for you, it'd be `echo shutdown /r` followed by `shutdown /r`. Kind of ugly, but if you don't get a better answer that'll work. – Cody Oct 31 '16 at 22:16
  • `Echo` prints a message. You are telling it to print `shutdown /r` to the screen. Lose the `echo`. –  Oct 31 '16 at 22:18
  • btw ˋshutdown /rˋ will restart your PC not shutdown. See ˋshutdown /?ˋ for the syntax –  Nov 01 '16 at 00:03

1 Answers1

1

command echo text show you only text on command line. Use only shutdown /r for shutdown you pc.

Stephan
  • 53,940
  • 10
  • 58
  • 91
david
  • 83
  • 1
  • 13
  • Why didn't I think of that... anyways it came out like this: your pc will shut down (times the number I press enter) – Deus luna Oct 31 '16 at 22:27
  • i think this post can help you http://stackoverflow.com/a/162305/7058848 – david Oct 31 '16 at 22:47
  • I got it! I tried without the echo, but it didn't quite work. Then I tried copying and pasting my code into Notepad instead of Notepad ++. For some odd reason when I try to run this code on notepad ++, it just displays "Your pc will shutdown" (times the user presses enter). – Deus luna Nov 03 '16 at 01:50