Click here to Skip to main content
15,888,341 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have List control and I wanted to manage startup programs using it
for that first I need to load start up programs Sorry I don't have any Idea how
to do it? That's what I'm looking for...
Please Help!!!

What I have tried:

// This is a list control...
	m_lstStartupProgram.InsertColumn(0,_T("File Name"),LVCF_TEXT,180);
	m_lstStartupProgram.InsertColumn(1,_T("File Location"),LVCF_TEXT,230);
	m_lstStartupProgram.InsertColumn(2,_T("Key"),LVCF_TEXT,280);


void CStartupBoosterPage::LoadStartupsToList()
{
	//Here I want to write code...
}
Posted
Updated 24-Mar-17 2:01am

1 solution

There is no simple solution to get the list of startup programs because there are multiple locations where startup programs are defined.

But you can retrieve a list using WMI or PowerShell. So the simplest solution would be executing those as command line processes, redirecting the output to a text file, and read and parse that file. See Generate a List of Startup Programs via Command Line or PowerShell[^] for using WMI and the PowerShell.

To execute processes use system, _wsystem[^] or CreateProcess function (Windows)[^]. The output should be written to a temporary file (see GetTempFileName function (Windows)[^]) which should be deleted after reading it. Reading a text file should be no problem. When using WMI you have to process the text file line by line and split the lines into it's column (use strtok, CString::Tokenize, or AfxExtractSubString). With the PowerShell output, items are separated by empty lines and the columns are prefixed with an identifier (when using the command from the above link).
 
Share this answer
 
Comments
Premnath Mali 27-Mar-17 0:09am    
Sir,
On cmd prompt it is giving only three programs not all I checked with msconfig,
and the powershell command is giving error... What should I do?

error:
The term 'Get-CimInstance' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
Jochen Arndt 27-Mar-17 3:00am    
Execute it as Administrator.

Are you using Windows 7?
Than you have to install or update PowerShell.
Premnath Mali 27-Mar-17 5:30am    
I'm using windows 7
and tried executing as Administrator but still getting same error???
Jochen Arndt 27-Mar-17 6:07am    
You got that error when PowerShell is not installed or too old.
- Open a command prompt
- Type PowerShell
- You will get a ps prompt
- Type $PSVersionTable.PSVersion
- Type exit
Premnath Mali 27-Mar-17 6:17am    
PS C:\Users\lapitop> $PSVersionTable.PSVersion

Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900