'====================================================================
'= Enumerate Startup Links VBScript sample - Copyright © 2007, Dave Moats
'=
'= This sample is provided 'as-is', without any express or implied warranty.
'= In no event will the authors be held liable for any damages arising from
'= the use of this sample code.
'=
'= Permission is granted to anyone to use this sample code for any purpose,
'= including commercial applications, subject to the following restrictions:
'=
'= The origin of this code must not be misrepresented;
'= you must not claim that you wrote the original code.
'= If you use this code, an acknowledgment in the
'= documentation is requested - shown below:
'=
'= Portions Copyright © 2007, Dave Moats (http://www.davemoats.com/).
'=
'====================================================================
'====================================================================
'== enum_files.vbs - script to enumerate all the files in
'== the startup folders located under
'== c:\document and settings
'====================================================================
set fso = createobject ( "Scripting.FileSystemObject")
set wShell = createobject ( "WScript.Shell")
set objFolder = fso.getfolder ( "c:\documents and settings")
indentStr = " "
listFolders ( objFolder )
set objFolder = nothing
set wShell = nothing
set fso = nothing
wscript.quit
'====================================================================
'== sub listFolders - enumerates all the folders under
'== c:\documents and settings
'====================================================================
sub listFolders ( inFolder )
'==================================================================
'== ignore any folder does not exist errors
'==================================================================
on error resume next
set subFolders = inFolder.subfolders
for each folder in subFolders
set objSubFolder = fso.getfolder ( folder.path & "\Start Menu\Programs\Startup" )
wscript.echo " Folder: " & objSubFolder.path
listFiles ( objSubFolder )
set objSubFolder = nothing
next
end sub
'====================================================================
'== sub listFiles - enumerating all the files located in the
'== startup folder
'====================================================================
sub listFiles ( inFolder )
dim objFile, filePath
set objFiles = inFolder.files
for each file in objFiles
indentStr = " "
wscript.echo indentStr & "File: " & file.name
filePath = file.path
wscript.echo getFileInfo ( filePath )
if instr ( 1, lcase ( file.name), ".lnk" ) <> 0 then
filePath = getLinkPath ( file.path )
wscript.echo indentStr & " Link target: " & filePath
indentStr = " "
wscript.echo getFileInfo ( filePath )
end if
wscript.echo vbcrlf
next
indentStr = " "
end sub
'====================================================================
'== sub getLinkPath - open up the link file and find its target
'====================================================================
function getLinkPath ( lnkPath )
dim objLink, retVal
set objLnk = wShell.createshortcut ( lnkPath)
retVal = objLnk.targetpath
set objLnk = nothing
getLinkPath = retVal
end function
'====================================================================
'== function getFileInfo - get information about the file in
'== question
'==
'== Normal 0 Normal file. No attributes are set.
'== ReadOnly 1 Read-only file. Attribute is read/write.
'== Hidden 2 Hidden file. Attribute is read/write.
'== System 4 System file. Attribute is read/write.
'== Volume 8 Disk drive volume label. Attribute is read-only.
'== Directory 16 Folder or directory. Attribute is read-only.
'== Archive 32 File has changed since last backup. Attribute is read/write.
'== Alias 1024 Link or shortcut. Attribute is read-only.
'== Compressed 2048 Compressed file. Attribute is read-only.
'==
'====================================================================
function getFileInfo ( filePath)
dim fileObj, outMsg
set fileObj = fso.getfile ( filePath)
outMsg = ""
outMsg = outMsg & indentStr & " Created: " & fileObj.DateCreated & vbcrlf
outMsg = outMsg & indentStr & " Last Accessed: " & fileObj.DateLastAccessed & vbcrlf
outMsg = outMsg & indentStr & " Last Modified: " & fileObj.DateLastModified & vbcrlf
outMsg = outMsg & indentStr & " File Type: " & fileObj.Type & vbcrlf
if fileObj.attributes and 0 then
outMsg = outMsg & indentStr & " File Attributes: Normal File"
else
outMsg = outMsg & indentStr & " File Attributes: "
if fileObj.attributes and 1 then
outMsg = outMsg & "Read Only "
end if
if fileObj.attributes and 2 then
outMsg = outMsg & "Hidden "
end if
if fileObj.attributes and 4 then
outMsg = outMsg & "System "
end if
if fileObj.attributes and 8 then
outMsg = outMsg & "Volume "
end if
if fileObj.attributes and 16 then
outMsg = outMsg & "Directory "
end if
if fileObj.attributes and 32 then
outMsg = outMsg & "Archive "
end if
if fileObj.attributes and 1024 then
outMsg = outMsg & "Link "
end if
if fileObj.attributes and 2048 then
outMsg = outMsg & "Compressed "
end if
end if
set fileObj = nothing
getFileInfo = outMsg
end function
'= Enumerate Startup Links VBScript sample - Copyright © 2007, Dave Moats
'=
'= This sample is provided 'as-is', without any express or implied warranty.
'= In no event will the authors be held liable for any damages arising from
'= the use of this sample code.
'=
'= Permission is granted to anyone to use this sample code for any purpose,
'= including commercial applications, subject to the following restrictions:
'=
'= The origin of this code must not be misrepresented;
'= you must not claim that you wrote the original code.
'= If you use this code, an acknowledgment in the
'= documentation is requested - shown below:
'=
'= Portions Copyright © 2007, Dave Moats (http://www.davemoats.com/).
'=
'====================================================================
'====================================================================
'== enum_files.vbs - script to enumerate all the files in
'== the startup folders located under
'== c:\document and settings
'====================================================================
set fso = createobject ( "Scripting.FileSystemObject")
set wShell = createobject ( "WScript.Shell")
set objFolder = fso.getfolder ( "c:\documents and settings")
indentStr = " "
listFolders ( objFolder )
set objFolder = nothing
set wShell = nothing
set fso = nothing
wscript.quit
'====================================================================
'== sub listFolders - enumerates all the folders under
'== c:\documents and settings
'====================================================================
sub listFolders ( inFolder )
'==================================================================
'== ignore any folder does not exist errors
'==================================================================
on error resume next
set subFolders = inFolder.subfolders
for each folder in subFolders
set objSubFolder = fso.getfolder ( folder.path & "\Start Menu\Programs\Startup" )
wscript.echo " Folder: " & objSubFolder.path
listFiles ( objSubFolder )
set objSubFolder = nothing
next
end sub
'====================================================================
'== sub listFiles - enumerating all the files located in the
'== startup folder
'====================================================================
sub listFiles ( inFolder )
dim objFile, filePath
set objFiles = inFolder.files
for each file in objFiles
indentStr = " "
wscript.echo indentStr & "File: " & file.name
filePath = file.path
wscript.echo getFileInfo ( filePath )
if instr ( 1, lcase ( file.name), ".lnk" ) <> 0 then
filePath = getLinkPath ( file.path )
wscript.echo indentStr & " Link target: " & filePath
indentStr = " "
wscript.echo getFileInfo ( filePath )
end if
wscript.echo vbcrlf
next
indentStr = " "
end sub
'====================================================================
'== sub getLinkPath - open up the link file and find its target
'====================================================================
function getLinkPath ( lnkPath )
dim objLink, retVal
set objLnk = wShell.createshortcut ( lnkPath)
retVal = objLnk.targetpath
set objLnk = nothing
getLinkPath = retVal
end function
'====================================================================
'== function getFileInfo - get information about the file in
'== question
'==
'== Normal 0 Normal file. No attributes are set.
'== ReadOnly 1 Read-only file. Attribute is read/write.
'== Hidden 2 Hidden file. Attribute is read/write.
'== System 4 System file. Attribute is read/write.
'== Volume 8 Disk drive volume label. Attribute is read-only.
'== Directory 16 Folder or directory. Attribute is read-only.
'== Archive 32 File has changed since last backup. Attribute is read/write.
'== Alias 1024 Link or shortcut. Attribute is read-only.
'== Compressed 2048 Compressed file. Attribute is read-only.
'==
'====================================================================
function getFileInfo ( filePath)
dim fileObj, outMsg
set fileObj = fso.getfile ( filePath)
outMsg = ""
outMsg = outMsg & indentStr & " Created: " & fileObj.DateCreated & vbcrlf
outMsg = outMsg & indentStr & " Last Accessed: " & fileObj.DateLastAccessed & vbcrlf
outMsg = outMsg & indentStr & " Last Modified: " & fileObj.DateLastModified & vbcrlf
outMsg = outMsg & indentStr & " File Type: " & fileObj.Type & vbcrlf
if fileObj.attributes and 0 then
outMsg = outMsg & indentStr & " File Attributes: Normal File"
else
outMsg = outMsg & indentStr & " File Attributes: "
if fileObj.attributes and 1 then
outMsg = outMsg & "Read Only "
end if
if fileObj.attributes and 2 then
outMsg = outMsg & "Hidden "
end if
if fileObj.attributes and 4 then
outMsg = outMsg & "System "
end if
if fileObj.attributes and 8 then
outMsg = outMsg & "Volume "
end if
if fileObj.attributes and 16 then
outMsg = outMsg & "Directory "
end if
if fileObj.attributes and 32 then
outMsg = outMsg & "Archive "
end if
if fileObj.attributes and 1024 then
outMsg = outMsg & "Link "
end if
if fileObj.attributes and 2048 then
outMsg = outMsg & "Compressed "
end if
end if
set fileObj = nothing
getFileInfo = outMsg
end function
Copyright © 2010 Dave Moats. All rights reserved. Links: Copyright © by their respective owners.
NO WARRANTIES EXTENDED. Void where prohibited by law. Please report any issues or broken links.
You may link to this site freely from your own site. You may quote from this site, but please include a link to the original source on the originating site.