Python Forum
Pyinstaller - I can't drag and drop into the CMD terminal anymore..
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pyinstaller - I can't drag and drop into the CMD terminal anymore..
#1
Hi guys, I wrote a script in Python 3 and it works. When I start my script ".py" a cmd terminal appears and from there I'm able to drag and drop a file into it to get the full path about the file. Now I converted my script in an ".exe" file with Pyinstaller. The script works exactly as before, but when I try to drag and drop a file into the cmd terminal, the full path is not inserted, the drag and drop action doesn't produce any kind of effect in the terminal. How can I solve this issue?
Reply
#2
Your script extracts file paths from shortcuts?
In what OS? Assuming Windows because cmd and exe
How does it do this?
Why use the terminal? Can't you create a special window for this that will work regardless of how the program is stored?
Why does it need to be an exe?
Reply
#3
(Jan-11-2020, 03:52 PM)Clunk_Head Wrote: Your script extracts file paths from shortcuts?
How does it do this?
my script ask the user a path (example: "C:\Users\Pippo\Desktop\file.txt") because it needs to know where is a specific text file. then it will read it and produce a new file. to give the specific path to my script, you have two choises, the first one is write by hand it in the cmd terminal, the second one instead is drag and drop the file in the cmd terminal. the second one is easier and simpler then the first one, but it works only if I run, let me say, the ".py" version of my script. the drag and drop doesn't work if I use the ".exe" version of my script.

(Jan-11-2020, 03:52 PM)Clunk_Head Wrote: In what OS? Assuming Windows because cmd and exe
Windows 10 Professional, x64

(Jan-11-2020, 03:52 PM)Clunk_Head Wrote: Why use the terminal? Can't you create a special window for this that will work regardless of how the program is stored?
my script don't have a GUI, it's just a CLI script. when you open it you will see the cmd terminal.

(Jan-11-2020, 03:52 PM)Clunk_Head Wrote: Why does it need to be an exe?
because I have to use it on different PC without python installed.
Reply
#4
I can do a test.
# drop.py
import sys

drop_file = sys.argv[1]
print(f'You dropped {drop_file}')
with open(drop_file) as f:
    print(f.read())
input('Press <Enter> to exit')
Make a drop.bat file to drop to as it has all permission for drag drop,.py can be blocked in Registry.
"C:\python37\python.exe" drop.py %*
Build with Pyinstaller.
pyinstaller --onefile --add-data drop.bat;. drop.py
Now can drop files to drop.exe,eg it will work for txt,csv,html... ect.
Reply
#5
sorry for the delay guys, I solved my issue only in these days. I don't know why, but the drag and drop issue appears only if the program is named as "setup.exe". to solve the issue, you have to change just the name. simple :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  My first script does not work anymore redfirebrooks 2 2,412 Jan-05-2021, 10:49 AM
Last Post: redfirebrooks
  Code used to work, not anymore for no apparent reason? chicagoxjl 1 1,885 Jan-08-2020, 05:05 PM
Last Post: jefsummers
  Python code suddenly not working anymore mike_b 5 5,734 Oct-02-2019, 03:38 PM
Last Post: ichabod801
  All of a sudden Pycharm doesn't run anymore (select valid interpreter) Luke_Drillbrain 1 5,274 May-04-2017, 07:30 PM
Last Post: buran
  Windows: Put File automatically under Cursor for Drag & Drop sym 1 3,475 Jan-13-2017, 04:55 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020