Results 1 to 20 of 97

Thread: Solved: Only running MyExcel.xls on named machine?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Quote Originally Posted by Simon Lloyd
    Matt your code for collecting machine names gave an error first until i created compNames.txt in C: but then when run did not populate the .txt file or excel and i dont pretend to understand how you are polling the machines
    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.
    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.

    Quote Originally Posted by Simon Lloyd
    The "Net Send" command is kinda cool but is there a way of capturing the required data off it or do i have to go through cancelling 172 (yes i counted 'em) net messages again?
    There is no way of capturing that message window (not an easy way), but what you just said begs the question:
    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 method The above is just a workaround, you'd still have to gather the data from each email you received.
    Last edited by Aussiebear; 03-11-2025 at 05:46 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •