Scripting VBS Windows

Find Startup Items

A long time ago i found this VBS script to display the start-up items for a windows pc. i can not remember who is the author of the script.

hopefully this will help someone.

 This script is a VBS script

 
' StartupList.vbs - Create a text listing of all startup items.

' ************************** User Tweaks *********************************
' The FileExt variable can be used to change the default output format
' Suggestions: htm, doc, rtf. If not specified, defaults to .txt
FileExt = "" : If FileExt = "" Then FileExt = "txt"

' The OpenWith variable is optional, to open results in specific program
' If variable is empty, Windows will use default program for FileExt type
OpenWith = "" : If OpenWith <> "" Then OpenWith = Trim(OpenWith) & " "
' ************************************************************************

With CreateObject("WScript.Network")
ComputerName = .ComputerName
UserName = .UserName
End With

Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("WScript.Shell")
TmpFile = ws.ExpandEnvironmentStrings("%TEMP%") & "\Startup." & Trim(FileExt)

With fso.CreateTextFile(TmpFile, True)
.WriteLine WriteCode("Startup Items for Computer: " & ComputerName & _
", User: " & UserName & ", " & Now())
.WriteLine WriteCode("")
For Each o in GetObject _
("winmgmts:\\" & ComputerName & "\root\cimv2").ExecQuery(_
"Select Name, Command, User, Location from Win32_StartupCommand",,48)
If LCase(o.Command) <> "desktop.ini" _
AND LCase(o.User) <> ".default" _
AND InStr(LCase(o.User), "nt authority") = 0 Then
.WriteLine WriteCode("Name: " & o.Name)
.WriteLine WriteCode("Command: " & o.Command)
.WriteLine WriteCode("User: " & o.User)
.WriteLine WriteCode("Startup Location: " & o.Location)
.WriteLine WriteCode("")
Else
s = s & vbcrlf & WriteCode("Name: " & o.Name)
s = s & vbcrlf & WriteCode("Command: " & o.Command)
s = s & vbcrlf & WriteCode("User: " & o.User)
s = s & vbcrlf & WriteCode("Startup Location: " & o.Location)
s = s & WriteCode("") & vbcrlf
End If
Next

If s <> "" Then
.WriteLine WriteCode(String(25, "*"))
.WriteLine WriteCode("Additional non-relevant item(s) " & _
"in the Startup configuration:")
.WriteLine s
.WriteLine WriteCode("")
End If
.WriteLine WriteCode("NOTE: This file will be deleted when you close " & _
"it. If you wish to retain this information, " & _
"Print it or use File, Save As...")
.WriteLine WriteCode("")
.Close
End With

' Some programs do not work properly with bWaitOnReturn argument
On Error Resume Next
ws.Run OpenWith & TmpFile,,True
On Error GoTo 0

fso.GetFile(TmpFile).Delete

Set fso = Nothing
Set ws = Nothing

Function WriteCode(sIn)
If LCase(FileExt) = "htm" OR LCase(FileExt) = "html" Then
WriteCode = sIn & "
"
Else
WriteCode = sIn
End If
End Function

Leave a Reply

Your email address will not be published. Required fields are marked *