VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 18 of 18
Thread
  1. I need to do the following:

    http://stackoverflow.com/questions/15380551/paste-but-dont-execute-command-in-windows-command-prompt
    (I copied the text from the site, so it is here even it isn't available anymore on the site, who knows)


    My target is to show the Windows command prompt and display a command on the command line without executing it. Therefore, if I want to display the command echo Hello, I want the command prompt to be started and display:
    Code:
    C:\Windows\System32>echo Hello_
    ... where _ is the blinking cursor waiting for the user to press a key.
    To accomplish this, I've tried either to create a shortcut to the Windows command prompt executable, that has its "Target" changed to:
    Code:
    C:\Windows\System32\cmd.exe ...
    or a bat file containing:
    Code:
    cmd.exe /k ...
    ... where /k stands for:
    Code:
    /k : Carries out the command specified by string and continues
    This makes the command prompt continue to live and not terminate the way the /c switch acts.

    Any idea how to achieve this result?
    Quote Quote  
  2. You just need to make it look like a command line? Or does the user actually need to be able to edit the command line?

    For the former you can do something like:

    Code:
    @echo off
    echo|set /p =%CD%^\echo Hello
    pause >nul
    echo .
    echo Hello
    I couldn't figure out how to echo the > character so I used \ instead.
    Last edited by jagabo; 16th Feb 2016 at 09:36.
    Quote Quote  
  3. I need to start cmd.exe in a bat file and the command or string after ">" should be inserted but it should only be pasted, not executed.
    for example "stringtest" should be inserted:
    Code:
    C:\Users\Name>stringtest
    Quote Quote  
  4. my bat file looks like that:
    Code:
    start "Testprogram" /max %windir%\system32\cmd.exe
    Quote Quote  
  5. You can't do that inside a batch file, you would need to remove the carriage return from the line. There are hacks that remove characters from a line, but they only work while parsing that line and that only happens because of the carriage return. Like Jagabo demonstrated, you can simulate the effect. This code will show the command on a normal looking command line and it will execute it when the user hits enter:

    Code:
    @echo off
    prompt $p$g$secho$shello
    PAUSE >nul
    prompt $p$g
    cls
    echo hello
    It's a lot easier to do with CMD than it was with DOS.
    Quote Quote  
  6. Originally Posted by jagabo View Post
    the user actually need to be able to edit the command line?
    It should be editable. Is that possible?
    Quote Quote  
  7. Originally Posted by nic2k4 View Post
    You can't do that inside a batch file, you would need to remove the carriage return from the line. There are hacks that remove characters from a line, but they only work while parsing that line and that only happens because of the carriage return. Like Jagabo demonstrated, you can simulate the effect. This code will show the command on a normal looking command line and it will execute it when the user hits enter:

    Code:
    @echo off
    prompt $p$g$secho$shello
    PAUSE >nul
    prompt $p$g
    cls
    echo hello
    It's a lot easier to do with CMD than it was with DOS.
    Thank you for the code, but I think I don't get it how to use this code. Can you please help me?
    Quote Quote  
  8. Editable like what? You should be able to use SET /P to have your user input something. Give me some details as to what you're looking to do and I'll see what I can do.
    Quote Quote  
  9. I want to start a program with a bat file containing:
    Code:
    start "program" /max %windir%\system32\cmd.exe
    The opened cmd window shows
    Code:
    C:\Users\Name>
    I want the cmd window to display:
    Code:
    C:\Users\Name>stringtest
    -> I want to add a command like
    Code:
    stringtest
    like it was already typed in which is editable and is of course not executed.

    For example
    Code:
    ipconfig -all
    or any other command can be used instead of
    Code:
    stringtest
    Quote Quote  
  10. This will allow the user to add parameters to ipconfig but not change ipconfig to something else:

    Code:
    @echo off
    set /p userinput=%cd%^>ipconfig 
    ipconfig %userinput%
    I don't see any way to pre-fill the command line then execute whatever it has changed to after the user has edited it.
    Quote Quote  
  11. there are two problems I think, but I'd be happy to be wrong,.., just narrowing it down what you are trying to do, so there might be someone who reacts more easily if I am wrong ...

    -there cannot be just line written and just wait for user input to execute it, there is always a sort of prompt, asking user what to select/or type something but point is,..... that a new batch script line written by programer executes things, one just cannot switch from running batch script line by line to manual cmd.exe prompt window
    (perhaps that VBScript allows that using that SendKeys)

    -that new prompt/or batch and original batch cannot just run independently. That calling cmd/batch has to exit first so that first one continues
    Quote Quote  
  12. I think there is no way to do it with a *.bat file but I got it with a Visual Basic Script. It seems, I must be more open for other script languages. I think I must also take a look at powershell ... very impressive
    Quote Quote  
  13. yes, and one can generate a basic GUI's etc
    using batch and wanting user to fix a line or even a menu or something I use notepad to popup a text file, user can edit that and then save it, cancel notepad window and batch script continues its script checking/parsing that notepad file ...
    Code:
    START /WAIT "%path_notepad%" "title.ini"
    Quote Quote  
  14. I'm glad you found something that works. However what you are asking to do loses it's usefulness when you start replacing the previously typed command. I can see editing the command line before executing it to change/enter parameters. It's trivial using SET /P as Jagabo demonstrated. You could even make a menu to select different functions and minimize typing. Replacing the typed command is doable, but will require checks before executing making the batch a lot more complicated.
    Quote Quote  
  15. But you are thinking small , small edits, limited inputs, as soon you start to think big, that could be handy, that notepad sum up pop up. Definitely batch is wrong language for that, make no mistake, if knowing VBscript or other real language it could have nice GUI, but imagine doing something that start as small utility and in years ending up as for example Blu-Ray back up system. Suddenly you realize that works just fine, not like you have to share it with someone that needs neat GUI and golden button that says START. So you have a command line utility for backing up and encoding Blu-Ray. Then after loading BD you can end up seeing this:
    Code:
    Title 1) 
     
    MKV name              :The Judge 
      
    -------------------------------------------------------------------------------------------------------
    1: Chapters, 15 chapters 
    -------------------------------------------------------------------------------------------------------c:1_1_Chapters.txt
      
    -------------------------------------------------------------------------------------------------------
     h264/AVC, 1080p24 /1.001 (16:9)  (eac3to info)
     avc, 1920x1080, progressive, 23.976fps, 16:9 (mediainfo)
    -------------------------------------------------------------------------------------------------------v:1_2_Video.*
    2: name               :
    2: copy track         :
    2: encode track       :yes
    2: Avisynth script: 
      
    Spline36Resize(1280,720) 
      
    2: autocrop           :yes  
    2: w_integer          :4   
    2: h_integer          :4  
    2: x264 cmd line      :--log-level error --crf 18 --ref 6 --vbv-bufsize 30000 --vbv-maxrate 30000 
      
    -------------------------------------------------------------------------------------------------------
     DTS Master Audio, English, 5.1 channels, 16 bits, 48kHz
     (core: DTS, 5.1 channels, 16 bits, 1509kbps, 48kHz)
    -------------------------------------------------------------------------------------------------------a:1_3_Audio_English_dtsma.DTSHD
    3: name               :
    3: copy track         : 
    3: extract core       :yes 
    3: encode track       :  
    3: eac3to cmd line    :-640 -down6 -down24  
      
      
    -------------------------------------------------------------------------------------------------------
     Subtitle (PGS), English
    -------------------------------------------------------------------------------------------------------s:1_8_Subtitle_English_PGS.sup
    8: name               :
    8: copy track         :  
    8: encode track       :yes  
    8: BDsuptoSUB options :/res:auto /fps:auto /filter:lanczos3
    where you can edit default values after that colon character or avisynth script and batch makes MKV. To manually adjust every single item would not be digestible.
    Quote Quote  
  16. Yep, you are right batch file is not the best language to do anything elaborate. I'm not saying it can't be used, it just works better with limited parameters and well defined inputs. I'm guilty of trying to use batch files for crazy stuff, but that's just 'cause I enjoy pushing it.

    Your batch file does give you a nice customized log for your backups. As you mention sharing, one big issue with batch files is they often fail on other language windows. I made a nice pure batch routine to detect which drive contains a CD and save the drive letter. Worked perfect on a US windows, not on UK windows. We ended up using a small external program to set the variable.
    Quote Quote  
  17. I try to avoid all %windir%\system32\notepad.exe but using concrete C:\Windows\System32 instead or to avoid %temp% and all these defaults or getting drive letter. So old fashion INI file is used where it is set up by user first time or after PC is changed. Like you did. Drive letter is a part of command line (it could be just a file).

    Also all inputs has to go through character check, that is most challenging to troubleshoot all inputs and get warnings to prevent illegal characters to enter batch script. Some characters cannot be used in a file path, some in filename while handling in batch , some for Avisynth etc. You are right it is a just a fun.
    Quote Quote  
  18. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    It is fairly easy to program a test box as Pseudo CMD (DOS) window and you can update/enter/change/etc. and then execute manually or program wise. I'm not sure if this would work but it would be better in most cases than a CMD script, especially for updating before execution efforts.

    Click image for larger version

Name:	ScreenHunter_197 Jun. 22 23.06.jpg
Views:	345
Size:	39.3 KB
ID:	37475
    Quote Quote  



Similar Threads