Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Execute Program in Batch File As Administrator (Or Other Solution)

12 Nov 2014   #1

Win 7 Pro 64 bit
Execute Program in Batch File As Administrator (Or Other Solution)

We use a program called TFC.exe (Temp File Cleaner - to wipe all sorts of temp files off a computer on a monthly basis.

The older version was a standalone .exe that users used to execute from a a folder on a server. The newer version is actually installed on each user's PC.

If TFC it is not run in administrator mode, it is limited to wiping the temp files as allowed by users file permissions. Most of our users do not have admin privileges, and thus, the system files and other user profiles that may be on the computer do not get cleaned.

What I want to do is allow this one program to execute in admin mode, either by having the user execute a batch file (or batch file converted to exe) using a shortcut, or maybe by automatically running it via the task scheduler.

The open ended question is: Can this be accomplished or am I going to have to log in to each computer to run as admin?


My System SpecsSystem Spec
12 Nov 2014   #2

Microsoft Windows 7 Home Premium 64-bit 7601 Multiprocessor Free Service Pack 1
Use an Eleveted Shortcut

Suggest using an Elevated Shortcut in Task Scheduler. Personally I use this:

WinAero: ElevatedShortcut for Windows 7 and Windows 8

As for the batch file to run the program use:

C:\Windows\system32\schtasks.exe /run /tn taskname

taskname is the name as displayed in Task Scheduler. Wrap it in quotes if it contains spaces.
My System SpecsSystem Spec
12 Nov 2014   #3

Win 7 Pro 64 bit

Thanks for the information. I see that in the Elevated Shortcut article there is the warning:

This shortcut and task can only be created and work while logged in as an administrator account.
This shortcut will not work in a standard user account.
I gather, then, that this will not solve my problem since I want to run TFC on computers with standard users, without me having to login as administrator. Looks like this is tough to do. Thank you.
My System SpecsSystem Spec

12 Nov 2014   #4

Microsoft Windows 7 Home Premium 64-bit 7601 Multiprocessor Free Service Pack 1
Elevated Shortcut

I hadn't spotted that! In that case I'm not sure. I reckon it must be possible. I know that in my workplace clean up scripts run overnight even with no users logged on but I'm no expert on networks.

When I create an Elevated Shortcut I see the following options:

Execute Program in Batch File As Administrator (Or Other Solution)-e-levated_-local-computer-.jpg

Execute Program in Batch File As Administrator (Or Other Solution)-elevated_-local-computer-2.jpg

Maybe changing to Administrator will allow it to run without UAC using a stored password but I'm not 100% certain.

Also check if this might be suitable - there are some restrictions.

Elevated Program Shortcut - Create for Standard User

My System SpecsSystem Spec

 Execute Program in Batch File As Administrator (Or Other Solution)

Thread Tools

Similar help and support threads
Thread Forum
Execute a file as Administrator
Hi I have to execute a file as Administrator to one user's System, so I created a shortcut access and use RUNAS with /SAVECRED option to only write one time the Administrator's Password , but I have to write it any time doesn't save it ..... So is there any other via to fix it?
General Discussion
Batch File on USB fails when Ran As Administrator
I am new to this site so please excuse any lack of etiquette I may show. I have recently built a .bat files to perform a large number of configuration changes needed for a Win7 or Win8 workstation to function properly on my network. The .bat file obviously needs to be ran with elevated...
Administrator with full access still can't execute program
Hi all! I'm having a problem with a Windows 7 Professional VM. I'm trying to "lock down" the permissions of some files (cmd.exe, ftp.exe, etc) For example, I modify the permissions for C:\Windows\System32\cmd.exe so that only SYSTEM and Administrators have full access. I removed Users,...
System Security
execute a .bat and .exe file as administrator once for all
hello, Once i double click on bat file, a new program .exe is launched and receive a msg asking if i allow the program to modify my computer. I click yes, and my short life continues... Any clue what can be done to remove this msg once for all for this program ? After right click on .bat...
System Security
How to always run batch file as administrator?
I've made a batch file, but i don't know how to make it to always run as administartor. In .bat's file properties the option "always run as administartor" is grayed out. I have to right click it and then choose "run as administartor" from context menu. But i don't want to do it every time because...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 17:40.
Twitter Facebook Google+