none
How can CMD Command History be cleared? RRS feed

  • Question

  • I want to clear CMD or Batch command history (via pressing up and down key), but I cant :(

    How can we clean command history from cmd or batch. 

    Is there an any command to clear command history, in place of Alt+F7 for bat scripts?


    • Edited by serdaruzun Sunday, September 7, 2014 9:50 PM Mistaken definition
    Sunday, September 7, 2014 4:24 PM

Answers

  • Hah! Nothing to do with memory.

    You are aski9ng how to clear an "environment  variable".

    Simple:

    Set PingPC=

    That is hwo we clear or remove a variable.  I also notice that you like to put spaces around your equal signs.  Don't.  It doesn't work as expected.

    Do this
    SET VAR=something

    DO NOT DO THIS

    SET VAR = something else

    Watch:

    C:\scripts>SET VAR=something
    C:\scripts>if [%var%] == [something] echo match
    match

    Now this:

    C:\scripts>SET VAR= something
    C:\scripts>if [%var%] == [something] echo match
    something] was unexpected at this time.


    ¯\_(ツ)_/¯

    Monday, September 8, 2014 9:10 PM

All replies

  • Hi

    Within windows you can restart explorer. Can you provide more information as well please?


    Hope this helps. Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Sunday, September 7, 2014 4:29 PM
  • I want to reset CMD or Batch commands via pressing up and down key, but I cant :(

    How can we clean command memories from cmd or batch. Is there any way to reset cmd command memory except to restart it.

    Thank you in advance...


    \_(ツ)_/ twitter.com/serdaruzun

    This has nothing to do with scripting.  It is about how to use Windows CMD.  There is no memory in a batch.

    If you are asking about environment variables then you need to specify that and post in the Windows forum for your version of Windows or post here:

    http://answers.microsoft.com


    ¯\_(ツ)_/¯

    Sunday, September 7, 2014 5:48 PM
  • Hi

    Within windows you can restart explorer. Can you provide more information as well please?


    Hope this helps. Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    "DOS" (CMD.EXE) history is not cleared by restarting anything. CMD is not part of Explorer and has no memory.

    Type DOSKEY /? to see how to manage command history.

    This is not a scripting question.  It is a new user question.  I recommend getting a book for new users and reviewing these things.  They will clarity much for you. 
    Post user questions about basic utilities at: http://answers.microsoft.com


    ¯\_(ツ)_/¯


    • Edited by jrv Sunday, September 7, 2014 5:57 PM
    Sunday, September 7, 2014 5:56 PM
  • Press Alt+F7 to clear the command history buffer for a console window.

    But this isn't really a scripting question.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by serdaruzun Sunday, September 7, 2014 9:35 PM
    • Unmarked as answer by serdaruzun Monday, September 8, 2014 9:14 AM
    Sunday, September 7, 2014 9:32 PM
    Moderator
  • Press Alt+F7 to clear the command history buffer for a console window.

    But this isn't really a scripting question.


    -- Bill Stewart [Bill_Stewart]

    As always,  jrv reprimanded me :( instead of trying understand...

    I couldnt ask my question properly beacuse of my bad english, sory :( Thank you Bill_Stewart :) You understand me :) And your answer worked well. 

    Is there an any command to clear command history, in place of Alt+F7 for bat scripts

    By the way Bill_Stewart thank you again :)



    \_(ツ)_/ twitter.com/serdaruzun

    Sunday, September 7, 2014 9:46 PM
  • Not  a reprimand - You just were asking a question that didn't make any sense the way your asked it so I tried to point you at some good background.

    A good book on basic Windows would help you knowledge as well as you English although the issue here was not English.  It was a lack of knowledge and a lack of knowing that memory is not the term.

    The most important take-away is to think if the question is really about scripting.  Learn to use the answers and other basic forums to get answers.

    Good luck until next time.

    Oh - FYI

    DOSKEY /REINSTALL is the batch equivalent of ALT-F7 which is what you asked for.


    ¯\_(ツ)_/¯



    • Edited by jrv Sunday, September 7, 2014 10:09 PM
    Sunday, September 7, 2014 10:08 PM
  • Not  a reprimand - You just were asking a question that didn't make any sense the way your asked it so I tried to point you at some good background.

    A good book on basic Windows would help you knowledge as well as you English although the issue here was not English.  It was a lack of knowledge and a lack of knowing that memory is not the term.

    The most important take-away is to think if the question is really about scripting.  Learn to use the answers and other basic forums to get answers.

    Good luck until next time.


    ¯\_(ツ)_/¯

    You dont have to answer, do you?

    \_(ツ)_/ twitter.com/serdaruzun

    Sunday, September 7, 2014 10:10 PM
  • Not  a reprimand - You just were asking a question that didn't make any sense the way your asked it so I tried to point you at some good background.

    A good book on basic Windows would help you knowledge as well as you English although the issue here was not English.  It was a lack of knowledge and a lack of knowing that memory is not the term.

    The most important take-away is to think if the question is really about scripting.  Learn to use the answers and other basic forums to get answers.

    Good luck until next time.


    ¯\_(ツ)_/¯

    You dont have to answer, do you?

    \_(ツ)_/ twitter.com/serdaruzun


    The answer is DOSKEY /REINSTALL or Alt-F7.  I posted that above.

    ¯\_(ツ)_/¯

    • Proposed as answer by jrv Sunday, September 7, 2014 10:28 PM
    • Unproposed as answer by serdaruzun Sunday, September 7, 2014 10:34 PM
    Sunday, September 7, 2014 10:16 PM
  • Not  a reprimand - You just were asking a question that didn't make any sense the way your asked it so I tried to point you at some good background.

    A good book on basic Windows would help you knowledge as well as you English although the issue here was not English.  It was a lack of knowledge and a lack of knowing that memory is not the term.

    The most important take-away is to think if the question is really about scripting.  Learn to use the answers and other basic forums to get answers.

    Good luck until next time.


    ¯\_(ツ)_/¯

    You dont have to answer, do you?

    \_(ツ)_/ twitter.com/serdaruzun


    The answer is DOSKEY /REINSTALL or Alt-F7.  I posted that above.

    ¯\_(ツ)_/¯

    I tried DOSKEY /REINSTALL or Alt-F7 before but it doesnt work. Even if blank, My batch script accepts alyways latest entered data input.

    :PingCheck @ECHO OFF SET /P PingPC=IP or HostName: doskey /listsize=0 if [%PingPC%]==[] cls && goto Blank cls COLOR 3E cls start "%PingPC% nolu PC icin Ping Kontrolu Yapiliyor" cmd /c "ping %PingPC% -w 10 -t" ^& start doskey /reinstall ^& pause if %errorlevel% == -2147023174 goto IKAZPing goto PingCheck :IKAZPing @echo There is no connection pause goto PingCheck

    :Blank

    @echo You did not enter anything. Try again

    pause

    goto :PingCheck

    For example:

    In my script above, you enter www.serdaruzun.com then a windows will be opened to check for ping control. But after that, if you enter again without entering nothing, it accepts the latest data entered, namely www.serdaruzun.com; ok?

    I hope I can explain my problem?


    \_(ツ)_/ twitter.com/serdaruzun





    • Edited by serdaruzun Sunday, September 7, 2014 10:33 PM add
    Sunday, September 7, 2014 10:29 PM
  • Then you need to tell us what the purpose of this is.  So far I see no reason for what you are doing.

    ¯\_(ツ)_/¯

    Sunday, September 7, 2014 10:37 PM
  • P.S. - Command History is not "command buffer".  You cannot manage the commend buffer in CMD.EXE.


    ¯\_(ツ)_/¯


    • Edited by jrv Sunday, September 7, 2014 10:41 PM
    Sunday, September 7, 2014 10:41 PM
  • Then you need to tell us what the purpose of this is.  So far I see no reason for what you are doing.

    ¯\_(ツ)_/¯

    I want the script not to accept latest data entered. As it is; If you enter without any data input, you will get the info about previous data, so you will have the wrong info ok?

    Really  I am having a difficult time to explain properl now :(


    \_(ツ)_/ twitter.com/serdaruzun

    Sunday, September 7, 2014 10:45 PM
  • P.S. - Command History is not "command buffer".  You cannot manage the commend buffer in CMD.EXE.


    ¯\_(ツ)_/¯


    You say, there is no way to clear the command cache :( P.S good but we have to use Bat for a while

    I am really so sory to hear there is no way to remove cmd command cache :(


    \_(ツ)_/ twitter.com/serdaruzun

    Sunday, September 7, 2014 10:48 PM
  • I said noting about a cache. I said there is no way to clear the command buffer in batch.  YOu can clear it in PowerShell.

    I do not think that is your problem.  It is a coding issue.


    ¯\_(ツ)_/¯

    Sunday, September 7, 2014 10:53 PM
  • Is this what you are trying to do?

    @echo off
    set /p PingPC=IP or HostName: 
    if [%PingPC%]==[] goto empty
    echo %pingpc%
    goto eof
    :empty
    echo no input
    :eof


    ¯\_(ツ)_/¯

    Sunday, September 7, 2014 10:57 PM
  • Is this what you are trying to do?

    @echo off
    set /p PingPC=IP or HostName: 
    if [%PingPC%]==[] goto empty
    echo %pingpc%
    goto eof
    :empty
    echo no input
    :eof


    ¯\_(ツ)_/¯

    Nope, your script is for one-time use. It should be reusable by not closing

    \_(ツ)_/ twitter.com/serdaruzun

    Monday, September 8, 2014 9:14 AM
  • My script is to show you how to do this.  It is up to you to adapt it to your own script. I am showing you that your problem has nothing to do with command history or any kind of "memory".  It is only due to a lack of understanding of how to write a prompt and how to decide whether it has been answered or skipped.

    The piece of script shows how to do this.


    ¯\_(ツ)_/¯

    Monday, September 8, 2014 10:35 AM
  • My script is to show you how to do this.  It is up to you to adapt it to your own script. I am showing you that your problem has nothing to do with command history or any kind of "memory".  It is only due to a lack of understanding of how to write a prompt and how to decide whether it has been answered or skipped.

    The piece of script shows how to do this.


    ¯\_(ツ)_/¯

    I wanted to say that your way is not suitable for reusable ok?
    And also, what is the difference between my way and your way; you wrote nearly the same.
    My problem is the second usage of my script. 

    For you, I will record a video and send its link to you to understand me...


    \_(ツ)_/ twitter.com/serdaruzun

    Monday, September 8, 2014 7:00 PM
  • If you run a batch script and it ends there is nothing remembered unless you create a permanent variable using SETX or you save to a file.

    The issue with your batch wscript is that you have bad code.  The IF that you are using is wrong.  It does not do what you think it does.

    This line aslo does not make much sense:

    start "%PingPC% nolu PC icin Ping Kontrolu Yapiliyor" cmd /c "ping %PingPC% -w 10 -t" ^& start doskey /reinstall ^& pause

    Perhaps it would be better if you could just explain what you are trying to do instaead of complaining about some unknow thing having a memory.

    What are you trying to do?


    ¯\_(ツ)_/¯


    • Edited by jrv Monday, September 8, 2014 7:19 PM
    Monday, September 8, 2014 7:18 PM
  • Is this what you are trying to do?

    @echo off
    
    :PingCheck
    
    set /p PingPC=IP or HostName: 
    if [%PingPC%]  NEQ [] goto pingit
         @echo You did not enter anything. Try again
         goto PingCheck
    
    :pingit
    ping %PingPC% 
    echo %errorlevel%
    if %errorlevel% EQU 0 echo ping succeeded
    if %errorlevel% EQU 1 echo ping failed
    goto PingCheck
    


    ¯\_(ツ)_/¯

    Monday, September 8, 2014 7:36 PM
  • Please Never Mind how muck my script functional or sense. I GAVE AN EXAMPLE SCRIPT...!

    PLEASE WACTH THIS VIDEO, ONLY FOR YOU...! ONLY TO UNDERSTAND ME.

    GIVE UP CALLING PEOPLE AS AN IGNORANT PLEASE. 

    If I am not able to tell you my problem properly, does this mean I'm stupid? Your every sentence has revilement. Insted of answering questions, You always twist the subject, and you begin to say: Your script is nonsense, etc ...... My problem is not about script. My problem is a part of cmd command in a script. 

    I'm really tired.You harassed me. I dont want to deal with you.

    FORGET MY PROBLEM PLEASE AND DONT ANSWER ANYTHING ABOUT MY QUESTIONS, I BEG....


    \_(ツ)_/ twitter.com/serdaruzun

    Monday, September 8, 2014 8:22 PM
  • Hah! Nothing to do with memory.

    You are aski9ng how to clear an "environment  variable".

    Simple:

    Set PingPC=

    That is hwo we clear or remove a variable.  I also notice that you like to put spaces around your equal signs.  Don't.  It doesn't work as expected.

    Do this
    SET VAR=something

    DO NOT DO THIS

    SET VAR = something else

    Watch:

    C:\scripts>SET VAR=something
    C:\scripts>if [%var%] == [something] echo match
    match

    Now this:

    C:\scripts>SET VAR= something
    C:\scripts>if [%var%] == [something] echo match
    something] was unexpected at this time.


    ¯\_(ツ)_/¯

    Monday, September 8, 2014 9:10 PM