2015-07-14

Solved: cannot eject USB device: "This device is currently in use."

Millions of people all over the planet continuously have this problem: they try to eject their USB drive so as to avoid data loss, but windows does not allow them.  Which is very frustrating, because whatever reasons windows thinks it has for not allowing the removal should have lower priority than the user's explicitly stated direct wish to remove the damned thing!

Anyway, suggestions for solutions abound on the interwebz.  Here are some that I found with a quick search:

1.  Put your computer to sleep.  When going to sleep, Windows flushes all buffers to all devices, so while the computer is asleep, it is safe to remove the device.  The problem with this approach is that I don't want to have to put my bloody computer to sleep each time I want to take a USB device out.

2. Use SysInternals Process Explorer to search for the drive name, find which process has a handle open on the drive, and terminate it.  The problem is that drive names are only one a letter and a colon, a search for "D:" may yield thousands of handles from several dozen processes, all of which are unrelated to your drive "D".  Unfortunately, Process Explorer does not offer any option to search for a whole word only.  Another problem is that this approach hardly ever works.  Apparently, there are ways in which devices can be locked which do not show in Process Explorer.  Even if you remember to launch it as Administrator.

3. Select "Quick removal" policy as opposed to "Better performance" policy in the drive properties. The problem with this is that it is not really a solution: we generally do specifically want the better performance, and we are willing to sacrifice quick removal for it, accepting slow removal instead. But this issue is not one of slow vs. fast removal, it is about not being allowed to remove your device at all, ever!

Here is the solution which worked for me, after the above failed:

4. Make sure that the drive, or any folders in it, are not shared on the network!  (Use "NET SHARE" on the command prompt to quickly find out what you are sharing.)

Solved: The network folder specified is currently mapped using a different user name and password

So, I am on computer A, trying to map a local drive to a shared folder of computer B, and Windows gives me this message: "The network folder specified is currently mapped using a different user name and password".  

Microsoft supposedly addresses this issue here: https://support.microsoft.com/en-us/kb/938120 and concludes that it is so by design.

Bullshit.  They are missing the point.  The error message is wrong.  The network folder specified is not currently mapped using a different user name and password. Instead, what is happening, is that another folder of the same computer B is already mapped on computer A using a different user name and password. 

So, apparently, with windows, if you connect from computer A to any share of computer B, then all subsequent attempts to connect from computer A to other shares of computer B must be done using the same credentials.  Go figure.

2015-07-13

The GWX (Get Windows 10) KB3035583 trojan horse

So, Microsoft has pushed this trojan horse to every single user of Windows on the planet.  It displays a Windows 10 logo on the taskbar, and it is basically telling you that not only you will get Windows 10 as soon as it comes out, but you should right now begin acting as if you are looking forward to it. Because, you know, you are their biatch.

So, let's see:  a) GWX installs on your machine without your consent; b) once installed, you cannot "quit" it or "exit" it; and c) you cannot find it anywhere to uninstall it.  So, it fits squarely within the definition of malware.

GWX is delivered by means of an innocent looking optional update, KB3035583.  The update is designated as "Recommended", and its description says "Install this update to resolve issues in Windows. For a complete listing of the issues that are included in this update, see the associated Microsoft Knowledge Base article for more information."  (I am not making this up, that's exactly what it says, I suppose English is not their forte at Microsoft.)

Of course, with dozens upon dozens of updates each time you check, which give you no clue as to what they are about, and instead each one of them refers you to some web page for more information, you don't bother checking, and so you passively consent to this trojan horse being downloaded and installed on your computer.  If you click on "More information", you are taken to a web page which admits that update KB3035583 is nothing but an incredibly lame and stupid publicity stunt about the upcoming Windows 10.

And so, as it turns out, that bit about resolving issues in Windows was a fucking lie.

How to get rid of the KB3035583 trojan horse:

1. In Windows Update select Change settings, and make sure that "Give me recommended updates the same way I receive important updates" is unchecked.  This way, the fact that this is a "Recommended" update will not cause it to jump from the "Optional" updates list to the "Important" updates list.

2. In Windows Update select View update history, find KB3035583, and uninstall it.

3. In Windows Update click on "Check for updates".

4. In Windows Update go to Optional Updates, find KB3035583, and specify that you want it to be hidden.


And then in 2017 there is this:
betanews.com: Microsoft will never again sneakily force Windows downloads on users
(Though it is unclear to me whether this is about Germany only or the whole world.)

2015-07-09

Remote Desktop Connection quits without a word

So, I am firing up a remote desktop (RDP) connection, and the little box appears saying that it is trying to connect:


And then the box just disappears, without an error message or any other hint as to what might have gone wrong.

The interwebz abound with reports of this happening, and people asking how to fix it, and various solutions being offered that range from the complex to the hopelessly complex.

Luckily, every time I have encountered this problem, the solution for me was very simple: just wait and try again later.  The remote computer is probably busy booting, or perhaps booting and installing updates.

Now, I will tell you a little secret: when something goes wrong, software can ALWAYS give a meaningful error message.  If it does not, then someone, somewhere, is being either EVIL or INCOMPETENT.

If it could not find the server, it would have said that the server was not found.

If the server was not responding, it would have said that the server is not responding.

In this case, the server was actively refusing the connections, and someone at Microsoft was either so evil that they decided that in this specific case the software should not say anything, or, more likely, someone at Microsoft was so incompetent that they could not simply write their world-class software to give a meaningful error message in a very frequently occurring usage scenario.

Intel NUC5CPYH incompatible with Windows 7 Ulitmate 64 bit?

Intel advertises NUC5CPYH - (Celeron N3050) as being compatible with Windows 7.  It is not.  All my attempts to install Windows 7 Ultimate 64 bit on it failed.  The installation would start, and when it would reach the first interactive screen (language selection) the keyboard and mouse would be dead, (not even NumLock would work on the keyboard,) even though both keyboard and mouse work fine on the BIOS screens of the NUC.  On other occasions I managed to overcome this problem, (I don remember how,) and the installation would proceed to 99%, only to fail in the end with some error about not being able to update my computer's boot configuration or something.

Edit: be sure to read nucblog's comment below for a link to an article with instructions that might bring you more luck than I had.

In general, my overall experience of interacting with the BIOS of the NUC5CPYH was not pleasant at all.  The spiffy looking BIOS screens were not welcome by me, as they were not structured in the perfect logical order that I would expect of them, and certain parts of them were clunky.  Attempts to introduce an aesthetic upgrade which result in something technically more flawed than its ugly predecessor generally make a very bad impression, at least to me.

Perhaps the most annoying thing is that the initial screen with the prompts to press F2 to enter setup, F10 to enter the boot menu, etc. appears as if it requires not one, but two key-presses.  It probably requires only one, but there is an initial period of time during which if you press a key, that key is ignored, and that's extremely annoying.  Hey you, Intel BIOS programmers, I have a hint for you: if you are not ready to accept key-presses, do not display a prompt for them!

2015-04-30

On dogma in engineering

I once had a colleague who had a higher rank than me, and who was not only unconvinced by my rational and articulate arguments for doing a certain thing in a certain way, but he concluded the discussion by stating that --and I am not paraphrasing here, this is what he actually said-- the way he wanted it done was mentioned in a book, so unless I could find a book backing up my proposal, it was to be done his way.

I did not argue with him at that time, (how can you argue with that?), but I would now like to quickly jot down my thoughts on why saying such a thing is incredibly stupid:

Wow, 5 upvotes, 10 downvotes and counting

I have this answer on programmers.stackexchange.com which, at the time of writing these words, has 5 upvotes and 10 downvotes, and in all likelihood it will continue collecting downvotes, while I adamantly refuse to remove it, standing 100% by my ideas. I am dumbfounded, as such a thing has never happened before.

Here is the programmers.stackexchange.com question:

Is it okay to have objects that cast themselves, even if it pollutes the API of their subclasses?


I have a base class, Base. It has two subclasses, Sub1 and Sub2. Each subclass has some additional methods. For example, Sub1 has Sandwich makeASandwich(Ingredients... ingredients), and Sub2 has boolean contactAliens(Frequency onFrequency).

Since these methods take different parameters and do entirely different things, they're completely incompatible, and I can't just use polymorphism to solve this problem.

Base provides most of the functionality, and I have a large collection of Base objects. However, all Base objects are either a Sub1 or a Sub2, and sometimes I need to know which they are.

It seems like a bad idea to do the following:

for (Base base : bases) {
    if (base instanceof Sub1) {
        ((Sub1) base).makeASandwich(getRandomIngredients());
        // ... etc.
    } else { // must be Sub2
        ((Sub2) base).contactAliens(getFrequency());
        // ... etc.
    }
}

So I came up with a strategy to avoid this without casting. Base now has these methods:

boolean isSub1();
Sub1 asSub1();
Sub2 asSub2();

And of course, Sub1 implements these methods as

boolean isSub1() { return true; }
Sub1 asSub1();   { return this; }
Sub2 asSub2();   { throw new IllegalStateException(); }

And Sub2 implements them in the opposite way.

Unfortunately, now Sub1 and Sub2 have these methods in their own API. So I can do this, for example, on Sub1.

/** no need to use this if object is known to be Sub1 */
@Deprecated
boolean isSub1() { return true; }

/** no need to use this if object is known to be Sub1 */
@Deprecated
Sub1 asSub1();   { return this; }

/** no need to use this if object is known to be Sub1 */
@Deprecated
Sub2 asSub2();   { throw new IllegalStateException(); }

This way, if the object is known to be only a Base, these methods are un-deprecated, and can be used to "cast" itself to a different type so I can invoke the subclass's methods on it. This seems elegant to me in a way, but on the other hand, I'm kind of abusing Deprecated annotations as a way to "remove" methods from a class.

Since a Sub1 instance really is a Base, it does make sense to use inheritance rather than encapsulation. Is what I'm doing good? Is there a better way to solve this problem?

Tags: java, inheritance, type-casting
asked by codebreaker