Reputation: 247
I am trying to add my program run in Windows 7 startup, but it doesn't work. My program has an embedded UAC manifest.
My current way is by adding a string value at HKCU..\Run.
I found a manual solution for Vista from http://social.technet.microsoft.com/Forums/en/w7itprosecurity/thread/81c3c1f2-0169-493a-8f87-d300ea708ecf
- Click Start, right click on Computer and choose “Manage”.
- Click “Task Scheduler” on the left panel.
- Click “Create Task” on the right panel.
- Type a name for the task.
- Check “Run with highest privileges”.
- Click Actions tab.
- Click “New…”.
- Browse to the program in the “Program/script” box. Click OK.
- On desktop, right click, choose New and click “Shortcut”.
- In the box type: schtasks.exe /run /tn TaskName where TaskName is the name of task you put in on the basics tab and click next.
- Type a name for the shortcut and click Finish.
Additionally, you need to run the saved scheduled task shortcut to run the program instead of running the application shortcut to ignore the IAC prompt. When startup the system will run the program via the original shortcut. Therefore you need to change the location to run the saved task. Please:
- Open Regedit.
- Find the entry of the startup item in Registry. It will be stored in one of the following branches.
- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
- HKEY_USERS.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Run
- HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
- Double-click on the correct key, change the path to the saved scheduled task you created.
Is there any free code to add item with privileges option in scheduled task? I haven't found the free one in torry.net.
Thanks a lot.
Upvotes: 2
Views: 3164
Reputation: 93
Are you asking how to get your app to start(launch) at Windows 7 startup or are you asking how to change your apps privileges at Windows 7 startup?
Upvotes: 0
Reputation: 6501
Why not just add your program to the Task Scheduler? See the command line options for schtasks.exe at MSDN for options. Your command line might look something like this:
schtasks.exe /Create /RU {username} /RP {password} /SC ONLOGON /TN {task name} /TR {file to run} /RL HIGHEST.
The "/RL HIGHEST" is what lets the task run with the admin level privileges.
Upvotes: 1
Reputation: 7489
JCL provides a Delphi interface unit to control Microsoft task schedule service. Its name is JclTask.pas. They also provide a demo application for adding/removing/showing Windows tasks in "jcl\examples\windows\tasks" folder.
Also, if commercial components are OK with you, SiComponents provides VCL Scheduling Agent, which is a VCL wrapper for Windows Task Scheduler, and supports new interface provided in Windows Vista.
Upvotes: 2
Reputation: 18974
There is a COM component called TaskScheduler. Some documentation is at http://msdn.microsoft.com/en-us/library/aa384006(v=VS.85).aspx. An example in C# is included in the Windows 7 Training Kit.
Upvotes: 2