Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write current network drive mappings to event log -Help please! 1

Status
Not open for further replies.

Jeepix

MIS
Aug 21, 2003
102
US
I just got a new requirement. Before we remap everyone's network drives during a file server migration they want a list of current drive mappings for the computer before the whole process happens.

I had wrote a basic batch file to drop this to a .txt file, but they didn't want an errant file laying around and didn't want to do a mass 'delete' from all these PC's.

I have no idea where to even start with this one and have never written to an event log before.

Something quick and dirty is absolutely fine. Just need something like this:

- User name of currently logged in account
- Current network drive mappings (whether persistent or non-persistent would be great, but not required kind of like a 'wmic netuse' kind of output.)
- Written to the application log?

Many thanks in advance for any help!!!
-j
 
If "they" want a list, are you sure you want that list scattered among every computer's event log??? If you already wrote a batch file, pipe the output (using >) to a shared folder, or append the output (using >>) to the end an existing file.

If you want a vbscript solution, here is a start:
 
Yeah, they want it in the event log because that'll eventually be dropped off the log instead of having a file hanging around. I already tried talking them out of it, but they insisted. :/

I've been using that link and I can get information like the machine name and username into the log, but not a list of the mapped drives.

Thanks again for the help, guitarzan. I'll keep plugging away, hopefully something will click. :)
-j
 
Test the code in the link I posted. objItem.Name and objItem.ProviderName should give you what you need. Store it in a variable, and then write that plus machine name and username to the log
 
This was the end result of what I needed done, in case anyone else needs this:

Set objNetwork = WScript.CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
Set colDrives = objNetwork.EnumNetworkDrives
Dim Logs
For i = 0 to colDrives.Count-1 Step 2
Logs = Logs & vbCrLf & colDrives.Item(i) & vbTab & colDrives.Item (i + 1) & " Logged Time : " & Now & " User " & objShell.ExpandEnvironmentStrings("%USERNAME%")
Next
objShell.LogEvent 4, Logs
 
Let me just quote what the event logs are actually for: "Event logs are special files that record significant events on your computer"

What you have been asked to do is a misuse of the event logs.
 
Well, it'd be a pretty significant event if, for some reason, the person lost all their drive mappings and we had no idea what they were. This gives us a way to at least manually recover their mappings with the same drive letter and everything. Plus, I'm just the contractor, they're the client. Gotta do what I gotta do. ;)

-Jeepix
 
Jeepix: This isn't really directed at you, just an observation...

I agree with strongm. Another example of misuse of the event logs is Quickbooks....... Older versions (maybe recent ones too, i stopped caring about any event log message from Intuit long ago) from 2008 / 2009 QB Pro anyway, would FILL your event log with stupid errors. And the errors they posted actually had typos sometimes..... Or something stupid like "ERROR CODE 0 detected: No Error", or something equally stupid.

Basically, Intuit coders treated all end-users event logs like their own personal debug logs. I really hate them for that!

The point is, you should never ever use the event log this way, ... unless of course your employer explicitly asks for it! In which case, be prepared to have others look on your code with disdain! Also, CYA!
 
Yeah, I know guitarzan. As my original post stated, I was going to send it to a file...but they wanted it written to the event log. What the customer wants the customer gets. What can I do? I need a paycheck like everyone else...

Thanks for all your help!
-j

-Jeepix
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top