Solved

Get Unique PC Identifier

Posted on 2013-05-25
11
730 Views
Last Modified: 2013-05-26
Hi.  I have a piece of software that I run on multiple machines.  Currently you have the option of running it remotely off of the server db or off of the db on the local machine.  I currently have all of the machines that use the software listed in a dropdown so that the user can either check "Remote" or the name of their machine, and the software finds the database from the machine name.  It works fine but I would like to simplify it and allow them to simply choose "Remote" or "Local".  If they choose "local, it will find the database on the machine that they are on.  

When I am working on another machine I constantly choose my normal machine and then I have to wait until it times out because it can't find it (since that is not the machine that I am on) before I correct my mistake.  There has to be a way to "find" the database on the local machine without hard-coding the name into a dropdown???

Any help?
0
Comment
Question by:Bob Schneider
11 Comments
 
LVL 14

Assisted Solution

by:Faustulus
Faustulus earned 83 total points
Comment Utility
Couldn't you let the program search for the db in a certain sequence, like, IF the db is found on the local machine, use that db, else look for the db on a remote server?
If you need a method to force the program to select the db of the user's choice you might add a drop-down with the choices "Auto" and "Select" where the former is the process I have just described and the latter the one you presently have.
0
 

Author Comment

by:Bob Schneider
Comment Utility
Good suggestion but I want to be able to choose local or remote because it is quicker to run it off of the local db than the server, but how can I get it to look for a local db?  Here is my current connection string:

    If sWhichSrvr = "Remote" Then
        conn.Open "Provider=SQLNCLI10;Server=216.185.199.1,1433\SQLExpress;Database=VIRA;Uid=uid;Pwd=pwd;"
    Else
        conn.Open "Provider=SQLNCLI10;Server=" & sWhichSrvr & "\SQLExpress;Database=dbname;Trusted_Connection=yes;"
    End If

Open in new window

0
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 83 total points
Comment Utility
If there is an Install procedure for your program, I would have it make an 'ini' file that tells whether there is supposed to be a local database server or not.  If there is not, then it should always connect to the remote.  If it is local you could store the local part of the connection string in the 'ini' file.
0
 

Author Comment

by:Bob Schneider
Comment Utility
Actually I just run it out of the exe for now...may change that later.  Can I conclude that there is no way to determine the machine name or some other identifier using vb6?
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 334 total points
Comment Utility
Can I conclude that there is no way to determine the machine name or some other identifier using vb6?
There are Windows API calls to identify the machine name.  I can look it up if you want.

Alternatively, you can reduce the connection time so that you do not have to wait 30 seconds.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Bob Schneider
Comment Utility
I would love to know how to do a Windows API Call to identify the machine name if you would be so kind.
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 334 total points
Comment Utility
Here is one example I found:
http://www.vb6.us/tutorials/simple-windows-api-example

There was a site I used to use around 10 years ago that had every possible Windows API call that you could possibly think of using VB6, but for the life of me the name escapes me.  If i find it I will post it.
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 334 total points
Comment Utility
Here it is:  VBnet Visual Basic Developers Resource Centre

P.S. Don't let the VBnet name fool you, it is all Visual Basic classic.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 334 total points
Comment Utility
On second thoughts, you may not need to use a Windows API (although that would certainly work).  There are a couple of other options:
1. The environment variable COMPUTERNAME contains the name (this should be simple call).  This can be spoofed though.
2. You should be able to use the WScript.Network object model to get it also.
0
 

Author Comment

by:Bob Schneider
Comment Utility
Awesome!  Thank you!!
0
 

Author Closing Comment

by:Bob Schneider
Comment Utility
Great stuff!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The use of stolen credentials is a hot commodity this year allowing threat actors to move laterally within the network in order to avoid breach detection.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

763 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

9 Experts available now in Live!

Get 1:1 Help Now