WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

System UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Set Computer Name on 2000 and XP


keywords: Intcontrol 76 rename computer name computername set change

Problem setting the computer name on Windows 2000 or XP. This UDF is designed for Windows 2000/XP/2003 It is a workaround for a problem with IntControl 76 not setting the DNSHostName.
#DefineFunction SetComputerName(computername)
	;This function is designed for Windows 2000/XP/2003
	;It is a workaround for a problem with IntControl 76
	;not setting the DNSHostName
   if WinVersion(1) < 5
	   Message("Error","This function is not supported on the platform")
		Return(0)
	endif
	dllname = StrCat(DirWindows(1),"Kernel32.dll")  
	ret = DllCall(dllname, long:"SetComputerNameExA", long:5, lpstr:computername)
	if ret == 0
		Message("Error",DllLastError())
		Return(ret)
	endif
	return(1)
#EndFunction

ret = SetComputerName("OTIS")
if ret == 0
	Message("Error","Unable to set computer name")
	Exit
endif
Exit

Article ID:   W16734
File Created: 2005:02:18:12:22:06
Last Updated: 2005:02:18:12:22:06