1

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 'hostname' system command?

Thanks in Advance. Sam

Sam
  • 453
  • 2
  • 6
  • 10

1 Answers1

5

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.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875