Possible Script?

Discussion in 'Web Design & Coding' started by omg its nlm, Jan 23, 2004.

  1. omg its nlm

    omg its nlm lvl 17 Hax Folding Team

    Messages:
    1,829
    Location:
    Minnesota
    Ok here is what I want to do. I do a report in ghost and it goes into a text file, containing pc information. From there I want to put it into a database. The report file looks like this
    ------
    computername
    -----
    ram: 256
    model: HP
    Ect
    ----

    Is there some kind if script I can make that would put it into an access or excel database? I have done some coding with VB in excel once before. Does this seem like a hard task? Is there a better soultion?

    Basicly the norton report is way to big, it was 8 pages with only 15 computer and there is no way to shorten it down. This way we can track our computers information easily.
     
  2. CodeReliant

    CodeReliant OSNN Junior Addict

    Messages:
    22
    Put this into a file with the extension ".vbs"

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
    For Each objItem in colItems
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Model: " & objItem.Model
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "TotalPhysicalMemory: " & objItem.TotalPhysicalMemory
    Next
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    There are hundreds of other things you can find with vbs, they might be in different objects. Let me know if you can't get other information.

    Dan
     
  3. CodeReliant

    CodeReliant OSNN Junior Addict

    Messages:
    22
    Forgot to mention. If you want, you can create a new file with the extension ".csv" that is comma delimited. This will create an excel file that is nice and organized.

    Dan
     
  4. omg its nlm

    omg its nlm lvl 17 Hax Folding Team

    Messages:
    1,829
    Location:
    Minnesota
    hey thanks that will work for another project. Here is what I am trying to do...

    If you see the attached file, I want to put that into a database. I am trying to figure out a way to sort it so I can. You have any ideas?

    Thanks for the help.
     

    Attached Files:

  5. CodeReliant

    CodeReliant OSNN Junior Addict

    Messages:
    22
    Scriptomatic

    I don't know an easy way. You may have to organize all of your machines into one excel file. Then you can create a blank database and import the excel file using the file drop down menu. (Assuming you are using excel). I will take some messing around with to get the import to work right. Your excel file might have to be set up like this (all computers in one sheet):

    Computer IPAddress .......
    lab-02 654.654.64.654......
    lab-03 654.654.64.654......

    Dan
     
  6. omg its nlm

    omg its nlm lvl 17 Hax Folding Team

    Messages:
    1,829
    Location:
    Minnesota
    yeah, my main problem is we will be running reports more than once and want to make a short process to add data. Just wondering maybe in excel to code it VB to sort the data.
     
  7. CodeReliant

    CodeReliant OSNN Junior Addict

    Messages:
    22
    That is not easy. If all of the computers connected to a domain, you could create a group policy to run a scrip on everyones computer when they login. This script would map a drive, create a text file (named by the mac address because its unique), write the information to the text file and disconnect the drive. That way you have a network share consisting of all of the machines and their respective information.

    Then a small VB application can open each text file and import the data into access once a night. This is the way I proposed to my boss but....viruses and spam have taken priority.

    I have tried to find simpler ways to develop an accurate inventory without any luck. I would guess it would take 40hrs to perfect the process if you don't have alot of VB experience.

    Let me know if you find another solution.

    Dan
     
  8. omg its nlm

    omg its nlm lvl 17 Hax Folding Team

    Messages:
    1,829
    Location:
    Minnesota
    Its ran on norton ghost and will get the inventory, then is exported to a text file, from there I want to sort it in a database. From the text file I imported it to excel. Now I want to put that information into a data base. i.e. access.
     
  9. CodeReliant

    CodeReliant OSNN Junior Addict

    Messages:
    22
    it seems you really only have the option I mentioned above. Write a small vb application that will open the comma delimited excel files (assuming from your other posts) and import it into access. Its much simpler than trying to continually import by hand or trying to get VBA to manipulate the data in excel and import it into access.

    The program would be very small. If you go that route, Tutorials dealing with "sequential file access" and "database connections" would be helpful. Otherwise I don't have any other ideas.

    Dan
     
  10. omg its nlm

    omg its nlm lvl 17 Hax Folding Team

    Messages:
    1,829
    Location:
    Minnesota
    Alright, thanks for all your help :)
     
  11. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    At school they runa small C++ app, that reports:

    IP adress, Mac Adress, login date, username, computer stats.

    Once you log out, it runs another tool, to add an logout entry, this time also IP adress, mac ardress, logout date, and username but no computer stats.

    They have a database with all the Mac's to show where the Machine should be located, if we cannot locate it, they run a little app on that designated machine, that makes it ping its first uplink router, router logs this, and we know which floor its on. Now we enter room by room and look for the box.