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 ---
I don't know that you can do that with VFP. Vague recollection is that it needs a callback function to complete the process. One needs to impersonate an account to get it to work.
What I've done in the past is launched a new program forcing the escalation.
HTH, Tracy
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Fred Taylor Sent: Tuesday, October 27, 2020 6:45 PM To: profoxtech@leafe.com Subject: Need way to change user to access protected folder
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]
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 :)
Hmm, vaguely remember doing this through the API more than 15+ years ago from a VFP app, but I did not take that code with me when I left as my work was ""owned" by my employer. I know it can be done, but I don't remember the details.
Fred
On Wed, Oct 28, 2020 at 2:09 AM Alan Bourke alanpbourke@fastmail.fm wrote:
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]
To be honest, for me this is a failing of network permissions policy. If your app is trusted to access this location by spawning an elevated process, why don't they just trust it to access the location all the time?
This might be what you are looking for: https://github.com/VFPX/Win32API/blob/master/samples/sample_554.md
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Fred Taylor Sent: Wednesday, October 28, 2020 10:36 AM To: profoxtech@leafe.com Subject: Re: Need way to change user to access protected folder
Hmm, vaguely remember doing this through the API more than 15+ years ago from a VFP app, but I did not take that code with me when I left as my work was ""owned" by my employer. I know it can be done, but I don't remember the details.
Fred
On Wed, Oct 28, 2020 at 2:09 AM Alan Bourke alanpbourke@fastmail.fm wrote:
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]
I found this on the fox.wikis.com:
https://fox.wikis.com/wc.dll?Wiki~RunAsAnotherUser~VB
Fred
On Wed, Oct 28, 2020 at 8:38 AM Tracy Pearson tracy@powerchurch.com wrote:
This might be what you are looking for: https://github.com/VFPX/Win32API/blob/master/samples/sample_554.md
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Fred Taylor Sent: Wednesday, October 28, 2020 10:36 AM To: profoxtech@leafe.com Subject: Re: Need way to change user to access protected folder
Hmm, vaguely remember doing this through the API more than 15+ years ago from a VFP app, but I did not take that code with me when I left as my work was ""owned" by my employer. I know it can be done, but I don't remember the details.
Fred
On Wed, Oct 28, 2020 at 2:09 AM Alan Bourke alanpbourke@fastmail.fm wrote:
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]
We need windows hosting for 4 users to run a single VFP9 SP2 app simultaneously. This can be windows 10 or server as long as 4 users can run the single VFP application simultaneously. Must be low cost and reliable. All users are in the USA.
We are now using server 2012 successfully, but the cost is too much and will increase 20% soon from the vendor we have been using. Not worth it for this 1 application.
I appreciate any suggestions.
Ken
On 11/17/20 2:30 PM, Ken McGinnis wrote:
We need windows hosting for 4 users to run a single VFP9 SP2 app simultaneously. This can be windows 10 or server as long as 4 users can run the single VFP application simultaneously. Must be low cost and reliable. All users are in the USA.
We are now using server 2012 successfully, but the cost is too much and will increase 20% soon from the vendor we have been using. Not worth it for this 1 application.
AWS is pretty cheap.
Ken,
I have a good friend that does just that...email me offline and I'll provide details.
Bill Anderson
On Tue, Nov 17, 2020 at 10:39 AM Ken McGinnis kamcginnis@gmail.com wrote:
We need windows hosting for 4 users to run a single VFP9 SP2 app simultaneously. This can be windows 10 or server as long as 4 users can run the single VFP application simultaneously. Must be low cost and reliable. All users are in the USA.
We are now using server 2012 successfully, but the cost is too much and will increase 20% soon from the vendor we have been using. Not worth it for this 1 application.
I appreciate any suggestions.
Ken
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
[excessive quoting removed by server]