2

Long story short: I'm writing a shim for running custom privileged scripts with Windows' native shell. To test that, I'd like to have a set of custom-forged installations, one of which would involve the system installed to a non-standard location (i.e. not C:\Windows). That said, I can't figure out a way how to automate it - I've read pretty much everything on DISM, sysprep, SIM, PE and the only related thing I've stumbled upon is how to change default user profile directories (which I don't need). The worst part is that I remember being able to do so in the past - though I can't recall using what tools and how exactly in general.

Is such a thing possible or have I gone insane?

Windows 10 if that's relevant (10.0.16257+ to be more specific).

mataha
  • 23

1 Answers1

1

I can't find an official source stating this. But I've read in various places that this hasn't been supported since Vista (e.g. Dell forums, some other places I forget now). The old Windows installer used in Windows XP and earlier enabled you to specify the Windows installation directory, at least if you used an unattended installation file.

However, since Vista, it has used image-based installation (originally ImageX, nowadays DISM), and image-based installation doesn't support changing the %windir%. So it is necessarily hardcoded to C:\WINDOWS. Maybe the Microsoft internal tooling used to build the original installation image supports changing this, but in the image as shipped to customers it is fixed.

Back in the days of Windows 3.x and Windows NT, using a non-default Windows install directory (e.g. C:\WIN31 or even D:\WINDOWS) was a reasonably common practice, common enough that software vendors were expected to support it – and failing to do so (e.g. by hardcoding C:\WINDOWS instead of using %windir%) was considered a bug (albeit not an uncommon one).

But nowadays, it is a close to impossible configuration. And as a result, software developers have become lazy – likely including even Microsoft themselves – and started hardcoding C:\WINDOWS everywhere. So even if somehow you managed to get recent Windows versions to install into a non-default directory, I expect a lot of software just plain wouldn't work, possibly including parts of Windows itself. And given this is no longer a supported configuration, nobody is going to accept it as a bug.

I think supporting non-default installation directories is a feature which Microsoft decided is no longer worth the cost of supporting in the contemporary environment. With the advent of virtual machines, dual-booting between different Windows versions is less common than it used to be. And if you really want to do it, you can just use multiple partitions–whichever partition you boot from will be assigned as C drive, and hence its \WINDOWS directory will be available as C:\WINDOWS. The main thing we've lost is the ability to store multiple Windows installations in the same partition, and very few people were still doing that. Those kind of rarely used configurations end up breaking anyway because nobody bothers to test them, and hence they trigger bugs which few can be bothered to fix.

%windir% is never going to go away due to backward compatibility, but now it is always a fixed value (unless someone is doing crazy things like deliberately changing it to exploit a security vulnerability). I still prefer to use %windir% myself in batch files, if only because it is less typing.

Simon Kissane
  • 271
  • 1
  • 6