-1

I want to get the computer user profile name to put log text on the appData

note: This is just for IE, (currently using this for windows 7 gadget)

The default would be, without profile name is this

C:/Users/user/AppData/Local/sampleFolder/

but when there is a profile name on it, what should it be?

C:/Users/{profileName}/AppData/Local/sampleFolder/

My fixed solution (but I recommend the accepted answer)

function GetComputerName()
{
    try
    {
        var network = new ActiveXObject('WScript.Network');
        // Show a pop up if it works
        alert(network.computerName);
    }
    catch (e) { }
}
Robin Carlo Catacutan
  • 13,249
  • 11
  • 52
  • 85
  • 1
    Is this in the browser? If so, I'm pretty sure that information isn't exposed. – James M Jan 23 '12 at 01:48
  • You can't access this with JavaScript. – j08691 Jan 23 '12 at 01:50
  • Am I getting this right? You're trying to create a file on the user's computer with JavaScript inside a regular browser? Sorry, but that is hilarious! Why don't you directly create a virus? – buschtoens Jan 23 '12 at 01:52
  • You probably can access this in JavaScript in IE only with the proper security settings. This is definitely not something that is recommended. JavaScript should not be used in this way due to security restrictions in the browser. What kind of application are you working on? – SoWeLie Jan 23 '12 at 01:52
  • @j08691 I can do this on javascript refer to this link (http://stackoverflow.com/questions/922476/how-can-i-read-the-clients-machine-computer-name-from-the-browser) – Robin Carlo Catacutan Jan 23 '12 at 02:02
  • 1
    Thanks for reminding me why I don't use IE! – James M Jan 23 '12 at 02:02
  • @silvinci Your not getting this point. Your wrong and right at the same time, You can't create file on user's computer unless it's on system folder, but you can create files on some folder refer to this (http://www.tek-tips.com/viewthread.cfm?qid=1171273) – Robin Carlo Catacutan Jan 23 '12 at 02:05
  • @SoWelie Yes, I'm not refering this to the browser. I'm just stating the example path of the folder I want to put. – Robin Carlo Catacutan Jan 23 '12 at 02:06
  • @j08691 duh! I know that already. Been using ActiveX Object all the time. Haven't tried? tsk – Robin Carlo Catacutan Jan 23 '12 at 07:50
  • @JamesMcLaughlin LOL, yes one of the many reasons why I will never use IE for anything other than testing (only because people won't get a better browser). – SoWeLie Jan 23 '12 at 15:28

1 Answers1

1

I believe that would just be the users name, which should be:

network.username

This page looks like a guide to the object you are creating (for future reference).

LoveAndCoding
  • 7,857
  • 2
  • 31
  • 55