I am trying to resolve %USERPROFILE% using WScript.Shell. When I create a vbs file and run directly from Windows, I get the correct path for the logged-in user C:\Documents and Settings\Administrator but it gets resolved to C:\Documents and Settings\Default User instead of logged-in user when I used it inside my classic ASP webapp running on the local machine on IIS.
The code I used is as below
var oShell = new ActiveXObject("Wscript.Shell");
var userPath = oShell.ExpandEnvironmentStrings("%USERPROFILE%");
Is there a permission/setting which I need to check to get correct value of USERPROFILE when retrieving value from the webapp?
PS: I am using javascript to code.
ASP does not know what user is logged in, it runs under a generic anonymous internet user account.
If you want IIS to know the current user, you will have to remove rights for the anonymous user on the directory of your site. This will force IIS to show your users a login screen.
After they log in, the thread for that session will run under the logged on user (so make sure that user has rights). You can now use request.servervariables(“AUTH_USER”) to get the username.
Erik