This is my final project for CIS-573
- Ensure a file exists on your flash drive in the root named processes.txt (i.e. D:\processes.txt)
- Install Python=>3.10.4
- Install pyinstaller with pip
python -m pip install pyinstaller - Run pyInstaller command to build your current directory, making an executable from argument [1]
For Windows if the file you want to run is inputChecker.py (it is):
pyInstaller inputChecker.py - Go to Control Panel, and search AutoPlay in the top-right searchbar.
- Select AutoPlay, navigate to "Removable Drives" and select "Take no action".
- Click Save in the bottom-right and close the window.
- Change the `C:\RelativePath\TotheExecutable\executable.exe and "C:\FullPath\TotheExecutableFolder" and "adminPassword" in the tag
to the relative path to your executable (if the WorkingDirectory tag is set to the directory containing executable.exe you can set the first argument ("C:\RelativePath...") to just the name of the
<Arguments>/c ""C:\RelativePath\TotheExecutableFolder\executable.exe" "C:\FullPath\TotheExecutableFolder" "adminPassword""</Arguments>
executable.exeexample: runInputChecker.exe), and changeadminPasswordto your preferred adminPassword. The FullPath argument must be the full path from the drive name up to and including the directory containing the executable being run.to point towards the directory of the executable you wish to run. The value of WorkingDirectory must NOT have quotes.<WorkingDirectory>C:\FullPath\TotheExecutableFolder</WorkingDirectory>
- Import the Task Scheduler Task "runInputChecker.xml" into Task Scheduler.
- Open cmd
- cd to the directory where runInputChecker.xml is stored
- Run the command:
schtasks.exe /Create /XML runInputChecker.xml /tn "Event Viewer Tasks\taskname"
in Powershell, where "runInputChecker.xml" is used to detect the usb flash drive insert event, and where taskname is the name you wish to have for the task. After which, your task should be viewable in the Task Scheduler folder "Event Viewer Tasks".
- Install Python=>3.10.4
- Install pip
sudo apt install python3-pip - Install pyinstaller
pip3 install pyinstaller - Install bin-utils
sudo apt install binutils - Install libc-bin
sudo apt install libc-bin - Run PyInstaller command to build your current directory, making an executable from argument [1]
For Linux if the file you want to run is inputChecker.py (it is):
python3 -m PyInstaller main.py - Run the command:
location="/path/to/FinalProject"; nohup watch -n seconds $location/linuxFindDrives.sh $location executable sudoPassword >/dev/null 2>/dev/null & echo $! > "$location/file_to_save_pid_to.txt" ; line=$(head -n 1 "$location/file_to_save_pid_to.txt") ; disown -h $line
where /path/to/FinalProject is the path to the FinalProject directory (INCLUDING FinalProject), seconds is the number of seconds after which you would like to repeatedly check again for flash drives, executable is the name of the executable (usually inputChecker), sudoPassword is your sudo Password, and file_to_save_pid_to.txt is the filename you want the program's process id saved to. EXAMPLE:
location="/home/strassboom/Documents/FinalProject"; nohup watch -n 10 $location/linuxFindDrives.sh $location inputChecker Honda#1954 >/dev/null 2>/dev/null & echo $! > "$location/kill_me.txt" ; line=$(head -n 1 "$location/kill_me.txt") ; disown -h $line
- Memorize where file_to_save_pid_to.txt is, or the integer printed to the terminal after the command is finished running.
- Close the terminal window with the x button.
- You are Done.
- Go to task Scheduler, and right click the task, and click disable task. To delete the program you may simply delete the folder where FinalProject is saved, and the task in Task Scheduler you created.
- I you would like to just kill the entire program, open a terminal window, and type the command "kill x" where x is the process id you saved earlier that was printed in the earlier terminal window.
- To delete the program you may simply delete the folder where FinalProject is saved, and perform step 1 if you have not already.
- If you are unsure if there are more instances of the watch command running, display all process in the terminal with the command
ps -ef.