How to check user permissions
Moderator: Rathinagiri
How to check user permissions
Dear Frens,
Marhaban ya Ramadhan
How to code for checking user permission for a folder in order to create/write a file/s....
Is there anyway to change/get the write permission on a folder.
It's on win10 os
TIA
Best rgds
Chang
Marhaban ya Ramadhan
How to code for checking user permission for a folder in order to create/write a file/s....
Is there anyway to change/get the write permission on a folder.
It's on win10 os
TIA
Best rgds
Chang
Last edited by hmgchang on Sat May 19, 2018 9:27 pm, edited 1 time in total.
Just Hmg It !
Re: How to check user permussions
Chang
Without coding in C, you can check if you have permission to write to the directory by trying to create a temporary file in this directory.
Example:
Without coding in C, you can check if you have permission to write to the directory by trying to create a temporary file in this directory.
Example:
Code: Select all
#include "fileio.ch"
#include "hmg.ch"
FUNCTION Main()
LOCAL cDir := "C:\Program Files"
IF HB_DirExists(cDir)
MsgBox(cDir + CRLF + CRLF + If(IsDirWritable(cDir), "You can write in this directory.", "You have not permissions to write in this directory!"))
ELSE
MsgBox(cDir + CRLF + CRLF + "Directory not found!")
ENDIF
RETURN NIL
FUNCTION IsDirWritable(cDir)
LOCAL cFileName
LOCAL nFileHandle
nFileHandle := HB_fTempCreate(cDir, NIL, FC_NORMAL, @cFileName)
IF nFileHandle != F_ERROR
fClose(nFileHandle)
fErase(cFileName)
RETURN .T.
ENDIF
RETURN .F.
Re: How to check user permissions
Yes and thanks KDJ,
what I don't understand is, I may copy files to my c:\, but
within hmgExe, I can not save a text file by hb_Memowrit to my c:\
any suggestion ?
TIA
best rgds,
Chang
what I don't understand is, I may copy files to my c:\, but
within hmgExe, I can not save a text file by hb_Memowrit to my c:\
any suggestion ?
TIA
best rgds,
Chang
Just Hmg It !
Re: How to check user permissions
No program is alowed to write to the root folder since win 7
Angel Pais
Web Apps consultant/architect/developer.
Web Apps consultant/architect/developer.
Re: How to check user permissions
1. If you run KDJ's program as Administrator in windows then Program is allowed to write to the root folder
You can get applications to write to Program Files by changing the folder's security settings.
1. Go to properties and select the Security tab.
2. Click Advanced.
3. Change ownership to your own account instead of TrustedInstaller, and let it propagate. This allows you to add yourself to the list of principals.
4. Click 'Add' and type your username, press 'Check names' and it auto-corrects.
Now you can add 'Full control' for your username, and all applications you run should be able to write to this folder and its sub folders.
Or
Always Run a Program as Administrator in Windows:
Create shortcut of your program, Select shortcut, right click with mouse Go to the properties, and there you will find a button labeled “Advanced.” Click on it. Check the “Run as administrator” box, and then press OK. From now on, this shortcut icon will run the program with administrator's privileges all the time
OrYou can get applications to write to Program Files by changing the folder's security settings.
1. Go to properties and select the Security tab.
2. Click Advanced.
3. Change ownership to your own account instead of TrustedInstaller, and let it propagate. This allows you to add yourself to the list of principals.
4. Click 'Add' and type your username, press 'Check names' and it auto-corrects.
Now you can add 'Full control' for your username, and all applications you run should be able to write to this folder and its sub folders.
Or
Always Run a Program as Administrator in Windows:
Create shortcut of your program, Select shortcut, right click with mouse Go to the properties, and there you will find a button labeled “Advanced.” Click on it. Check the “Run as administrator” box, and then press OK. From now on, this shortcut icon will run the program with administrator's privileges all the time
- Attachments
-
- Untitled2.png (29.18 KiB) Viewed 5606 times
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
Re: How to check user permissions
Dear Apais,
Dear Bpd2000,
Thanks for the tips
1. Can we set the Administrators rights to the hmg Exe ?
2. Wil the rights remain if we rebuild the Exe ?
TIA
best rgds,
Chang
but I can copy/paste files to the c:\ with win explorerNo program is alowed to write to the root folder since win 7
Dear Bpd2000,
Thanks for the tips
1. Can we set the Administrators rights to the hmg Exe ?
2. Wil the rights remain if we rebuild the Exe ?
TIA
best rgds,
Chang
Just Hmg It !
- dragancesu
- Posts: 921
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: How to check user permissions
I have not tested / knowledge but it can be done through necessary changes / addition in Manifesthmgchang wrote: ↑Sun May 20, 2018 9:54 pm Dear Apais,but I can copy/paste files to the c:\ with win explorerNo program is alowed to write to the root folder since win 7
Dear Bpd2000,
Thanks for the tips
1. Can we set the Administrators rights to the hmg Exe ?
2. Wil the rights remain if we rebuild the Exe ?
TIA
best rgds,
Chang
Claudio / Gfilatov / Rathinagiri may help you
Code: Select all
<requestedExecutionLevel
level="asInvoker|highestAvailable|requireAdministrator"
uiAccess="true|false"/>
Another way is Pack your app into WinRar SFX with silent mode + admin request mode.
I have tested and is working smart
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
Re: How to check user permissions
Finally I have managed to generate Manifest file to run app with Admin rightsBpd2000
1. Can we set the Administrators rights to the hmg Exe ?
2. Wil the rights remain if we rebuild the Exe ?
You have to add reference of manifest file in RC file
Finally working example of app run as Administrators rights
My OS is Win-10, request other users to check it is working Ok or not
- Attachments
-
- Permission.rar
- (1.21 MiB) Downloaded 273 times
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG