Solved

Changing the computer name under Windows XP...

Posted on 2002-06-17
4
155 Views
Last Modified: 2010-05-18
I'm not sure if this even counts as a VB question or not, but what the hoo..

I'm trying to change the computer name from within a simple VB app I've written.  The original plan was to create a .REG registry file to change the ComputerName key, but under Xp, changing that key has no effect.

I'm an old time .batch file geek, and I don't know two halves about VB.. if I could use a batch file to achieve my goal just as easily, I'd be doing that instead of using VB... but a text interface just isn't the same thing as a simple VB form.  :)  So please gear your answer with my incompitence in mind.

If this is not something that can easily be done through VB, I'll call this question a wash and put it under the Win XP section, but I expect that someone somewhere has tried to do this under VB...

Thank you for your help.
0
Comment
Question by:EDStech
  • 2
  • 2
4 Comments
 
LVL 2

Author Comment

by:EDStech
ID: 7084221
Also if it matters...

I'm using Visual Basic 6.
I'm using Windows XP Pro.
These machines are not on a domain.

Thanks.
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 100 total points
ID: 7084241
you can use SetComputerName api:

Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long

Private Sub Command1_Click()
    Dim retVal As Long
    retVal = SetComputerName(Text1.Text)
end sub
0
 
LVL 2

Author Comment

by:EDStech
ID: 7084289
Well heck, that was easy.  Perfect!

Thank you.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7084335
welcome :)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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