There's no way to elevate an already running process, so you have to 
encapsulate that in a separate EXE and run that with elevated permissions.

This could be as simple as creating a batch file and in there use the 'runas' 
command.

runas /noprofile /user:mymachine\administrator myexe.exe

Then run the batch file from your main VFP executable.

The problem with this is that it's inelegant and prone to prompting for 
credentials.

You could try doing it in VFP code using the Windows API:

Download the Win32API project from https://github.com/VFPX/Win32API

Extract somewhere and run apiviewer.exe

Search for 'how to start a process as another user'

That should display a VFP program illustrating how to leverage the Windows API 
to do it. And you're in a world where you now have to worry about the password 
being stored in plaintext in your program :)




-- 
  Alan Bourke
  alanpbourke (at) fastmail (dot) fm

On Tue, 27 Oct 2020, at 10:44 PM, Fred Taylor wrote:
> Anybody have a way to change the user while an app is running so I can
> access a protected folder?  Haven't done much Windows API in quite some
> time.
> 
> 
> Fred
> 
> 
> --- StripMime Report -- processed MIME parts ---
> multipart/alternative
>   text/plain (text body -- kept)
>   text/html
> ---
> 
[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: https://leafe.com/archives
This message: 
https://leafe.com/archives/byMID/313b513e-cc45-46e0-8918-17137af4d...@www.fastmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to