API to get hostname from Jscript
I am not sure why my previous post was not listed. Lets see if this one gets listed. I have a stand alone jScript which passes parameters to a C# program. I have to pass hostname to the C# program. Is there an api which I can use to get hostname in the jScript if not can I do it using the 'hostn开发者_运维知识库ame' system command?
Thanks in Advance. Sam
Since you're using JScript I assume you're running under Windows. You can get the current computer's name from the environment:
var env, computerName;
env = new ActiveXObject("WScript.Shell").Environment("Process");
computerName = env("COMPUTERNAME");
...if that's what you mean by hostname. More on environments (there are more than one available, above I picked the process's environment) here.
精彩评论