If I have some simple text in a .rtf file (called test_file.rtf), how can I run this in terminal?
For example if I have cd Documents/Movies written in this file, I don't want to have to open the file, copy that line, paste it into terminal, then hit enter to get into the Movies folder. I just want to simply 'run' test_file.rtf and then I will be in Movies folder.
Is there a simple way to just call this without loads of ammendments to my setup or to the simple rtf file? Essentially just a word to type in to say 'run this command'?
Related
I was wondering if it was possible to run a selfwritten ruby program just like any other program by double-clicking an icon of some sort.
And if it's possible, how do I do it?
I wrote a little program for a friend but I don't want him to have to use the command line to run it, because that's rather inconvenient (unless there is a way to just double-click and the command line opens the program itself..).
Thanks for your help!
The simple answer that should work for all versions of Windows is to just create a simple batch launcher.
Create a .bat file. I usually just create a new .txt file via "right click > new > text document". Then rename it, highlight everything, including the extension, and rename it to something like run.bat. The .bat part is important. Once you rename it, the icon should change to gears. If you can't overwrite the extension, or Windows is still treating it as a text document, you'll need to either manually save it as a bat, or disable "hide file extensions" in the explorer settings so the extension can be changed.
Edit the bat file, and put into it something like:
#echo off
YOUR RUN COMMAND HERE THAT YOU WOULD NORMALLY TYPE MANUALLY
pause
Paste the command that you would normally run manually where the capital text is. The first line is so it doesn't repeat the commands back, and the pause is so if an error happens, the command prompt doesn't immediately close. This gives you a chance to read the error.
Save it and close it. Now, if you double click on the bat file, your program should run.
Multiple ways
if it's for occasional use and for one script only I would pack it
to a Windows executable with Ocra, then you can double click
the .exe itself or a link to it
same as above but use jRuby and create a .jar file, not for beginners though
the easiest: if you configure Windows to start/run .rb files with your ruby.exe you can double click the .rb files itself and they
will execute, they will have the red Ruby stone icon
if you run a .reg file to enable drap and drop on .rb files you can combine the previous technique to drop files on the script and
they will be the parameters to the script, see my answer here for the reg file
my favorite: copy the .rb to your windows "C:\Users\your_user\AppData\Roaming\Microsoft\Windows\SendTo\"
folder, then you can right click file(s) or folder(s) and select
sendto and select your script, the files or folder will again be the
parameters for your script
you can create a .bat or .cmd file that starts with the path to your ruby.exe and the script as parameter, use rubyw.exe if you
don't want output
How can I save lc3 console output into a .txt file? The console does not let me copy or do anything with its output, please help.
Load the program which produces output that you want to display into LC3 Simulator
Go to File ---> Start Console File...
This will bring up a window that will allow you to choose where you want to save the text file that will contain the output. You can name it anything that you like but be sure to include the .txt extension on the end.
Run the program as usual
When the output that you want to save has successfully been printed to the console go to File ---> End Console File
If you go to the location you specified in step 2 you should now see a text file containing the console output.
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?
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.
There can be "This file came from another computer and might be blocked" message in file properties.
Is there a way to block back file in windows 7?
I need this for program testing.
You have to recreate the alternate data stream for the file. The easiest way to do this is by using Notepad. Run cmd.exe and navigate to the directory that contains the file. I'll use test.txt as an example, type this command:
Notepad "test.txt:Zone.Identifier"
Double quotes required. Notepad prompts you to create a new file, click Yes. Paste or write this:
[ZoneTransfer]
ZoneId=3
Press Ctrl+S to save.
I have scenario where I can use only command line operations to do my things.
I have some file which is already opened. I want to copy the content from this file and save it to notepad.
I am able to do CTRL+A, CTRL+C, now since this is now in clipboard.
Do we have any one line command by which I can paste this clipboard content directly to a notepad.
You can look for various CLIP tools that can write from the clipboard into a file.
A batch file can help you utilise them...