How to know Computer Profile name using Javascript

1k views Asked by At

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) { }
}
1

There are 1 answers

0
LoveAndCoding On BEST ANSWER

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).