Starting a python file when a computer starts - python

I am trying to run a python file when my Windows 10 computer starts up. I've already coded the file. It asks for a password and if its incorrect, it shutdown the computer. If the password is correct, it ends the file and lets the user to continue.
I've looked around but all i can see is how to do it with batch files or solutions to do it when a user logged in, im the only one that uses my machine and there is only 1 user
I've heard something about searching for a 'startup' folder but cant find it. Any ideas?
P.s if you know how to get to the start up folder that could help as well

Place your python file in the Startup folder. The folder is located at
C:\Users\<user-name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Make sure you have enabled Show hidden files. The AppData folder is a hidden folder so you won't find it if you don't enable it.

Related

Is there a way to hide a folder even when "show hidden files" is checked using python?

I've been wanting to make a program that hides a folder that has a lot of my sensitive files on it. I use python as my main programming language.
I need a way to hide the folder from Windows Explorer, even if the "Show Hidden Files" option is checked. I know how to hide it normally, right-clicking on the folder and checking the "hidden" option, but I need users to not be able to see it at all. I also need to be able to unhide it using the same program.
If anyone knows a solution, please let me know!
Thank you!
Theoretically, you could make a program that loads your folder into the RAM on startup while deleting it and re-saving the folder on shutdown, however this would be very risky when you press "shutdown anyways". If a certain condition is met, you could show the folder(e.g. saving it to file system).
Another Idea would be to try to remake it as the very infuriating folder in C:\Program Files\WindowsApps which you can only access in command-line
Also if you are able to complete this project, I would be very interested in using it too.
I have opted for a secured, hidden folder marked as hidden, system reserved and encrypted, and requiring a python script to unlock. Using the attrib DOS command, but it does the trick. I'm also using EFS encryption on the folder, so even if the system and hidden attributes are cleared, people still can't access it.

How to close a specific folder with Python

I am trying to make a simple program that closes a specific folder every time it gets opened to deny access to said folder. I've tried using VBScript , and the codes I was given worked at first, but they failed after some circumstances (like trying to open the specific folder a lot of times in quick succession, or sometimes even after closing an unrelated folder).
The folder I'm trying to close is C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

Can you stop PyCharm from automatically closing script files when you click out of the program?

I am having a problem with PyCharm (Community Edition) in that, when I open a .py file in the program, I can happily read and write in the file as usual, however when I click out of PyCharm (to look my emails for example) and then click back into it to carry on with my code, the file automatically closes and the project tree structure collapses (so I have to re-open it every time).
So far I have tried changing the tab limit to a high number, but this doesn't seem to help (and it shouldn't be related, since this happens when I open just one file).
I had the same issue before. I'm assuming you're connected to a network shared folder via UNC path (e.g. \\foo\bar\)?
If so, it is not currently supported. You'll need to map your network folder and give it a Drive letter. Then load up your project using the mapped drive, and it'll work like a charm.
If that's not the scenario though, please give us more information.

Hidden .db files using Python and SQLite3

I am using sqlite3 and python for a new website I am creating. The problem is, the "files_storage.db" file I am trying to create will not appear in any Windows 10 Folder Window, PyCharm's Directory View, nor will it appear via the command line interface.
The catch to this is, if I execute my python script multiple times, I get an error that states the database file already exists... So this file is somewhere, I guess it is a game of cat and mouse to find it.
I have ran into this problem before, but I have ALWAYS been able to find the file via the command line. Usually, I wouldn't both yall with such a question but, this is really irking me and I am going to run into serious issues when it comes time to put this baby on a server. :(
thanks in advance, and here's some screenshots I suppose.
You are using a relative file path.
Relative paths are converted to absolute ones by something like os.path.join(os.getcwd(), <relative path>). So they depend on the current working directory of the process.
Try to open it with an absolute path (starting with drive letter) to avoid any ambiguities.
If you use just a filename without a path, the file will be saved in whatever the current working directory of the Python interpreter is.
To see where the current working directory is, add the following code to the beginning of your program:
import os
print(os.getcwd())
You should then see the working directory in the output.
There is a setting for the current working directory in your IDE somewhere. See e.g. the answers to this question.
You can also do something like:
import os
path = os.path.expanduser("~") + '/Documents'
print(path)
This will allow you to access the directories for the current user. For me, this prints:
'/Users/thomasweeks/Documents'

Permission error 13 Python 3.5.2

I have a problem opening a file with Python script in windows 10.
What I do is next:
I open my script as administrator in which create a new directory in the route:
C:\ProgramData\New_folder
Inside that folder I create a txt file:
C:\ProgramData\New_folder\log.txt
After that the program put some text in the log.txt and finish.
Now I have to open the script normally not as admin and when the program start it launch an permission error 13 in the following line of code.
dirLog = 'C:\ProgramData\New_folder\log.txt'
output = open(dirLog, "a")
I really don't know what is happening here because I check the file created and it has read and write permissions.
it's of vital importance open the script as admin just the first time, the rest just normally.
This might be caused because of the level of permission that the folder is set at. There is a possible fix for this, but it could cause security issues in the future as far as permissions for that folder go. If you can afford to change the permission level of the folder, try this: navigate to ProgramData, right click on the folder, click 'Properties', then hit the 'Security' tab at the top, then check the permissions for users. If the read permission is set off, turn it on. Otherwise, try enabling the write permission.

Categories

Resources