Copy PowerShell shortcut to Program Files, repath -file argument magic

176 Views Asked by At

I have a PowerShell utility that historically is run from a shortcut, and stored on a network share, so the path in the shortcut for the -file argument is a full UNC path. I am implementing a Work From Home version, where I zip up the network folder along with a shortcut with relative path to one of the utilities. That all gets unzipped on the user desktop of the home machine, the I do a Copy-Item -recurse to C:\Program Files. I expected I would then need to revise the path in the -file argument for all the included shortcuts. But to my amazement those paths are automatically getting revised. This does not happen if I copy to any other location, which has me thinking it is a special behavior associated with copying a link into Program Files. It happens when I copy the folder manually too. I am VERY happy with Microsoft making something easier for once, but I can't find any documentation on this behavior, and I worry that

1: this might not apply to every build of Windows 10, or

2: It might actually be a side effect, not a feature, and be broken in some future update

Does anyone know of some documentation related to this? Something that would assure me that taking advantage of this isn't going to break in future?

0

There are 0 best solutions below