Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Changing computer Name
Message
 
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:
00960161
Views:
9
>HOWEVER THIS DOESN'T WORK WHAT HAVE I MISSED ?


You should specify Username and Password (and it must be from some administrator) for they are not optional, if you print the error (? loCS.Rename(lcNewName)) You'll probably see the error is 2221, which is "User name could not be found"

A shorter way of doing it is:
loWMIService = GETOBJECT("winmgmts:")
loCS = loWMIService.Get("Win32_ComputerSystem.Name='" + Getenv("COMPUTERNAME") + "'")
if loCS.Rename(lcNewName, lcAdminUser, lcAdminPassword)
  ? 'You need to reboot'
endif
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform