Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch File Display Startup Items

In Windows, how can I display the startup items from using a batch file?


2 Answers

Your startup items are a combination of your own items and the "All Users" items. You can find your own with:

dir "%homedrive%%homepath%\start menu\progams\startup"

and the "All Users" ones (usually) with:

dir "%homedrive%%homepath%\..\all users\start menu\progams\startup"

All you have to do is manipulate the file names to remove the path and the ".lnk" at the end to get the shortcut names.

If you cd to those directories first and just do dir, you won't even have to remove the path.

UPDATE:

If, as your comments seem to indicate, you want all things that start when your system starts, they're found all over the place. You'll want to get a copy of Autoruns (or its command-line brother, Autorunsc, for your purposes).

This is the best approach since it's "blessed" by Microsoft themselves.

like image 141
paxdiablo Avatar answered Dec 08 '25 17:12

paxdiablo


If you can use PowerShell, here is a bit of code that uses AUTORUNSC.

$autoruns = [xml](AUTORUNSC -x 2>$null)

foreach ($item in $autoruns.autoruns.item)
{
  If ($item.Description.Length -gt 0)
  { Write-Output $item.Description.Trim() }
  Else
  { Write-Output "n/a"}
  Write-Output $item.ItemName.Trim()
  Write-Output $item.imagepath.Trim()
  "---------------------------------------"
}

EDIT: The -x parameter on AUTORUNSC makes it output XML.

like image 43
aphoria Avatar answered Dec 08 '25 16:12

aphoria



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!