The file should be created using the line[vba]Shell "Net view >c:\compNames.txt"[/vba]The 'shell' part of that more or less tells excel to run that on a command line.. the "Net view" is a command to see the network (like 'net send' is used to send a message in the network), and the ">" tells excel to send the results to that file.Originally Posted by Simon Lloyd
Do me a favor, go to Start, then Run, and once your dos window is open just type "net view" and press enter. I'm curious to see what comes up for you.
There is no way of capturing that message window (not an easy way), but what you just said begs the question:Originally Posted by Simon Lloyd
Do you really want 172 computer names hard coded into your code? Seems to me it would be easier to use Ken's method.
But as I like to give different examples, are you on an exchange server and do you know your SMTP server name?
If you think you are on exchange (many companies are) but don't know the server, and go to Tools / Services, on the services tab there should be a listbox with one option of "Microsoft Exchange Server". Click that, and go to Properties. Write down the server listed there, and you could try using CDO to send a message (if its installed on the machine):
[Code]Sub SendSimonComputerName()
Dim objCDO As Object
On Error Resume Next
Set objCDO = CreateObject("CDO.Message")
On Error GoTo 0
If objCDO Is Nothing Then 'cdo must not be installed on the machine
Exit Sub
End If
With objCDO
.Subject = "Computer name"
.From = "ComputerNames@domain.com"
.To = "simon.lloyd@company.com"
.TextBody = "Username: " & Environ("username") & vbCrLf & _
"Computer name: " & Environ("computername")
With .Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/con...tion/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = SmtpServer
.Item("http://schemas.microsoft.com/cdo/con...smtpserverport") = 25
.Update
End With
.Send
End With
Set objCDO = Nothing
End Sub[/vba]
Replace your real email address into the .To line, and replace "SmtpServer" with your server.
In the end, I'd say if you still want to hardcode the computer names, then try using the 'net view' again. If it doesn't work, consider Ken's methodThe above is just a workaround, you'd still have to gather the data from each email you received.




The above is just a workaround, you'd still have to gather the data from each email you received.
Reply With Quote