Dear fans of Win32Pad!
Here is a more nearly complete answer to the question how to make sure that only one instance of Win32Pad is running. The following batch file supplies the details. Beginners need not do anything of course except copy and paste the batch file text into Win32Pad, or even into NotePad if a person doesn't have Win32Pad up and running yet.
To bring up a copy of NotePad, hold down the WinKey and tap letter R. In the small window that pops up, press Delete, type in «notepad» (without quotes) and press ENTER (unless, of course the word NOTEPAD is already present for you in the run-window: in that case just tap ENTER.
After copying and pasting (and making sure that the copying did pick up the whole contents), save the file to the root directory of your drive (most conveniently a flash- or portable hard drive). Save the batch file (we suggest) under the name «GoW32Pad.bat».
Quit from Win32Pad or NotePad by holding down the ALT key and tapping F4.
@ echo off
if not exist \win32pad\win32pad.exe goto end
::
:: GoW32Pad.bat is designed to make sure that only one instance is run-
:: ning, anywhere on the operating system, of the program Win32Pad.exe .
::
:: GoW32Pad assumes you've installed Win32Pad.exe to N:\Win32Pad folder.
:: «\» means «root directory» and «N:» is the drive letter of the drive.
:: «Win32Pad» in «N:\Win32Pad» means the «Win32Pad» folder on the drive.
:: Modify if not line and start line to show correct path for YOUR case.
:: Whatever follows the initial «N:\» (if anything) is named the «path».
:: The goto end command will of course terminate this bat-file abruptly
:: if win32pad.exe isn't located in the N:\Win32Pad directory specified.
::
tasklist|find /i /c "win32pad.exe" > nul
::
:: «tasklist» is a function native to Windows (probably from Win2000 on).
:: It doesn't need a prefix for path to it. Type tasklist at any prompt
:: to see how it lists what is currently running on your Windows system.
::
:: Here, we pipe the list into find, where /i and /c mean «case insensi-
:: tive» and «count». If win32pad.exe is already running, find will say
:: so. The «> nul» masks what would otherwise be screen chatter that we
:: don't need. The set INSTANCE line captures the yes|no 0|1 errorlevel
:: («yes» is usually 1, but not in the case of %errorlevel% output with
:: MSoft's cmd.exe = formerly command.com). Goto already in case of «0».
:: %errorlevel% is a hidden feature that shows only if we make it do so
:: as we have here: by setting it = to a temporary environment variable.
::
set INSTANCE=%errorlevel%
if "%INSTANCE%"=="0" goto already
start \Win32Pad\win32pad.exe %1
::
:: «%1» is the name in batch-talk of the file you want to run or create.
:: GoW32Pad.bat WILL run Win32Pad.exe without a somename.ext, but we do
:: not recommend it because File, SaveAs won't be cued to the directory
:: from which you had run GoW32Pad.bat. If, however, you do supply file-
:: name: File, Save As WILL be cued up to exactly the current directory.
:: Current directory means the directory whose prompt you are typing at.
:: If creating a new file, W32Pd will ask if that's what you want to do.
:: The ask window is already cued up to Yes, so all you do is tap ENTER.
:: The typing area inside Win32Pad will of course be empty: get typing!
::
:: Run this batch file from the directory prompt where an existing file
:: is found OR where you want to create a new file. The syntax reads --
::
:: N:\Some_Directory>\goW32Pad somename.ext [ENT] -- Where GoW32Pad.bat
:: is assumed to dwell in the root directory of your drive named by «N:»
:: Be sure to include the backslash \ in front of goW32Pad somename.ext.
:: Notice how, in the start command above, we likewise supply backslash.
:: We purposely don't supply drive-letter N: since it varies by host PC.
:: On any host where you take your flash-drive a backslash will suffice.
::
goto end
::
:already
echo. & echo Win32Pad is already running somewhere.
echo. & echo Tap [spacebar] to end this batch file.
echo.
pause>nul
:end
set INSTANCE=
exit
To summarize: by running Win32Pad by means of the batch file above, only a single instance is allowed of Win32Pad anywhere on the host PC or workstation. Instead of the Win32Pad developers taking the time to build in this single-instance feature, the developers are able to turn their attention to whatever next version they may have time to provide.
mit herzlichem Gruß,
Roger
«Es macht keinen Sinn, daß die Kühe Milch geben —
Die Bauern nehmen sie ihnen einfach weg.»