I got it! Very simple.
The script above breaks when trying to map to the hidden share "ipc$", which Pre-Vista machines take. Vista and later don't take this, but you can still pass credentials to an entity. Just delete \ipc$ and it works.
So, the logic of the script goes as follows...
- Check to see if the user is logging onto a corporate network domain or just the local computer (local domain, since all computers are their own mini-domain). If logging onto the local-domain, the domain name will equal the %userdomain% variable. If the user logs onto a corporate domain, then authentication will be seemless, so skip to the last command. But if the remote network-domain computer doesn't know who you are, then continue to the next section which allows you to pass credentials to the remote PC.
- The next section prompts for your username.
- The username is sent to the remote PC, which queries locally, then AD, which automatically prompts you for your password (no asterisks will appear as you type it in, but it's working).
- Then the last command tells Windows Explorer to open a window to the D: drive of the remote PC. The ipc$ hidden share is gone, but the c$, d$, etc. hidden shares still work. Windows 7 security may not allow this command to take you all the way to the remote drive, as commanded. It may instead just take you to the root machine...
\\TheRemotePC
instead of...
\\TheRemotePC\D$
But adding it to the address field of Windows Explorer manually will get you in.
So this might not be as totally fast as with XP, but at least it isn't "broken".
One reason I prefer a script instead of a shortcut is that machines and paths change - my work environment is very dynamic. I've seen shortcuts that point to non-existent places lock-up computers when clicked on. If nothing else, they slow a computer down - maybe miliseconds, maybe seconds, but add several bad shortcuts together, and especially if they're on the Desktop, and you have everything getting slowed down. A script can't have such a deleterious effect. The script might hang if you try to run it, but the computer's general performance won't suffer from it sitting there on the Desktop, or in a folder.