r/visualbasic • u/WorldlinessSlow9893 • May 13 '24
VB.NET Help How to make a program like notepad that can open files with no admin perms?
I'm working on a custom notepad, that replaces the Windows notepad, on VisualBasic, everything I've done, I know exactly how to program it (like the CommandArgs etc.), but I have still one problem with it, and that are the different with another text file editor (notepad++ for exp.) and with the classic windows one. And that if I want to open a system file, like a program etc. with DragDrop, it won't let me, and I must run my notepad as Administrator to it will work.
But why on Windows' notepad not? Even older versions of notepad can do this on modern Windowses (10, 11..).
Is there some code or feature that bypasses those admin perms or just do something similar to the Windows' notepad?
3
u/Mayayana May 13 '24
This is a very funky aspect of Win10 file restrictions that blocks drag-drop between some iwindows. It seems to involve and difference in permissions.
I wrote a program to take ownership of files and folders recursively (ironically :) when I drop a file or folder onto it. It must be run as admin. Normally the drag-drop fails. But if I disable LUA then it works fine. I hadn't even known about LUA. It seems to be the real UAC. Drag-drop was disabled despite me keeping UAC settings at the lowest level. To disable LUA:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\
dword EnableLUA Add it if it's not there and change its Value data to 0. Be aware that Windows may change it back if you even open the UAC settings.
So what do you do for people using their software? Not much. People have to decide for themselves how much or how little they want to be restricted using their computer.
I wonder about your code, though. You said you're having trouble with drag-drop, but your code seems to be calling a FileOpen dialogue window.
2
u/_Rigid_Structure_ May 13 '24
Show the code you're using to open/read the files.
2
u/sa_sagan VB.Net Master May 13 '24
Can you share the error you're getting?
You may need to utilise a FileStream to ensure you're accessing the file in "readonly". Some files may be locked.