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


  1. Posts : 24
    Win 7 Pro 64 bit
       #1

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


    We use a program called TFC.exe (Temp File Cleaner - addpcs.com) 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?

    TIA.
      My Computer


  2. Posts : 4,776
    Microsoft Windows 7 Home Premium 64-bit 7601 Multiprocessor Free Service Pack 1
       #2

    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 Computer


  3. Posts : 24
    Win 7 Pro 64 bit
    Thread Starter
       #3

    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 Computer


  4. Posts : 4,776
    Microsoft Windows 7 Home Premium 64-bit 7601 Multiprocessor Free Service Pack 1
       #4

    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 Computer


 

  Related Discussions
Our Sites
Site Links
About 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 16:45.
Find Us