lothos12345 Posted November 15, 2006 Posted November 15, 2006 I have written a visual basic.net class who's sole purpose is it get the user name and process id of a person that is running the particuliar application in which has this class and use that information to create a unique directory with a particularily name text file. This application works great if I am logged in as administrator into the machine but if I log in as someone else I cannot get the process information nor can I get the right to create the unique directory. Ideally the solution would be to increase the permissions of the Logon, unforunately this is not an option. I need the ability to do perform all the required actions as with administrator powers though I am logged in as the lesser user. This needs to be done in code. Any examples or help would be greatly appreciated. Quote
Administrators PlausiblyDamp Posted November 15, 2006 Administrators Posted November 15, 2006 Does any of this work as a non-admin? Does it fail to get the username, processid or both? Also where are you creating the new directories? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
lothos12345 Posted November 15, 2006 Author Posted November 15, 2006 The app opens and I can read the registry but I cannot read any process information to include the username and id. I am trying to create a directory in the Startup path of the application. I have thought of something but I am not sure how to accomplish it. Is there a way I can run the app as administrator and program this from the application? Quote
anthony Posted December 12, 2006 Posted December 12, 2006 Half the applications in the world won't work because of permissions.It's too bad. Quote
*Experts* Nerseus Posted December 14, 2006 *Experts* Posted December 14, 2006 You can't force your program to run as an Admin. If you need to safely create a folder on the user's hard drive, it's recommended to use either the temporary folder or the folder under My Documents (I think). I can't recall how to reference either of those (maybe through the Environment class?), but it's a start. You can always ask again, if this seems to fit with what you need. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
alreadyused Posted December 14, 2006 Posted December 14, 2006 (edited) directories I have no clue if you can get to these (due to permissions) but since Nerseus mentioned them, here's how to get to MyDocs, AllUsers\AppData and username\LocalSettings\AppData 'with sb as a stringbuilder: ' ' 'User's Desktop sb.Append(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)) ' 'User's MyDocs sb.Append(Environment.GetFolderPath(Environment.SpecialFolder.Personal)) ' 'user specific: ...\\docs & stgs\\username\\local settings\\app data\\... note "localsettings" sb.Append(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) ' 'all users: ...\\docs & stgs\\all users\\app data\\... note no "localsettings" sb.Append(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)) Edited December 14, 2006 by alreadyused Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.