Script to Validate PC

Posted on 2012-08-31
Last Modified: 2012-09-08
I'm looking to find a way to validate Computers by running a .bat or .vbs or similar file on them.

To start with there will be a MySQL table on a web server with the following columns
Unique ID, Company Name, Date, Time, ComputerName, LastUserName

The script should:

1) Generate a Unique ID, Preferably from something hardware so even is the OS is reinstalled it will still validate. It should be the same every time its generated from that computer.

2) Query an SQL server to find out if that Unique ID is already listed in table.

3a) If its already listed, It should update the record with the current Date, Time, ComputerName and Current UserName

4a) It should display a green pop up as below

[Blank line]
PC Unique ID: .....
[Close Button]


3b) If its not already listed, It should display a red pop up as below
[Blank line]
PC Unique ID: .....
Computer Name: ......

Authorise This PC:
Password: [Password entry box]
Company Name: [Plain Text Entry Box]
[Close Button]

4b) Assuming the password is correct the Unique ID, Company Name, Date, Time, Computer Name and Current UserName should be entered into the MySQL database. the program should loop back to the start to validate the computer against the database (this should now be fine)

Any idea, how to make this? or who we should talk to in order to get it made?
I cant see the code being particularly complex as scripts go, I'm fairly adaptable so if you point me towards the correct resources that I can cut,edit,mix and match from I would hopefully be able to create it myself.

Thanks a Great Deal
Question by:tetrauk
    LVL 20

    Expert Comment

    One part: The MAC address of the network interface suggests itself as identifier.
    For the rest I suggest a web-based form. For example, this allows arbitrary client operating systems, you just need a browser.
    IF the web server is in the same LAN as the client, it can determine the client's MAC by itself. However, you'd need to pull the username and computername environment variables - see here for example for hints applicable to Windows:
    LVL 33

    Expert Comment

    by:Todd Gerbert
    I agree with thehagman's comment above. I would only add that - assuming you're in a PC-only Active Directory environment, and you are the administrator - it seems like either a computer startup script (written in either JavaScript or VBScript), or a user login script, assigned via Group Policy would be the way to go.

    You shouldn't have too much trouble coming up with a simple script that connects to a SQL server - there are more than enough examples available everywhere you look.

    (Incidentally - your question kind of reads like you expect to provide us with a list of project requirements, and expect a completed piece of work, though I realize that may not have been your intention. Nevertheless, I'm more than happy to help, teach, or advise - but I have no intentions on doing your job for you. ;)
    LVL 1

    Author Comment

    tgerbert - It is actually the project spec I posted on freelancer, but I was asking here to figure out if I could do it myself. I'm not great at coding but will give anything a go!!!

    I'm looking here more for tips on how to connect and run an sql query from vbs or bat files. How to extract a mac address or other to a variable in a bat or vbs... things like that
    LVL 65

    Expert Comment

    Hi tetrauk,

    There's code here to read data from mySQL, requiring a DLL driver, although it's a bit old, so there's probably an updated driver by now:

    For the MAC address, you can use this code:

    So, based on retrieving the MAC address, you could query mySQL for a matching record, and update as necessary.

    If you can get working bits of code to do those two things, I can help you piece it together for the final outcome.


    LVL 1

    Accepted Solution

    Have solved this myself, used the wmic command in a bat file to get a unique id, dumped it to a variable and put it into a start iexplorer.exe command.
    After that everything is php and mysql, I've learnt a LOT!!!
    LVL 1

    Author Closing Comment

    have resolved this myself

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now