|
Answer» I want to create a batch file that can write another batch file.
I know it is possible but when the new written file is opened the commands dont work because they are placed in a row for them to be able to be written. Here is an example of what i did.
Code: [Select]echo echo off title Program cls pause > file.BAT This code just makes a batch file (file.bat) with the same commands in one line, so if u run it, the commands won't work. Is there anyway i can make it so that the commands will work?
I was thinking that maybe there was some kind of COMMAND or character to indicate a new line? For example if /=a new line, my code would just look like this.
Code: [Select]echo echo off /title Program /cls /pause > file.bateither
Code: [Select]echo echo off > file.bat echo title Program>>file.bat echo cls>>file.bat echo pause > file.bat or
Code: [Select]echo echo off ^& title Program ^& cls ^& pause > file.bat FBYou want to have a drone batch file
Code: [Select]REM This is drone.bat %1 Then your code is:
Code: [Select]echo echo off title Program cls pause > file.bat drone file But it is not clea what you want to do. When run, file.bat bat just says:
Code: [Select]off title Program cls pauseIs that what you want?
fireballs got it. Thnx
I wanted the CMD window to be named program, the screen CLEARED and then it saying press any key to continue. This is not actually what im using this function for, but this is just a simple example.
Although i have 2 more questions. What exactly does this do ^& ? and Whats the simplest way to make someone wait for a certain amount of time?
If for example you save this as a batch file.
Code: [Select]echo off echo Hi ping localhost -n 5 > nul pause It will say hi, wait for 5 seconds and then display the 'press any key to continue' message. I was wondering if this was the proper way to do it.Instead of ping, there is a sleep program and other programs that wit some time for a key press. Don't remember what they are. Somewhere deep in my archives.
Here is one: http://malektips.com/xp_dos_0002.htmlYe that website just said there is no such 'sleep' command in XP unless you download a special pack. However you can simulate it with the ping command the way i was doing. :/ sucks. (btw, still waiting for the reply to my other question )
Quote from: PirateSamir on January 22, 2009, 02:08:15 PM Although i have 2 more questions. What exactly does this do ^& ? and
http://www.ss64.com/nt/syntax-esc.html
***Escape Character
^ Escape character. Adding the escape character before a command symbol allows it to be treated as ordinary text. When piping or redirecting any of these charcters you should prefix with the escape character: \ & | > < ^ e.g. ^\ ^& ^| ^> ^< ^^
In the Statement ...
Code: [Select]echo echo off ^& title Program ^& cls ^& pause > file.bat we are basically saying Echo text {ESCAPE} & (and now do this) Other command.
Hope this HELPS.
Quote from: nothlit on January 22, 2009, 02:28:03 PMwe are basically saying Echo text {ESCAPE} & (and now do this) Other command.
That's not true... we're saying echo [text] ignoring special characters because we've escaped them. without the ^ it would say
Code: [Select]echo echo off [then do this] title Program [then do this] cls [then do this] pause FB
Quote from: fireballs on January 22, 2009, 02:32:15 PM
Quote from: nothlit on January 22, 2009, 02:28:03 PMwe are basically saying Echo text {ESCAPE} & (and now do this) Other command.
That's not true... we're saying echo [text] ignoring special characters because we've escaped them. without the ^ it would say
Code: [Select]echo echo off [then do this] title Program [then do this] cls [then do this] pause FB
Oops ... I knew what I meant just wrote it wrong. oh ok, thnx guys.
Quote from: PirateSamir on January 23, 2009, 02:23:03 PMoh ok, thnx guys.
Didn't confuse you did I? I hope 'fireballs' cleared up my goof quick enough that you understand.
|