Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing computer Name
Message
From
10/11/2004 05:04:53
Carl Dobson
Reference Point Computers
Overbury, Tewks, United Kingdom
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
00954066
Message ID:
00959898
Views:
24
ok I put the code in and it looks like this:
LOCAL answer
oldcname = ALLTRIM(THISFORM.txtoLD.VALUE)
newcname = ALLTRIM(THISFORM.txtNew.VALUE)

IF oldcname != newcname
	answer=MESSAGEBOX("Your computer is called " +oldcname +CHR(10) +CHR(13);
		+"Are you sure you want to" +CHR(10)+CHR(13);
		+"change it to " +newcname,3,"Confirm Computer name change")
*Write back the computer name here - goto new method
	DO CASE
	CASE answer = 2 &&& Cancel
*go back to page
	CASE answer = 6 &&& Yes
*change the computer name here
suspend
		lcComputer = "."
		loWMIService = GETOBJECT("winmgmts:" ;
			+ "{impersonationLevel=impersonate}!\\" + lcComputer + "\root\cimv2")
		colComputers = loWMIService.ExecQuery ;
			("Select * from Win32_ComputerSystem")
		FOR EACH loComputer IN colComputers
			loComputer.RENAME(ALLTRIM(THISFORM.txtNew.Value))
		NEXT
	
	test = GETENV("COMPUTERNAME")
	CASE answer = 7 &&& No
	THISFORM.RELEASE()
		CLEAR EVENTS
	ENDCASE

ENDIF
HOWEVER THIS DOESN'T WORK WHAT HAVE I MISSED ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform