Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clients ip address in an HTA document 1

Status
Not open for further replies.

wenche1

Programmer
Sep 17, 2006
4
NO
Hi Guys

We have a HTA solution for our Intranet and I am looking for a way to pick up the clients IP address and store it as a hidden variable in the HTA so it can be sent as a login (rather than normal login with name/password) Is this doable??

May be this is not the right place for this question, but hope someone would answer anyway

Thanks
Wenche
 
wenche1, if your app uses a web server then it is easiest to get the ip address from the server.

If you are running your HTA as a standalone app on the desktop then you could use a shell to grab the data.

Look at this link:

It has a vbs file that will do a lookup of all ipaddresses on the current PC using wscript.shell and the FileSystemObject.
It can be simplified a bit for your own use. It is VBScript rather than Javascript but there is not a lot of difference between the two if you wanted to convert it.

Good luck.

At my age I still learn something new every day, but I forget two others.
 
To:eek:p
This function will give you the ip address(es) including connected ppp adapters.
[tt]
function getipaddr() {
var fso=new ActiveXObject("scripting.filesystemobject");
var stmpfolder = fso.GetSpecialFolder(2); //temporary folder:2
var stmpname = fso.GetTempName();
var stmppath=stmpfolder+"\\"+stmpname;
(new ActiveXObject("wscript.shell")).run ("%comspec% /c ipconfig.exe > " + stmppath,0,true);
var sdata=fso_OpenTextFile(stmppath).ReadAll();
fso=null;
var adata=sdata.split(/\n/g);
var aipaddr=new Array();
for (var i=0;i<adata.length;i++) {
if (adata.toLowerCase().indexOf("ip address") != -1) {
var acomp=adata.split(/:/g);
if (acomp[1].replace(/\s/g,"") !="0.0.0.0") {
aipaddr.push (acomp[1].replace(/ /g,""));
}
}
}
return aipaddr;
}
[/tt]
And you can store the data to the page. This is how just to alert what you get after calling the function.
[tt]
var aipaddr=getipaddr();

for (var i=0;i<aipaddr.length;i++) {
window.alert(aipaddr);
}
[/tt]
 
Amendment
>[self]aipaddr.push (acomp[1].replace(/ /g,""));
should be read:
[tt]aipaddr.push (acomp[1].replace(/[blue]\s[/blue]/g,""));[/tt]
 
Thanks guys for great response and yes, I need to find IP on the client machine and tsuji gave me even the code[dazed]
Thanks alot tsuji, you earn a star for that[gorgeous]

Keep up the good work guys, this is most helpful to us

Wenche
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top