Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Run at startup using scheduled tasks

Run at startup using scheduled tasks

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomwindows-adminjson
15 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxhl95
    wrote on last edited by
    #1

    Hiya everyone, Quick question: Is there any way to add a scheduled task (using windows api) without using COM? I want to make my application start on user logon and UAC on Vista stops me from adding the appropriate registry value. I've done a few quick searches, but google has yet to yield anything. Thanks. :)

    _ L 2 Replies Last reply
    0
    • H hxhl95

      Hiya everyone, Quick question: Is there any way to add a scheduled task (using windows api) without using COM? I want to make my application start on user logon and UAC on Vista stops me from adding the appropriate registry value. I've done a few quick searches, but google has yet to yield anything. Thanks. :)

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      The Windows Task Scheduler is exposed to applications only via COM interfaces. To add to the run registry keys, you have to be an administrator. But I'm not sure if you need admin previleges to create a shortcut in the StartUp folder. The statup folder is at C:\Users\\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      H 1 Reply Last reply
      0
      • _ _Superman_

        The Windows Task Scheduler is exposed to applications only via COM interfaces. To add to the run registry keys, you have to be an administrator. But I'm not sure if you need admin previleges to create a shortcut in the StartUp folder. The statup folder is at C:\Users\\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        H Offline
        H Offline
        hxhl95
        wrote on last edited by
        #3

        Thanks for the reply, but...I don't see to have a C:\Users folder. :confused: I've never seen that folder either. Is there any other way to make an app run on startup without having admin privileges?

        _ 1 Reply Last reply
        0
        • H hxhl95

          Thanks for the reply, but...I don't see to have a C:\Users folder. :confused: I've never seen that folder either. Is there any other way to make an app run on startup without having admin privileges?

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          Go to Start -> Programs -> StartUp, right click on it and select Explore. You will now be able to see the path for the StartUp folder. You can use the SHGetSpecialFolderLocation[^] API and give the nFolder parameter as CSIDL_STARTUP.

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          H 1 Reply Last reply
          0
          • H hxhl95

            Hiya everyone, Quick question: Is there any way to add a scheduled task (using windows api) without using COM? I want to make my application start on user logon and UAC on Vista stops me from adding the appropriate registry value. I've done a few quick searches, but google has yet to yield anything. Thanks. :)

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            A regular user should not be able to force another user to execute some of his code, and Vista has been the first Windows version to enforce this: regular users can't access someone else's private folders (such as StartUp), nor can they modify registry hives with global scope such as LOCAL_MACHINE. And if you find a way to do it anyway, it is doomed to be a bug, and will be fixed in a service pack or a new release. :)

            Luc Pattyn


            I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


            H 1 Reply Last reply
            0
            • L Luc Pattyn

              A regular user should not be able to force another user to execute some of his code, and Vista has been the first Windows version to enforce this: regular users can't access someone else's private folders (such as StartUp), nor can they modify registry hives with global scope such as LOCAL_MACHINE. And if you find a way to do it anyway, it is doomed to be a bug, and will be fixed in a service pack or a new release. :)

              Luc Pattyn


              I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


              H Offline
              H Offline
              hxhl95
              wrote on last edited by
              #6

              That's true, but it sounds like if I use superman's method, I'll be able to get my app to run for the current user (not all users though). That sounds good enough to me. :-D

              L 1 Reply Last reply
              0
              • _ _Superman_

                Go to Start -> Programs -> StartUp, right click on it and select Explore. You will now be able to see the path for the StartUp folder. You can use the SHGetSpecialFolderLocation[^] API and give the nFolder parameter as CSIDL_STARTUP.

                «_Superman_» I love work. It gives me something to do between weekends.
                Microsoft MVP (Visual C++)

                H Offline
                H Offline
                hxhl95
                wrote on last edited by
                #7

                Okay, I've just realized I don't know how to make a shortcut. Any hints? Edit: Is there any particular reason why I should use SHGetSpecialFolderLocation instead of SHGetSpecialFolderPath?

                modified on Thursday, November 5, 2009 10:44 PM

                _ D 2 Replies Last reply
                0
                • H hxhl95

                  Okay, I've just realized I don't know how to make a shortcut. Any hints? Edit: Is there any particular reason why I should use SHGetSpecialFolderLocation instead of SHGetSpecialFolderPath?

                  modified on Thursday, November 5, 2009 10:44 PM

                  _ Offline
                  _ Offline
                  _Superman_
                  wrote on last edited by
                  #8

                  You need to use IShellLink::GetPath[^] and IPersistFile::Save[^] to create shortcuts. Take a look at this article - Utility for creating Link(shortcut)...[^]

                  «_Superman_» I love work. It gives me something to do between weekends.
                  Microsoft MVP (Visual C++)

                  H 1 Reply Last reply
                  0
                  • _ _Superman_

                    You need to use IShellLink::GetPath[^] and IPersistFile::Save[^] to create shortcuts. Take a look at this article - Utility for creating Link(shortcut)...[^]

                    «_Superman_» I love work. It gives me something to do between weekends.
                    Microsoft MVP (Visual C++)

                    H Offline
                    H Offline
                    hxhl95
                    wrote on last edited by
                    #9

                    And unless I'm very much mistaken, we're back to using COM again. :laugh: No problem, thanks for your advice. :)

                    _ 1 Reply Last reply
                    0
                    • H hxhl95

                      And unless I'm very much mistaken, we're back to using COM again. :laugh: No problem, thanks for your advice. :)

                      _ Offline
                      _ Offline
                      _Superman_
                      wrote on last edited by
                      #10

                      :) COM is like alcohol. Good for anything.

                      «_Superman_» I love work. It gives me something to do between weekends.
                      Microsoft MVP (Visual C++)

                      1 Reply Last reply
                      0
                      • H hxhl95

                        That's true, but it sounds like if I use superman's method, I'll be able to get my app to run for the current user (not all users though). That sounds good enough to me. :-D

                        L Offline
                        L Offline
                        Luc Pattyn
                        wrote on last edited by
                        #11

                        Current user is no problem, there are many ways to do it. The personal startup folder is Environment.GetFolderPath(Environment.SpecialFolder.StartUp) which returns a different location on different Windows versions. [EDIT]Sorry, that is .NET stuff...[/EDIT] :)

                        Luc Pattyn


                        I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


                        modified on Friday, November 6, 2009 6:34 PM

                        H 1 Reply Last reply
                        0
                        • L Luc Pattyn

                          Current user is no problem, there are many ways to do it. The personal startup folder is Environment.GetFolderPath(Environment.SpecialFolder.StartUp) which returns a different location on different Windows versions. [EDIT]Sorry, that is .NET stuff...[/EDIT] :)

                          Luc Pattyn


                          I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


                          modified on Friday, November 6, 2009 6:34 PM

                          H Offline
                          H Offline
                          hxhl95
                          wrote on last edited by
                          #12

                          And then we run into the same problem up there (in the other "sub-thread"). :laugh: It's okay, I'm going to see if I can get COM to work...my copy of the SDK doesn't have it for some reason. Going to download some other copy.

                          L 1 Reply Last reply
                          0
                          • H hxhl95

                            And then we run into the same problem up there (in the other "sub-thread"). :laugh: It's okay, I'm going to see if I can get COM to work...my copy of the SDK doesn't have it for some reason. Going to download some other copy.

                            L Offline
                            L Offline
                            Luc Pattyn
                            wrote on last edited by
                            #13

                            CP hosts several articles on creating shortcuts, such as this one[^]. Alternatively you can distribute one with your app, and copy it to where ever you want it. :)

                            Luc Pattyn


                            I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


                            H 1 Reply Last reply
                            0
                            • H hxhl95

                              Okay, I've just realized I don't know how to make a shortcut. Any hints? Edit: Is there any particular reason why I should use SHGetSpecialFolderLocation instead of SHGetSpecialFolderPath?

                              modified on Thursday, November 5, 2009 10:44 PM

                              D Offline
                              D Offline
                              David Crow
                              wrote on last edited by
                              #14

                              hxhl95 wrote:

                              Edit: Is there any particular reason why I should use SHGetSpecialFolderLocation instead of SHGetSpecialFolderPath?

                              It all depends on whether you want the folder's PIDL or its path. They are not interchangeable functions.

                              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                              1 Reply Last reply
                              0
                              • L Luc Pattyn

                                CP hosts several articles on creating shortcuts, such as this one[^]. Alternatively you can distribute one with your app, and copy it to where ever you want it. :)

                                Luc Pattyn


                                I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


                                H Offline
                                H Offline
                                hxhl95
                                wrote on last edited by
                                #15

                                Edit: Ridiculously stupid post was here. Ignore it. Please. I did NOT write something that stupid. Apparently I fail at reading documentation. Problem solved now, thanks a lot. :)

                                modified on Friday, November 6, 2009 8:49 PM

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups