Pretty straightforward one that I'm having trouble finding an answer to.
serverfault previously helped me with finding a way to automate Windows updates without using WSUS. It's working fantastically, but to run it over the network, you have to first mount a shared drive. That's pretty simple XP since you just mount the drive and run the updater.
On Vista and W7, though, this all has to be done with elevated privileges to work correctly. The UAC account can't see network drives mounted by the regular user, so in order to get everything working, I have to mount the share via net use
from an escalated shell. I'd like to automate mounting this share and launching the updater via a simple .bat file.
I could probably just instruct everybody to right click "Run as Administrator" on the .bat file, but I'd like to keep things as simple as possible and have the .bat automatically prompt the user to escalate their privileges.
Since these computers don't belong to us, I can't count on anything like Powershell being installed, so that rules any solution along those lines out and pretty much have to rely on things that would be included in an RTM Vista install. I'm hoping I'm mostly missing something obvious here. :)
http://technet.microsoft.com/en-us/magazine/2007.06.utilityspotlight.aspx
EDIT: If you are giving the customer a single file to run, why not create a self extracting RAR with WinRAR and set the "Require Administrator" flag in SFX options? This absolves you of your limit of only 1 file, you can have all the resources you need.
Alternatively make your SFX using your favourite SFX tool and use the elevate tools above.
If you are prepared to convert to PowerShell this is much easier to do. This is my "
Elevate-Process.ps1
" script (withsu
as alias in my profile):Detection of being elevated can also be done in PSH (thus you can check for elevation, and then elevate if needed):
here is an example script I came up with, I hope it helps others. It's a bat file that prompts the user for permission and then escalates itself. It pipes out some vbscript which triggers the UAC prompt and then re-runs the bat file elevated... http://jagaroth.livejournal.com/63875.html
This is what you need: http://sites.google.com/site/eneerge/home/BatchGotAdmin
FusionInventory.org is an open source solution mostly used by small repair shops. It can be like your personal remotely controlled windows updater.
If you can't rely on Powershell being installed, you can take this solution on StackOverflow:
auto-elevate with UAC using batch file
It does not require anything to be installed and runs out of the box. If you need to preserve the command-line arguments, consider this update.
None of those solutions work for a .cmd file that needs to be aware of command-line parameters. Put this at the very beginning of the .cmd file and all your problems will be solved. (This is for future people browsing this thread [I have tested this on windows XP, 7 Vista and 8; x86 + x64]):
As @emilio said, that script is OK but it does not accept any arguments. Here the modified script to be compatible with arguments:
Have you tried the
runas
command?