Solved

Changing the computer name under Windows XP...

Posted on 2002-06-17
4
150 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 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

19 Experts available now in Live!

Get 1:1 Help Now