Top-rated Batch recipes tagged "batch"http://code.activestate.com/recipes/langs/batch/tags/batch/top/2017-03-27T13:20:41-07:00ActiveState Code RecipesBatch Local Network Messaging System (Batch)
2012-02-03T01:41:41-08:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/578028-batch-local-network-messaging-system/
<p style="color: grey">
Batch
recipe 578028
by <a href="/recipes/users/4179768/">Alexander James Wallar</a>
(<a href="/recipes/tags/alex/">alex</a>, <a href="/recipes/tags/batch/">batch</a>, <a href="/recipes/tags/batch_file/">batch_file</a>, <a href="/recipes/tags/dos/">dos</a>, <a href="/recipes/tags/messaging/">messaging</a>, <a href="/recipes/tags/messenger/">messenger</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/wallar/">wallar</a>, <a href="/recipes/tags/windows/">windows</a>, <a href="/recipes/tags/wired/">wired</a>, <a href="/recipes/tags/wired_network/">wired_network</a>).
Revision 3.
</p>
<p>This is a Batch Local Messaging System that can be used to send messages between computers that share the same file system.</p>
<p>There are three files in the code below. They are separated with dashed lines. There is a comment on the top of each segment of code indicating the file name that the code needs to be saved as. They need to be saved as three separate batch files in the same folder. </p>
<p>The first file, MessengerMain.bat will ask you for your name and then an address. The name should be whatever you wish your screen name to be. The address needs to be the path of the FOLDER that is shared between you and the other computer that you are communicating with. Once these pieces of information are entered, two screens will appear. The first is the Sender screen and the other is the Receiver screen. </p>
<p>How does it work?
The MessengerMain.bat file will create two text files, Name.txt and Address.txt, that will hold your user name and the common folder address. It will then use the START command to run Sender.bat and Receiver.bat. Sender.bat will create a text file named msgtext.txt in the address folder you specified in MessengerMain.bat. If there is already a file of this sort in existence in the address folder, it will overwrite it. Once this file is created, any message you enter will be saved in the msgtext.txt file after the name you entered (%name%: %msg%). Sender.bat the CLS (clears) the screen and asks you for another message continuously. Receiver.bat is very similar. Receiver.bat, first off, reads the Address.txt file and the Name.txt file to find your information given in MessengerMain.bat just like Sender.bat does. It will count the number of lines in the msgtext.txt file and will clear the whole screen and print out the whole contents of the file if the number of lines in msgtext.txt increases. So basically you are writing to a shared file and reading from a shared file. </p>
<p>Example:</p>
<p>I have a folder called MSGFolder located in the folder as I have my MessengerMain.bat, Receiver.bat, and Sender.bat files. I then run MessengerMain.bat by double clicking on the icon. I enter Alex for my Name and MSGFolder as the Address. I then double click MessengerMain.bat again and enter the name Bob for Name and MSGFolder for Address. Once you do this you can type in either of the Sender.bat interfaces and it will show up as if you are talking. </p>
Timing a batch program (Batch)
2016-05-29T10:50:33-07:00Antoni Gualhttp://code.activestate.com/recipes/users/4182514/http://code.activestate.com/recipes/580670-timing-a-batch-program/
<p style="color: grey">
Batch
recipe 580670
by <a href="/recipes/users/4182514/">Antoni Gual</a>
(<a href="/recipes/tags/batch/">batch</a>, <a href="/recipes/tags/timing/">timing</a>).
</p>
<p>It uses %time% to time a function to the hundredth of second.</p>
Send and retrieve text to/from clipboard (Batch)
2016-05-27T09:56:56-07:00Antoni Gualhttp://code.activestate.com/recipes/users/4182514/http://code.activestate.com/recipes/580669-send-and-retrieve-text-tofrom-clipboard/
<p style="color: grey">
Batch
recipe 580669
by <a href="/recipes/users/4182514/">Antoni Gual</a>
(<a href="/recipes/tags/batch/">batch</a>, <a href="/recipes/tags/clipboard/">clipboard</a>).
</p>
<p>Sending uses the command line tool clip.exe that may not be available in Windows XP. There is no standard tool to retrieve from clipboard so I use javascript via mshta.</p>
Batch priority queue (Batch)
2016-05-26T11:00:21-07:00Antoni Gualhttp://code.activestate.com/recipes/users/4182514/http://code.activestate.com/recipes/580666-batch-priority-queue/
<p style="color: grey">
Batch
recipe 580666
by <a href="/recipes/users/4182514/">Antoni Gual</a>
(<a href="/recipes/tags/batch/">batch</a>).
</p>
<p>The fact the environment sorts itself by key allows us to implement a PQ using the prefix "queu" added to the priority value as a key</p>
File selector dialog in batch (Batch)
2017-03-27T13:20:41-07:00Antoni Gualhttp://code.activestate.com/recipes/users/4182514/http://code.activestate.com/recipes/580665-file-selector-dialog-in-batch/
<p style="color: grey">
Batch
recipe 580665
by <a href="/recipes/users/4182514/">Antoni Gual</a>
(<a href="/recipes/tags/batch/">batch</a>, <a href="/recipes/tags/directory/">directory</a>).
Revision 2.
</p>
<p>Runs mshta hidden to open a file dialog and get the path of the file selected. No parameters can be passed to the dialog.
EDITED: I did a subroutine with the snippet</p>