I made a program using tkinter (GUI module). basically it is a banking system that stores data in text files. I found that a desktop.ini file was created in that folder. why so? Is it harmful if I delete the file?
[.ShellClassInfo]
IconResource=C:\WINDOWS\System32\SHELL32.dll,27
[ViewState]
Mode=
Vid=
FolderType=Generic
👆 this is what is there in that file.
it's a windows config file and is not harmful or a vulnerability
According to https://answers.microsoft.com/en-us/windows/forum/all/there-are-these-random-desktopini-files-appearing/5bb923f5-6b06-4e07-a79e-a16c8bfc844a
You should not delete them.
A Desktop.ini file is a file that determines the way a folder is displayed by Windows. These files can be found in any folder, anywhere on your computer, as long as that folder has a custom appearance set for it. Desktop.ini files control things like the icon used for that folder and its localized name.
Deleting them will always regenerate them anyway. If you don't want to see them, turn off show hidden files and folders in File Explorer > View tab > uncheck hidden files.
Related
Selected Files (3)
Menu Selection Send To ----
Result, Program will run for how many files are selected for this example it is 3
I have made an addition to windows registry and made a right click menu option for files. I attached a program to the option that will attach the file to an email and send me the file. When I select multiple files it will create multiple emails. What I want is for all the files to attach to a single email.
What I've tried:
1. I have tried a for loop in python script for sys.argv[n] / Didn't work because the program will run for each individual file selected
The issue is with Windows Explorer. You need to tell it you can handle multiple names. Have you registered your handler with an "open" verb? If you register it with the "OpenWithList" verb, then Explorer should send the whole list to one executable. I'm looking up the exact setting now.
Yes, HKEY_CURRENT_USER\Software\Classes\.mkv\OpenWithList\xxx.py.
Create a batch file.
insert #echo off cls command_path/command.exe %* into the batch file
Go to command location in windows registry and change the default value to the newly created batch file.
Continue if you don't want the command.exe location to be a part of the files sent
Create an array named files. ex. files = []
create a for loop to append to files ex. for i in sys.argv: if i != sys.argv[0]: files.append(i)
The files value will be inserted accordingly to the part of the api structure that handles attachments. Make sure to put it in as *files if you're not putting it into a list then files will work just fine.
(For those who are not in the know. The * is a spread operator. More examples on spread operators can be found easily by looking up spread operator.)
I just need to refresh a folder.
A hypothetical ideal example would be:
from aModule import refreshdir # fake
refreshdir("C:\path\to\directory")
Context:
I am using Autodesk Desktop Connector, a service that sync data on the cloud with local folders. To avoid expending resources, this tool just checks for new updates when the user opens the file or refresh the directory (so manually). However, in order to automate some operations, I need to refresh the directory with Python. There is no API for this tool.
Thanks in advance! =)
Edit:
New files can be added in the cloud. That's why it is important to refresh the folder. Example:
Before refreshing:
enter image description here
After refreshing:
enter image description here
os.listdir cannot catch those highlited files before refreshing.
Refreshing a directory is not an operating system operation, but a function of the filesystem browser / explorer. A refresh is essentially just reading in the directory contents anew.
Most likely that Adobe tool is hooking into the filesystem functions that do this enumeration of a directory's contents. If this is the case, then the task should be as simple as
import os
os.listdir("C:/path/to/directory")
Keep in mind that backslashes (\) in standard string literals start an escape sequence, i.e. if you wanted to put an actual backslash there, you'd have to write "\\". However Windows will happily use forward slashes as directory separator as well, so you can just use that :-)
To solve this problem I created a script in Python using the pywinauto library to do a manually task that clicks on the file and then clicks on the Sync option.
In this case you'll need to know the name of the files you want to sync. The code was made to AutoCAD Plant 3D project, you'll need to change the path to your files.
from pywinauto import Application
raiz = "C:\\Users\\YOUR_USERNAME\\ACCDocs\\ORGANIZATION_NAME\\PROJECT_NAME\\Project Files\\PLANT3D_PROJ_NAME\\Plant 3D Models"
Application().start('explorer.exe ' + raiz, timeout=10)
explorer = Application(backend='uia').connect(path='explorer.exe', title="Plant 3D Models")
#Plant3DModels is a variable automatically created with the title of the windows opened
explorer.Plant3DModels.set_focus()
# 'Infra-Geral.dwg' is the name of the file that I will Sync
file = explorer.Plant3DModels.ItemsView.get_item('Infra-Geral.dwg')
file.right_click_input()
explorer.ContextMenu.Sync.invoke()
The script needs to read from a .txt file with a list of items and based off that list, it creates a directory for each item. So just a simple with open() statement and then os.mkdir()..
The client will add account names to the txt file when they get new accounts, the program will create new directories for those new accounts. Files that are then placed in each directory for those accounts will get pandas stuff done to them and moved to an archive folder along with logging the events.
Since the program will be used by non-programmers, I'm using Pyinstaller.
When I go through the process, including the --add-file attribute, run the program, it says the txt file doesn't exist. I think I have an idea how to fix that but when I got the os.mkdir and with open statements to work by separating them out, it created them in the home folder and not the program folder. Path issue? And I only see documentation on how to include data files but not how to include changeable files.
I build a small project in python, now I need to send to another user to make him run it. But if he downloads my code on his computer then the file path(which based on my computer) won't be valid anymore. Is there anything I can do to make it runnable for him by setting up the path correctly?
zip the folder that it is located in and have them place it in the same location i.e if it is in your documents folder have them place it there
I want to change the default directory listing of the pythonwebkit(the one imported from gi.repository) for an application I am working on. Is there any function/script in webkit that does the job?
EDIT
The code for styling the default directory listing is in the file net/base/dir_header.html and ends up in chrome.pak and chrome_100_percent.pak.
The python module data_pack.py can work with these files.
If you want to filter certain file types from the list, you can probably do that in addRow()
You will have to use os.chdir() to change the current directory for the whole process. AFAIK, WebKit doesn't keep an internal environment for things like the current folder.