All Domain Computer's Informaiton

Jan 2, 2013 at 1:39pm
Hello Hi all! Ok getting straight to the point, Below is the code I was able to formulate to get information about the PC I'm using, I want to modify this code so I can get the information of all the workstations that are connected within the domain and print them out like the example. Question is: how would I modify it to connect to a computer and get the info for print out? The idea I have is creating a server & client app, were the client app sends the info to the server app (Yes I will have to manually install the app and put it on start up to all client pc's). Is there another easier way I can do this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>

//max character length for all information
#define MAX_LENGTH  50

int main(void)
{
    //character varibles to hold names and name size
    char dmnNameBuf[MAX_LENGTH];
    char usrNameBuf[MAX_LENGTH];
    std::string serialTag;
    std::string pcModel;
    
    DWORD pcNameBufSize = sizeof dmnNameBuf-1;
    DWORD usrNameBufSize = sizeof usrNameBuf-1;
    
    //Files for data manipulation, input and output files
    std::ifstream name("name.txt");
    std::ifstream ser("ser.txt");
    //std::ofstream outfile("out.txt");
    
    //Check if the computer name can be retrived if yes continue to get more info 
    if (GetComputerNameA(dmnNameBuf, &pcNameBufSize) == true) 
    {
        //Serial number, user name, and the computer model from the bios
        GetUserNameA(usrNameBuf, &usrNameBufSize);
        std::getline(ser, serialTag), std::getline(name, pcModel); //Dummy containing the first line.
        std::getline(ser, serialTag); //Actual lines containing the serial nubmer
        std::getline(name, pcModel); //Actual line containing the computer model
        
        //Ouput the informaiton to the console    
        std::cout << " User Name\t " <<  usrNameBuf << std::endl;
        std::cout << " Domain Name\t " <<  dmnNameBuf << std::endl;
        std::cout << " Computer Model\t " << pcModel << std::endl;
        std::cout << " Serial/Tag\t " << serialTag << std::endl;
    }
    std::cin.get();
    return 0;
}

Output



User Name        TKgatla
Domain Name      Contoso
Computer Model   Dell
Serial/Tag       FW2J35J

Jan 2, 2013 at 3:03pm
You could just run nmap and get all this information.
Jan 2, 2013 at 3:10pm
Installing your program on every machine would work, but what if you come out with a update ?

How about making it part of a web page or run it over the network?

You just need to make sure it runs on the users machine and not the server where you have it stored, but seems much easier to maintain.
Last edited on Jan 2, 2013 at 3:18pm
Topic archived. No new replies allowed.