View Full Version : Get Computer Name?
NitLions
02-18-2008, 01:06 PM
How can I get the computer name on which my AMS browser is running? Do I have to use GetLANInfo or is there another way?
I have to determine if the computer name contains "_" (underscore) with String.Find, I guess. If so, I need to warn the user that our Web application may not work properly with an underscored system name (why, I have no idea - that's for the hardcore developers to figure out). Then I guess I'll kill the app or do whatever I am directed to do by the decistion makers at that point.
Any help appreciated.
TimeSurfer
02-18-2008, 01:27 PM
yes you need to use getlaninfo,
as far as checking for an underscore in the return you can use string.find with some regex or you can use my free RegXmATCH.dll which is posted under ams7 discussion [also works for ams6] as it allows you to perform a regex match on any givin text.
NitLions
02-18-2008, 01:51 PM
Here's what I came up with since my initial post:
tblHost = System.GetLANInfo();
strfound = String.Find(tblHost.Host, "_", 1, false);
if strfound >= 1 then
--underscore found
Dialog.Message("Problematic Server Name...", "The system on which you are trying to install Our App contains an underscore (_) in the system name.\r\nOur App will not function properly under this condition. The system's IP address must be used!", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
--May have to do something else here...
end
Does anyone see any pitfalls or should this do the trick?
TimeSurfer
02-18-2008, 01:53 PM
that should work fine. quick question though why would an underscore cause a problem im a lil confused. Perhaps if you can explain some more i might be able to help you fix it.
NitLions
02-18-2008, 01:58 PM
After our app is installed, one must connect to the server on which it is installed to login, of course. If the server name contains an _, flakey things happen at login, I guess. I don't really know the details, but for some reason, if the name contains an _, they must use the IP address in the browser to connect.
TimeSurfer
02-18-2008, 02:06 PM
hmm, very odd. I wouldn't think an underscore would cause a problem though as its just a standard character. And i dont think you need to escape an underscore, could be wrong though lol. But what you just did should serve your purpose.
The underscore is not a legal character for use in hostnames (defined in RFC 822).
It is, what it is. :)
leebos
02-23-2008, 04:32 PM
How can I get the computer name on which my AMS browser is running? Do I have to use GetLANInfo or is there another way?
I have to determine if the computer name contains "_" (underscore) with String.Find, I guess. If so, I need to warn the user that our Web application may not work properly with an underscored system name (why, I have no idea - that's for the hardcore developers to figure out). Then I guess I'll kill the app or do whatever I am directed to do by the decistion makers at that point.
Any help appreciated.
The following will do it.
cname = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ ComputerName", "ComputerName", true);
Lee
longedge
02-24-2008, 02:22 AM
The following will do it.
cname = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ ComputerName", "ComputerName", true);
Lee
Something very strange. On my system there is a space displayed between the slashes in "ComputerName\\ComputerName" but looking at it as it is quoted while I am typing this, there is no space.
Now doing a preview, I can see the space again???
Copy and paste into AMS and it fails until I remove the space
Is that how other people see it? There should of course not be a space there.
leebos
02-24-2008, 07:33 AM
longedge, you are correct, there should be no space. I copied it directly from one of my apps so I don't know how the spage got there. Here is another copy/paste.
cname = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ ComputerName", "ComputerName", true);
Now I see the trouble, it's caused by this website apparently as It looks ok until I preview it.
IR, you need to look at this.
Lee
longedge
02-24-2008, 09:51 AM
Is there a control character or something in there? Very odd.
leebos
02-24-2008, 02:01 PM
Is there a control character or something in there? Very odd.
No control characters, I retyped it to be sure.
cname = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ ComputerName", "ComputerName", true);
Leaving out double \
cname = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\ComputerName\Comp uterName", "ComputerName", true);
Now it moves the extra space, strange indeed.
Here are is a few more lines from the same app. The one that gets the Workstation number is ok, the one that gets the Computer Description has the extra space after lanmanserver.
wsnum = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment", "workstation", true);
descript = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\lanmanserver\ \parameters", "srvcomment", true);
Lee
inlinex
05-31-2008, 11:40 AM
10x it works well,:yes
ShadowUK
05-31-2008, 12:44 PM
No control characters, I retyped it to be sure.
cname = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ ComputerName", "ComputerName", true);
Leaving out double \
cname = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\ComputerName\Comp uterName", "ComputerName", true);
Now it moves the extra space, strange indeed.
Here are is a few more lines from the same app. The one that gets the Workstation number is ok, the one that gets the Computer Description has the extra space after lanmanserver.
wsnum = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment", "workstation", true);
descript = Registry.GetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\lanmanserver\ \parameters", "srvcomment", true);
Lee
It's vBulletin thinking someone is spamming, thinking adding spaces will make a difference.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.