none
Splitting line in Batch Message Pop Up RRS feed

  • Question

  • @echo off
    shutdown.exe /s /t 600 
    echo wscript.quit MsgBox ("Your machine will shutdown in 60 seconds. Click YES to shutdown now or NO to abort", 4, "SHUTDOWN REMINDER") > yesno.vbs
    wscript //nologo yesno.vbs
    set value=%errorlevel%
    del yesno.vbs
    if "%value%"=="6" shutdown.exe /s /t 00 /f
    if "%value%"=="7" shutdown -a 

    Hi I have above code to pop up user with a message to abort shutdown or shutdown now. I want to display the message in two lines i.e. "Your machine will shutdown in 60 seconds" in one and "Click YES to shutdown now or NO to abort" in other. How to get this

    Please Help. 

    Thanks in advance

    Friday, February 14, 2014 11:00 AM

Answers

  • Why not just do it all in VB?

    set WshShell = createobject("Wscript.shell")
    wshShell.run "Shutdown -s -t 60"
    l = msgbox ("Your machine will shut down in 60 seconds" & vbcrlf & vbcrlf & _
                "Click ok to shutdown now or cancel to abort", vbokcancel, "Shutdown")
    if l = vbcancel then
       wshShell.run "shutdown -a"
    elseif l = vbok then
       wshShell.run "Shutdown -s -t 00 -f"
      
    end if
     

    Friday, February 14, 2014 11:29 AM

All replies

  • Why not just do it all in VB?

    set WshShell = createobject("Wscript.shell")
    wshShell.run "Shutdown -s -t 60"
    l = msgbox ("Your machine will shut down in 60 seconds" & vbcrlf & vbcrlf & _
                "Click ok to shutdown now or cancel to abort", vbokcancel, "Shutdown")
    if l = vbcancel then
       wshShell.run "shutdown -a"
    elseif l = vbok then
       wshShell.run "Shutdown -s -t 00 -f"
      
    end if
     

    Friday, February 14, 2014 11:29 AM
  • Thanks Braham20,

    I know this procedure in VBScript. But the requirement is to furnish this in Batch file only.

    Can you help me with that. 

    thanks in advance

    Friday, February 14, 2014 11:40 AM
  • Sorry Aby, I'm sure there's probably a way of using delims to echo it all into a file without too many problems but I don't know how off the top of my head. Why is it you can only use a batch file? Jrv or David will probably be along shortly with a good solution :)
    Friday, February 14, 2014 2:01 PM
  • Hi,
    I know this procedure in VBScript. But the requirement is to furnish this in Batch file only.

    You're already not meeting that requirement, since you're still creating and calling a VBScript file from your batch script. If you can get away with generating one on the fly, why not just use pure VBScript?

    EDIT: Also, have you already solved this issue? I see you've posted another question with a script you say works just fine.


    Don't retire TechNet! - (Don't give up yet - 12,575+ strong and growing)


    Friday, February 14, 2014 2:15 PM
  • The key in this case is actually the use of escape characters. (^)  The escape character cancels the function of &. in this example you can create as many lines as you like.  Each "^& vbcrlf " is the equivalent of a new line.

      @echo off
       shutdown.exe /s /t 600 
       echo wscript.quit MsgBox ("Your machine will shutdown in 60 seconds." ^& vbcrlf ^& vbcrlf ^& _  > yesno.vbs
       echo "Click YES to shutdown now or NO to abort", 4, "SHUTDOWN REMINDER") >> yesno.vbs
       wscript //nologo yesno.vbs
       set value=%errorlevel%
       del yesno.vbs
       if "%value%"=="6" shutdown.exe /s /t 00 /f
       if "%value%"=="7" shutdown -a


    Those who forget to script are doomed to repeat themselves.

    Monday, November 9, 2015 7:05 PM