Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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.
Posted
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?
  • 4 weeks later...
  • *Experts*
Posted

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

"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
Posted (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 by alreadyused

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...