![]() That is :LOOPĪlternatively, you could swap the test around and avoid the goto CONTINUE altogether. This is not clear cut, but some people find it easier to read if the else is omitted when the if side breaks, returns, or otherwise interupts the control flow. I just found it slightly jarring, and thought I'd mention it. ![]() Obviously it makes no difference to the script, and it's not something that a pure batch programmer would trip over. Personally, I would not have called it 'CONTINUE' because in many C family languages continue would continue with the next iteration of a loop, rather than break out of it. Obviously this depends on the language that the executable is written in having good string manipulation capabilties, but it would help protect against deleting whole folders and other such disasters. Because the use case of this batch file is that it's created by the executable that wants cleaning up, that executable could do the text substitution and put its own filename directly into the relevant code of the batch file. There's an alternative here, which is a bit of a cheat but worth mentioning as potentially safer in some cases. A comment saying that it pulls out the name and extension would be appreciated. Likewise filename manipulations ( %~nx1 and such) will always be arcane. Because you already have looping code checking for the process, this should be as simple as removing the line.įor example, I understand that PING -n 6 127.0.0.1>NUL is a fairly common delaying tactic, but it's still downright odd if you haven't seen it before. That way we can be sure the calling executable is done with everything else, including releasing any resources it's holding. It makes sense that you might want to do this, but I expect the file would be more useful if it waited for its calling program to end on its own. The IF "%filename%"="" GOTO:EOF is very important because if the first parameter isn't defined then DEL /F "%~f1" will automatically act like a * is there and try to delete the contents of the whole folder. I figured the easiest way to get the path of the calling program is to just have it passed in as a parameter. TASKLIST | FIND /I "%filename%" >NUL 2>&1 ![]() Make sure you copy the batch file before you test it because it will delete itself! OFF This is particularly useful for an NSIS installer because the batch file can be embedded in the exe and then extracted. And obviously I want to see if it can be improved upon, of course. So what if there was a general-purpose batch file that deletes the calling executable and then deletes itself? I couldn't find such a batch file so I made one, thinking maybe it could be useful to others. However, a batch file can delete itself, presumably because its contents get copied so the file can close before the code gets run. An exe can't delete itself because an exe can't be deleted while it's running. HDMI contains no volume information: volume control is the responsibilty of the device that renders audio, eg, the monitor, TV etc.There are times when I want to run a one-off executable on an end-user's machine that cleans up after itself, i.e. Apple no longer allows 3rd party apps to see or view AirPlay devices If you have headphones physically plugged in then your internal speakers are disabled for some Apple hardware. It does not support AirPlay or AirPlay 2 devices.ĪudioSwitcher is ideal if you have multiple sound devices attached to your Mac and want to be able to switch between them without having to use System Preferences. You can quickly change the sample rate or output to multiple devices at the same time.ĪudioSwitcher supports any device directly attached to the host system: USB, DisplayPort, HDMI, Thunderbolt and Bluetooth. In addition you can change the volume and other properties of each device without having to change your current input / output. AudioSwitcher is a menu bar that allows you to switch quickly between all available input and output devices.
0 Comments
Leave a Reply. |