Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing computer Name
Message
From
10/11/2004 13:33:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
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:
00960150
Views:
17
>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 ?

Carl,
CCed to me I assume you ask my 0.2 cents.
I think you were lucky it didn't work. I don't think you'd ever want to be responsible of the consequences it might cause. FWIW do not change computer name programmatically. If they want to do it they can use control panel at their own risk.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform