Login Info – collected!
Jul
2010
I have issues at clients with disparate home folder settings, manually re-directed special folders (i.e. My Documents or My Pictures), etc.
When trying to suddenly standardize such settings – perhaps for terminal server projects – there is difficulty and questions surrounding what should be changed and whom it will affect…
This script is something I threw together on my own time to address these questions – I would suggest just setting to be a login script for all domain users and create a share with everyone having full control (share permissions) and everyone having modify rights (ntfs permissions)…just modify the “strFile” to match where you wish to have the document saved. This script appends a record for each logon.
Some of the more clever readers may notice that a conflict could occur if two people logging in hit the script to append to the file at the same time – correct! Since this txt file is single-user, that issue does exist. In reality, I haven’t seen any issues since the script runs so quickly.
VBS code below – I would suggest leaving the “on error resume next” so users are none the wiser if you have a typo!
‘*******
On error resume next
strFile = “\\fastcodc\login-info\login-info-vbs.txt”
Set objShell = Wscript.CreateObject(“Wscript.Shell”)
Set objFso = CreateObject(“Scripting.FileSystemObject”)
‘the 8 is for append, 2 is write…
Set objFile = objFso.OpenTextFile(strFile, 8, True)
Set objNetwork = WScript.CreateObject(“WScript.Network”)
strMyDocs = objShell.RegRead(“HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal”)
strDesktop = objShell.RegRead(“HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop”)
strMyPics = objShell.RegRead(“HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Pictures”)
strMyMusic = objShell.RegRead(“HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Music”)
strCompName = objNetwork.ComputerName
strUser = objShell.ExpandEnvironmentStrings(“%USERNAME%”)
strHomeDrive = objShell.ExpandEnvironmentStrings(“%HOMEDRIVE%”)
strHomePath = objShell.ExpandEnvironmentStrings(“%HOMEPATH%”)
objFile.WriteLine (“Time: ” & Now & vbTab & “MyDocs: ” & strMyDocs & vbTab & “Desktop: ” & strDesktop & vbTab & “MyPics: “& strMyPics & vbTab & “MyMusic: ” & strMyMusic & vbTab & “Comp: ” & strCompName & vbTab & “User: ” & strUser & vbTab & “HomeDrive: ” & strHomeDrive & vbTab & “HomePath: ” & strHomePath)
objFile.Close
‘*******

See shot below…
