Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Dec 2009
    Location
    Wolfville, Nova Scotia, Canada
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post
    I program primarily in C++ using Visual Studio 2005. Can anyone help me figure out how to set a program (in this case one that polls network time servers and then sets the system clock) to automatically run with administrative rights so that Windows Vista & 7 will allow it to set the system time?

    Thanks in advance.

    Ron

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there a reason why the program cannot be run with Administrative Privileges built-in by using TaskScheduler in Vista|Win7?

    That would appear to be a simpler (& generally accepted) solution.
    Gre

  3. #3
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts
    Surely the Even Easier method is to use the built-in mechanism?

    Right-click on the time at the bottom right of the screen, and select Adjust Date/Time from the pop-up menu. Click on the Internet Time tab and it tells you all about it! If you don't like the default NTP server(s), choose one you prefer(in the UK, uk.pool.ntp.org, for example.
    BATcher

    Time prevents everything happening all at once...

  4. #4
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,594
    Thanks
    5
    Thanked 1,059 Times in 928 Posts
    Joe

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by Ron Brunton View Post
    Can anyone help me figure out how to set a program (in this case one that polls network time servers and then sets the system clock) to automatically run with administrative rights so that Windows Vista & 7 will allow it to set the system time?
    In case the above replies do not address the issue... Perhaps you want to create a program that can bypass the UAC dialog by elevating the user's privileges automatically. That almost certainly is not possible for ordinary EXEs run by the user, but it seems to be possible for programs installed as drivers or services that run in the SYSTEM context.

    Some MSDN doc on UAC for possible further investigation:

    User Account Control
    Teach Your Apps To Play Nicely With Windows Vista User Account Control

  6. #6
    New Lounger
    Join Date
    Dec 2009
    Location
    Some uncharted planet...
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jscher2000 View Post
    In case the above replies do not address the issue... Perhaps you want to create a program that can bypass the UAC dialog by elevating the user's privileges automatically. That almost certainly is not possible for ordinary EXEs run by the user, but it seems to be possible for programs installed as drivers or services that run in the SYSTEM context.

    Some MSDN doc on UAC for possible further investigation:

    User Account Control
    Teach Your Apps To Play Nicely With Windows Vista User Account Control
    Exactly - normal user executables are not supposed to run elevated unless manually elevated by the user, and should not have any mechanism to elevate themselves. (UAC is actually supposed to stop that, as self-elevating user-level executables are a massive security threat.) If your code has to run with top-level privileges, and given what you want to do this will probably be the best approach, the ideal mechanism is to build it into a noninteractive service and run that within the SYSTEM user context.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •