Tuesday, April 14, 2009

Uh, Because I had Nothing Better to Do?

I posted this over on MyItForum earlier, but I felt like maybe, just maybe, it was OK to post it here too, as well, also, in addition to, and so on. I've been sitting in afternoon rush hour traffic for an hour so I feel stupid right now. Stupid as stupid commuter drivers who drive stupid. I'll say it again: When do we get those computer-controlled cars without stupid wheels (oops, "STEERING" wheels)? Humans should not be allowed to drive - period. Because they can't.

Ok, here's the script: It iterates shortcuts and spits out their inerds (guts, insides, properties, ingredients, whatever). I didn't invent the concept, nor the methodology, but I did glue the code together since all the examples I found crawled either file/folder shortcuts or URL shortcuts, but not both. Mine does both, so there. Nah nah nah nah...


Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strAllUsers = objShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")
strThisUser = objShell.ExpandEnvironmentStrings("%USERNAME%")

strUsers = objFSO.GetParentFolderName(strAllUsers)
DesktopPath = strUsers & "\" & strThisUser & "\Desktop"
Set objFolder = objFSO.GetFolder(DesktopPath)

For each objFile in objFolder.Files
strPath = objFile.Path

Select Case Right(Lcase(objFile),4)
Case ".lnk":
Set objShortcut = objShell.CreateShortcut(strPath)
Wscript.Echo "----------------------------------"
Wscript.Echo "Type : file-system shortcut"
WScript.Echo "Full Name : " & objShortcut.FullName
WScript.Echo "Arguments : " & objShortcut.Arguments
WScript.Echo "Working Directory : " & objShortcut.WorkingDirectory
WScript.Echo "Target Path : " & objShortcut.TargetPath
WScript.Echo "Icon Location : " & objShortcut.IconLocation
WScript.Echo "Hotkey : " & objShortcut.Hotkey
WScript.Echo "Window Style : " & objShortcut.WindowStyle
WScript.Echo "Description : " & objShortcut.Description
Case ".url":
Set objShortcut = objShell.CreateShortcut(strPath)
Wscript.Echo "----------------------------------"
Wscript.Echo "Type : internet shortcut"
WScript.Echo "Full Name : " & objShortcut.FullName
WScript.Echo "Target Path : " & objShortcut.TargetPath
End Select
Next
Set objFolder = Nothing
Set objFSO = Nothing
Set objShell = Nothing

No comments: