HOSTS File

Started by CadJoe, August 28, 2014, 08:57:32 AM

Previous topic - Next topic

CadJoe

Hi,

I'm trying to automate copying a new HOSTS file over the old HOSTS file, and keep hitting a popup.

I don't think this is a UAC popup, as it just has a title of Destination Folder Access Denied, with a Continue button.

Hitting Continue works fine, I just need a winbatch way around the popup.

Windows 7 Pro
WinBatch 2014

Any ideas?

Thanks,

CadJoe
WinBatch, Gotta Love It!

td

Not sure what all of your requirements are but have you tried using the FileCopy function from a script running with elevated admin privileges?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

CadJoe

Please define which elevated admin your referring to:

1) Launch WinBatch with Run as Admin
2) WIL code to RunWIthLogon?
3) Compile EXE using UAC settings in compiler options.

Which would work the best?  All I want to do is replace it with another one, without prompts, initiated from the Winbatch.

Thanks,

CadJoe
WinBatch, Gotta Love It!

td

Quote from: CadJoe on September 08, 2014, 12:07:25 PM
Please define which elevated admin your referring to:

1) Launch WinBatch with Run as Admin
2) WIL code to RunWIthLogon?
3) Compile EXE using UAC settings in compiler options.

I wasn't referring to any particular techniques for executing a script as an elevated administrator.  I was simply referring to the enabled set of privileges on the access token of a process running a script.  More specifically I was referring to full admin privileges of an elevated admin as apposed to the restricted admin privileges of a restricted admin.  On Windows 7 admin accounts have both sets available when UAC is enabled and a process started by an admin may be granted either set.

Quote
Which would work the best?  All I want to do is replace it with another one, without prompts, initiated from the Winbatch.

If the system running the script has UAC enabled then you are going have either an admin approval or admin credentials prompt depending on the type of account running the script and the UAC policy settings.  You cannot use RunWithLogon to avoid an elevation prompt.  The most often recommend alternative on Windows 7 is the Task Scheduler trick. This technique does not work on Windows 8 and beyond. More on the Task Scheduler workaround can be found here:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UAC+Run~As~Admin~WinBatch~Script~With~UAC~On.txt

However, make sure you have identified the problem correctly before launching into a solution.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

CadJoe

Well, I don't think this is a UAC prompt, as the background isn't dim, and the prompt doesn't say anything about UAC, just wants admin credentials to Continue.

See attached PNG file.

The Winbatch to do this will be local, but is being called by a remote process that runs it locally, so it needs to be automated without popups.

The local logged in user that is running the script is in the local admin group on Windows 7.

Thanks,

CadJoe
WinBatch, Gotta Love It!

td

Quote from: CadJoe on September 09, 2014, 11:59:03 AM
Well, I don't think this is a UAC prompt, as the background isn't dim, and the prompt doesn't say anything about UAC, just wants admin credentials to Continue.

See attached PNG file.

The message is self explanatory. The process running the script needs full administrator rights and it doesn't have it. And just because you don't see a UAC prompt doesn't mean that this isn't UAC related. Not every UAC related issue is reflected by and occurrence of a UAC prompt.  Based the limited information provided so far, it is impossible to determine whether or not the problem is caused by UAC.

Quote
The Winbatch to do this will be local, but is being called by a remote process that runs it locally, so it needs to be automated without popups.

The local logged in user that is running the script is in the local admin group on Windows 7.


Possibly some terminology may be being misused but rather than speculating it would be best if you would provide more information.  First, how can the 'local logged in user' be running the script when the script is being executed by a remote process? Is the local script compiled?  If it is compiled, what are the manifest settings. If the script is really being executed by a remote process, how are you remotely starting the local script?  Are you using a tool like psexec.exe to run the script or some other technique?  Also, if the script is actually being executed by a remote process, what user credentials is the remote process using and how do those credentials relate the the local machine that script is running on?  Is UAC enabled on the local machine? 

Remember that an administrator does not automatically have administrator privileges when UAC is enabled
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

CadJoe

Sorry, we have a private instant messaging app that is running on each client, giving us the power to execute anything locally as the locally logged in users session.

Not very familiar with UAC so just trying to figure out how to get WinBatch to do this.
Guess I'll run the Winbatch, and have it call a cmd file elevated to do a copy /Y.

Thanks,

CadJoe
WinBatch, Gotta Love It!

td

Assuming the process is running as a restricted admin because UAC is enabled as it appears to be, you will not be able to avoid an elevation prompt using cmd.exe. .
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade