1

In Windows, you can initiate a Bluetooth transfer of a file by right clicking the file and choosing Send to > Bluetooth device. The Bluetooth File Transfer box appears, after which you select what device to send to. I have found that I can achieve the same effect by dragging-and-dropping the file that you want to send onto C:\Windows\system32\fsquirt.exe.

To figure out how Windows passes files to programs when you use Send to or drag-and-drop, I wrote the following Python script and placed a shortcut to it in C:\Users\<username>\AppData\Roaming\Microsoft\Windows\SendTo. The shortcut's Start In directory is the .py file's containing directory. (I am using Python 3.6.)

#!python3
import os, sys
print(os.getcwd())
print(sys.argv)
input("Press Enter to exit...")

When I drag-and-drop a file onto the shortcut or the script itself and when I right-click a file and choose Send to > the new shortcut, the same thing happens in all three cases: on the first line, Python prints out the containing directory of the .py file, and on the second line, Python prints out a repr of a list containing two elements: the absolute path to the .py file and the absolute path of the file that I chose.

I wrote the following batch file for testing:

cd C:\folder\of\py\file\
C:\folder\of\py\file\argv_dump.py "C:\path\to\a\file.txt"

When I run this batch file, either from the command prompt or by double-clicking it in Windows Explorer, I get the same output from before. on the first line, Python prints out the containing directory of the .py file, and on the second line, Python prints out a repr of a list containing two elements: the absolute path to the .py file and C:\path\to\a\file.txt.

Now, I am trying to initiate a Bluetooth transfer on Windows 10 from a script. I have written a three-line batch file for testing:

cd C:\Windows\system32\
C:\Windows\system32\fsquirt.exe "C:\path\to\a\file.txt"
pause

This does not appear to send "C:\path\to\a\file.txt" to fsquirt.exe. The Bluetooth File Transfer dialog box appears, but it still asks me to choose what file I want to send. Running these commands in a command prompt window yields the same result.

How does fsquirt.exe know the difference between when I drag-and-drop or use Send to and when I manually pass it an absolute file path from a batch file or the command prompt? How can I get fsquirt.exe to notice the file path that I am giving it?

I did look at this other question, which suggested checking the current working directory of the batch file. Wouldn't cding inside my batch file take care of that, though?

Community
  • 1
  • 1
wecsam
  • 2,651
  • 4
  • 25
  • 46

1 Answers1

0

In the past, I have used the Bluetooth Command Line Tools via Bluetooth Installer. They allowed me to automate a Bluetooth workflow via the Windows command line.

chris g
  • 1,088
  • 10
  • 18