How do I open a Notepad text file with my batch file?

Attached is my batch file (in .txt because EE won't accept .bat).  It will open the first text file, but then wait for me to close it before opening the second...

How do I fix my script so that it opens both Notepad text files instead of waiting for me to close the first one before opening the second?
Open-Logs.txt
LVL 1
shaolinfunkAsked:
Who is Participating?
 
Bill PrewConnect With a Mentor Commented:
Try the following:

@Echo ON

SET YEAR=%date:~10,4%
SET MONTH=%date:~4,2%
SET DAY=%date:~7,2%

Copy NUL "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%P.txt"
Copy NUL "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%E.txt"

START "" NOTEPAD.EXE "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%P.txt"
START "" NOTEPAD.EXE "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%E.txt"
 
0
 
Steve KnightIT ConsultancyCommented:
Hi,

Use START "" in front.  That starts a new process for the notepad.exe rather than waiting for it to finish.  If you want the first to start, then the second and the batch to wait leave the START "" off the second.  The "" is the window title so just leave it at "".

hth

Steve

@Echo ON

SET YEAR=%date:~10,4%
SET MONTH=%date:~4,2%
SET DAY=%date:~7,2%

Copy NUL "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%P.txt"
Copy NUL "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%E.txt"

START "" NOTEPAD.EXE "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%P.txt"
START "" NOTEPAD.EXE "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%E.txt"
 
0
 
Steve KnightIT ConsultancyCommented:
Damn tha explanation I typed :-)
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Bill PrewCommented:
You can explore the syntax and options of the START command further with START /?.  In it's default mode it will start the program you tell it, and not wait for it to finish before continuing on with the BAT file.

~bp
0
 
Steve KnightIT ConsultancyCommented:
BTW Would sugest you use %userprofile% instead of :\\Documents and Settings\Administrator\, i.e.

START "" NOTEPAD.EXE "%userprofile%\Desktop\Logs\%YEAR%-%MONTH%-%DAY%E.txt"

Steve
0
 
Bill PrewCommented:
Finally, it's been days, no weeks, since I beat Steve on the trigger.  Darn mobile experts!  :-)

~bp
0
 
Bill PrewCommented:
I also notice that you have an extra backslash in these lines:

Copy NUL "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%P.txt"
Copy NUL "c:\\Documents and Settings\Administrator\Desktop\Logs\%YEAR%-%MONTH%-%DAY%E.txt"

Steve's comment about leveraging the %userprofile% environment variable is a good one too, as long as our assumption that you are logged in as the local Administrator is valid.

~bp
0
 
Steve KnightIT ConsultancyCommented:
Sorry Bill, not actually here much, we must just clash time wise..... not sure I even want to be "Sage" or even what one is apart from something you have with Onions... but something is making me keep trying!
0
 
Bill PrewCommented:
Goals are important little motivators, even the somewhat "meaningless" ones...

~bp
0
 
Bill PrewCommented:
Just as a suggestion, here's a slightly leaner version...

@ECHO ON

SET YEAR=%date:~10,4%
SET MONTH=%date:~4,2%
SET DAY=%date:~7,2%
SET STAMP=%YEAR%-%MONTH%-%DAY%

FOR %%A IN (P E) DO (
  COPY NUL "c:\\Documents and Settings\Administrator\Desktop\Logs\%STAMP%%%A.txt"
  START "" NOTEPAD.EXE "c:\\Documents and Settings\Administrator\Desktop\Logs\%STAMP%%%A.txt"
)
0
 
shaolinfunkAuthor Commented:
that does the trick, thanks!
0
 
pitonsCommented:
Hi
Put both notepad's on one line and add "|" between them
add "start /b before every notepad.exe

see attach

and there you go!
Open-Logs-edited-.txt
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.