473,686 Members | 3,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change Computer Name -- not just NetBIOS Computer Name

Leaving network identification/DNS out of the picture, how does one
change the name of a computer in a local Workgroup (in C#)?

I implemented the SetComputerName () API call and that only seems to
change the NetBIOS Computer Name. I've verified that the underlying
registry key value that gets changed is:

HKEY_LOCAL_MACH INE\SYSTEM\Curr entControlSet\C ontrol\Computer Name\ComputerNa me\ComputerName

Is there a recommended API (via Active Directory or WMI or Win32) for
finishing the job and getting the local Computer Name changed?

Any help here greatly appreciated -- I'm under the gun on this one...

Michael Rose
-Unisys Corp
Jul 21 '05 #1
4 14293
Is there a recommended API (via Active Directory or WMI or Win32) for
finishing the job and getting the local Computer Name changed?


SetComputerName Ex ?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2

OK, thanks to Mattias I believe the API I want to use is
SetComputerName Ex. Now I just need to know how to invoke this from
C#. That is, does anyone know the P/Invoke definition for importing
this? Here's what I have for SetComputerName :
// PInvoke signature for SetComputerName in Kernel32.DLL
[DllImport("kern el32.dll")]
static extern bool SetComputerName (string lpComputerName) ;

I need the analogous PInvoke signature for SetComputerName Ex.

-Michael Rose

On Thu, 19 Feb 2004 13:19:44 -0600, Dr. StrangeDub
<st********@yah oo.com> wrote:
Leaving network identification/DNS out of the picture, how does one
change the name of a computer in a local Workgroup (in C#)?

I implemented the SetComputerName () API call and that only seems to
change the NetBIOS Computer Name. I've verified that the underlying
registry key value that gets changed is:

HKEY_LOCAL_MAC HINE\SYSTEM\Cur rentControlSet\ Control\Compute rName\ComputerN ame\ComputerNam e

Is there a recommended API (via Active Directory or WMI or Win32) for
finishing the job and getting the local Computer Name changed?

Any help here greatly appreciated -- I'm under the gun on this one...

Michael Rose
-Unisys Corp


Jul 21 '05 #3
Michael,
That is, does anyone know the P/Invoke definition for importing
this?


[DllImport("kern el32.dll", CharSet=CharSet .Auto)]
static extern bool SetComputerName Ex(COMPUTER_NAM E_FORMAT NameType,
string lpBuffer);

enum COMPUTER_NAME_F ORMAT
{
ComputerNameNet BIOS,
ComputerNameDns Hostname,
ComputerNameDns Domain,
ComputerNameDns FullyQualified,
ComputerNamePhy sicalNetBIOS,
ComputerNamePhy sicalDnsHostnam e,
ComputerNamePhy sicalDnsDomain,
ComputerNamePhy sicalDnsFullyQu alified,
}

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #4
Hey, thanks again Mattias.....Gla d to see that the P/Invoke signature
I ended up implementing (after a co-worker found the info) matches
exactly with what you entered.

Thanks again,
-Michael Rose
Unisys Corp

On Fri, 20 Feb 2004 01:05:26 +0100, Mattias Sjögren
<ma************ ********@mvps.o rg> wrote:
Michael,
That is, does anyone know the P/Invoke definition for importing
this?


[DllImport("kern el32.dll", CharSet=CharSet .Auto)]
static extern bool SetComputerName Ex(COMPUTER_NAM E_FORMAT NameType,
string lpBuffer);

enum COMPUTER_NAME_F ORMAT
{
ComputerNameNet BIOS,
ComputerNameDns Hostname,
ComputerNameDns Domain,
ComputerNameDns FullyQualified,
ComputerNamePhy sicalNetBIOS,
ComputerNamePhy sicalDnsHostnam e,
ComputerNamePhy sicalDnsDomain,
ComputerNamePhy sicalDnsFullyQu alified,
}

Mattias


Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1036
by: memememe | last post by:
I want to modify the computer name (the one used on netbios) before the configuration is read by netbios. I alreayd have a service that does this and I have created dependencies on this server for services such as netbios helper, ipsec, tcpip, etc. So in theory those services dont start before my service runs and changes the values on registry, yet my machine name only gets changed on my network places the next time I reboot showing the...
3
391
by: Vangelis | last post by:
Hi, I'm currently successfully retrieving the list of computers connected on the differents domains of our network via the System.DirectoryServices.DirectoryEntry class. What I'd like to have in addition of the computers name is their comment (just like when you browse over your network places on XP). The only way I found is querying the description field of
1
11732
by: Hakki | last post by:
We need to resolve with which computer my computer is communicating. We write a sniffer that gets pakets and so we resolve ip addresses and now we need to get their domain names. I think we need to use netbios protocol but I dont know how. How can we do this ...
4
2030
by: Dr. StrangeDub | last post by:
Leaving network identification/DNS out of the picture, how does one change the name of a computer in a local Workgroup (in C#)? I implemented the SetComputerName() API call and that only seems to change the NetBIOS Computer Name. I've verified that the underlying registry key value that gets changed is: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName Is there a recommended API (via Active...
2
1808
by: XiScO | last post by:
hi! I'm trying to get some info from other computers, I make ping to test that are powered on, then want to get netbios name and MAC. I get the dns name and get only first part as netbios (although this may be wrong,right?). Is there anyway to get netbios and mac of other computer? Thanks.
2
4760
by: martin lanny | last post by:
Simple network scanner is a part of my dotnet solution. It pings ip addresses in a selected network range and gives me the response time for each computer it finds. Anyhow, I would need to retrieve two more pieces of information for each active (local network) IP address: - Computer's Host Name - Mac Address
6
3588
by: DevX | last post by:
Hello, I have a big intranet that I run with IIS 6.0. I need to log the client's machine names, and I found on the web istruction on how to use REMOTE_HOST server variable while enabling Reverse DNS on IIS. Using also a query to the DNS retrieves only the names of machine that are registered in the DNS (like servers).
4
7043
by: madankarmukta | last post by:
HI, I want to set my computername to be greate than 15 bytes.How can i do that since when i set the name greter that 15 bytes it's give me message that "The NetBIOS name of the computer is limited to 15 bytes" . Can anybody tell me how can i edit this limit of 15 bytes of NetBIOS name ..? Thanks!
5
2129
by: Steve McKewen | last post by:
I am working on Windows Mobile 6 with VS2005. I want my mobile devices to connect to a shared folder on a PC in an isolated network environment. I don't have a server or router in the network, so don't have a DNS server. I can ping the PC using its IP address, but not its hostname. I have written a ping routine using a dotnet socket to send an IcmpPacket. I can connect to the shared folder by the hostname but not the IP address. I am...
0
8581
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8514
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8766
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8778
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.