Tag Archives: microsoft

Detecting location of Visual Studio 2017 and 2019

A few years ago, I wanted to use Bazel to build an old project of mine using Visual Studio 2017 Community.

Thing is, I don’t install most of MSVS on my system partition, as it’s on a relatively tiny SSD. So, where do I (portably) find it? And how do I set BAZEL_VS (per their documentation) to the correct path?

As I’m much more comfortable writing Bash scripts than writing old DOS-style Batch scripts, and as I’m going to have msys64 (or at least msys32) on my machines, clearly the answer is to write the resulting launcher in Bash. There are downsides to this approach, but it’s doable.

Do you even need this for Bazel?

No. I just tried running bazel-2.0.0-windows-x86_64.exe with my project. It found MSVS2019 out of the box both in cmd.exe and in the MSYS64 shell.

Unfortunately, I have a genrule that depends on bash, which didn’t work in cmd.exe even if I specified BAZEL_SH (missing binary for basename). And when I didn’t pass BAZEL_SH while running under MSYS64, it had trouble finding SDL/SDL.h presumably because the aforementioned genrule didn’t work.

Autodetection of MSVS2019 works, just set PATH Windows envvar to include msys binaries, and set BAZEL_SH Windows envvar to the output of cygpath -w /usr/bin/bash or cygpath -w /bin/bash.

You may want this for non-Bazel uses.

Finding Microsoft Visual Studio 2017

Assuming Bazel 2.0.0 is installed in C:\bazel under the default filename from the release on Github, this does the trick:

#!/bin/bash
# Based on https://superuser.com/a/539680 + searching around registry.
# Finds MSVS2017.
# Slashes when invoking 'reg query' are replaced with dashes because MSYS2.
VSPATH="$(cygpath -u "$(reg query 'HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7' -v 15.0 | tail -n+3 | head -n1  | awk '{for (i=3;i<=NF;i++) {printf "%s ",$i;};}' | sed 's/ *$//')")"

export BAZEL_SH="$(cygpath -w /usr/bin/bash)"
export BAZEL_VS="$VSPATH"

/c/bazel/bazel-2.0.0-windows-x86_64.exe $@

Finding Microsoft Visual Studio 2019

Unfortunately this is broken as of MSVS2019. See the explanation why that registry key is not used anymore.

The new situation is better: there’s a tool that does get installed in a well-known path: %ProgramFiles(x86)%/Microsoft Visual Studio/Installer/vswhere.exe.

The problem is merely that Bash doesn’t like parentheses in environment variable names, so ${ProgramFiles(x86)} won’t be acceptable. However, it was visible in env output! Other people have spotted the same thing, but as their writings talk about PROGRAMFILES(X86) in all caps, I’ve concluded that maybe it’s better to add the I flag to their sed-based solution.

#!/bin/bash
# Let's use VSWhere:
PROGRAMFILES_X86=$(env | sed -n s,'^PROGRAMFILES(X86)=',,pI) # because parens are not valid envvar names: http://mingw-users.1079350.n2.nabble.com/msysGit-bash-and-PROGRA$
VSWHERE=${PROGRAMFILES_X86}/Microsoft\ Visual\ Studio/Installer/vswhere.exe
VSWHERE="$(cygpath -u "${VSWHERE}")"

# Finding VC: https://github.com/microsoft/vswhere/wiki/Find-VC
VSPATH=$("${VSWHERE}" -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)

export BAZEL_SH="$(cygpath -w /usr/bin/bash)"
export BAZEL_VS="$VSPATH"

/c/bazel/bazel-2.0.0-windows-x86_64.exe $@

VSCode

The problem with using Bazel integration into VSCode is that it wants a path to Bazel. But Bazel wants to have BAZEL_VS set.

Maybe I could work around this by writing a tool in a compilable language, then have it pass on all CLI arguments to actual bazel.exe, while also setting BAZEL_VS. Or maybe Bazel supports some settings in .bazelrc. I didn’t care to check. Instead, I’ve used msys2_shell.cmd as the ‘shell’ for the integrated VSCode terminal. I’m used to manually running Bazel and I don’t care enough about interactive debugging. For now, I just don’t care enough to properly integrate Bazel into VSCode on Windows (though it would be neat).

Why even bother with Windows?

I need to trivially compare networking traffic between my project and a third-party program. The third-party program is written for Windows; it would likely work on other platforms under Wine, but I don’t care enough to explore whether I can make a third-party binary patcher for that program work under Wine.

My program still works on Linux, built whether with Bazel or using Makefiles; but the deprecated SDL 1.2 was recently broken on macOS, my program won’t work on macOS.

Getting this to work is also a nice exercise.

Windows Product Activation – "significant hardware changes"


I’ve just had a run-in with deactivation of Windows XP due to “significant hardware changes since the copy was last activated”. But, since I installed XP, the only thing I did was remove 512MB of RAM in the laptop, and install 1GB of RAM. I also plugged in the USB mouse during the bootup.

What probably triggered it, however, was changing filesystem of the system partition from FAT32 to NTFS using Microsoft’s own convert.exe, included with Windows. I have no idea where they’re pulling out the idea that filesystem of root system partition is a hardware thing.
I have no idea if this reactivation ate one of my activation slots for this product key, since Microsoft’s Knowledge Base link on the subject appears down. I surely hope I won’t have to deal with tech support; I’ve heard they’re friendly and unintrusive in Croatia, but still…
(By the way, unusually for tech-savvy Croats, this is a legit copy. From MSDNAA and FER, of course 🙂
Since there’s no way I could have captured the messagebox that appears during login (this isn’t a VM and I don’t have a good camera) included is just a leftover shot of WGA, after repeated activation.

Slow logoff in Windows XP – hang on "Saving your settings"

If you have problems with Windows XP logging off — that is, the system inexplicably decides to wait for about a minute before it proceeds with log off or shutdown — you may want to give Microsoft’s UPHclean – User Profile Hive Cleanup Service a spin. It just helped me with this problem that was harassing me for the past full calendar year.

It installs as a service so it’ll keep working.
Now, I wonder why this service is not included in Windows themselves, or at least in a service pack – why ship a broken OS?

Windows XP EULA is quite complex

And don’t let anyone tell you otherwise. You have to read between the lines letters. Each simple Latin letter, each simple glyph in fact consists of such fractal-like complexity that each one can stand for itself and tell the world a story of biblical proportions.

Behold:

test

Word 2007 has a very low memory footprint?

With two open documents (admittedly, no pictures) Word 2007 took only 2MB active memory, and 16MB virtual memory, according to task manager. Sounds to me like Microsoft should give up on working on OSes and development environments.

Why? Last few days was a torture for me, trying to handle Firefox (300-500MB VMem), Visual Studio (regularly 400-500MB VMem) and Windows Live Messenger (50MB) at the same time. On a laptop with 512MB RAM, and paging file on a very fragmented volume. Admittedly I ran only WLM during last evening, but still, even without it it was a horrible experience.

Worst part of all? Mozilla’s Firefox 3.5 is supposed to be fastest and lightest (and according to some test, it does take least memory). But if after several hours of work it cannot release the resources, someone’s done their job in a very sloppy manner. I have only Blogger open at the moment, and Firefox’s RAM usage is 294MB and VMem usage is 476MB. And I restarted it about an hour ago, and in the meantime I was studying from a PDF file, not surfing (effective surfing time? about 10-15min) What went wrong there?

Sounds to me like many many MS and non-MS teams could learn some lessons from Word 2007 team. Even UI design: once you get over the initial shock of the Ribbon interface, and once you understand it’s a very intelligent substitute for a toolbar, not menu, you can handle it. But that’s another topic, and I’ll say a few words later on. Who knows? Maybe in a few years someone will go and dig this blog’s archives out.

Microsoft's trolling of Firefox

Although Firefox did make it personal, what Microsoft just did by starting another Get the Facts campaign is shamelessly full of lies.

Claim 1: Internet Explorer 8 takes the cake with better phishing and malware protection, as well as protection from emerging threats.

Personally I enjoy protection built into Firefox . As far as I know it’s provided by Google, and it works great.

Claim 2: InPrivate Browsing and InPrivate Filtering help Internet Explorer 8 claim privacy victory.

Chrome doesn’t have this? What about Chrome’s anonymous browsing?

Claim 3: Features like Accelerators, Web Slices and Visual Search Suggestions make Internet Explorer 8 easiest to use.

Accelerators are annoying me: I select the text I read to concentrate easier. Web Slices don’t work for me. And what the hell are Visual Search Suggestions?

Claim 4: It’s a tie. Internet Explorer 8 passes more of the World Wide Web Consortium’s CSS 2.1 test cases than any other browser, but Firefox 3 has more support for some evolving standards.

It’s nowhere near a tie. You’re getting there, IE, but don’t lie.

Claim 5: Of course Internet Explorer 8 wins this one. There’s no need to install tools separately, and it offers better features like JavaScript profiling.

Yes, yes, Microsoft, interesting. Now how do I see AJAX requests and how do I run YSlow? Nobody approached Firebug with this. And nobody can claim that their browser is superior because it’s shipping developer tools built-in because nothing can approach Firebug here. And besides, Mozilla could just bundle Firebug and solve their problem.

Claim 6: Only Internet Explorer 8 has both tab isolation and crash recovery features; Firefox and Chrome have one or the other.

Chrome restores my pages very well, thank you very much.

Claim 7: Sure, Firefox may win in sheer number of add-ons, but many of the customizations you’d want to download for Firefox are already a part of Internet Explorer 8 – right out of the box.

Why does Chrome have a tick for customizability? It’s not customizable, period. And again, addons are addons and if IE’s got stuff out of the box … then those are not addons, they’re built in stuff.

Claim 8: Internet Explorer 8 is more compatible with more sites on the Internet than any other browser.

[citation needed] In other words — “what you say?” (somebody set us up the bomb, perhaps?)

Claim 9: Neither Firefox nor Chrome provide guidance or enterprise tools. That’s just not nice.

Don’t provide guidance? Perhaps they don’t need guidance. Enterprise tools? What the frakk? Define enterprise tools and why does home user need them.

Claim 10: Knowing the top speed of a car doesn’t tell you how fast you can drive in rush hour. To actually see the difference in page loads between all three browsers, you need slow-motion video. This one’s also a tie.

Performance of browser is not the same as time needed to achieve stuff with the browser. That said, my personal experience says IE8 can’t measure even closely to Firefox 3, and the distance to Chrome, Opera 9, Opera 10 and Firefox 3.5 is even greater. No, Microsoft, it’s not a tie. FF and Chrome deserve a tick, but IE does not.

Now their MythBusters section:

That’s why our Accelerator, Web Slice, Smart Address Bar, and Visual Search features make it faster, safer, and easier than ever for you to do what you need to do on the Web, giving you an overall better experience.

As already said Accelerators are annoying, Web Slices don’t work for me at all, Smart Address Bar — do they mean what Chrome did perfectly, and Firefox almost perfectly, and what IE is just poorly emulating? And again, what the hell is Visual Search?

Are they honestly trying to push all those suboptimal solutions as superior solutions?

My 0.02 cents (that is, 0.0002 EUR) that contribute to the hell that is the intarwebz.