Would someone please help me with this. I need the ruby output to be directly copied to clipboard.
I recently discovered GeoIPGen and it is awesome. I made a .bat script that runs GeoIPGen through which it generates a random IP but I need to make it to copy itself to clipboard.
Can you help me with this one?
Thanks in advance!
.BAT SCRIPT CODE EXAMPLE
C:\Ruby193\bin\ruby.exe C:\geo\geoipgen -n 1 US
pause
There is a gem called clipboard that provides the capability to store data in the system clipboard programmatically.
I found a soulution since I am using Command Prompt:
HowToGeek Tutorial - How to copy output text from the command line to the windows clipboard
How can I get a script's output to be copied to the Windows clipboard?
Related
This following code in my bat file copy's the bat file while it's running into a correct directory in windows 7 but when I convert it to a exe script it no longer works.
Can any one suggest a alternative ? Or any suggestions to why?
if not exist "%programfiles%\toolset\" (
md "%programfiles%\toolset\"
copy "%~f0" "%programfiles%\toolset\"
)
can any one else help I'm pretty sure it's not my converter tool I use as I have tried all the ones listed below but I think the script needs editing for it to function as exe application?
You can try the following nice tool
http://www.battoexeconverter.com/
since you are accessing programfiles you need to be admin
To do this run the cmd in admin mode and try to execute in command line
Download this tool. It works well.
Bat2Exe
You can add administrator manifest to run as administrator when opening the exe file.
I am a batch programmer just like you.
Personally I use this tool;
http://www.f2ko.de/programs.php?lang=en&pid=ob2e
Nice tool, only requires a download, used it multiple times, never dissappointed me, and it is very legit, have no doubts about it!
Pringles
I'm designing a batch file to first check if a copy of windows is activated (using the slmgr /xpr command) and if it isn't input a key to activate it. I have everything done except for the checking for activation as when you run the slmgr /xpr command, it outputs to a windows host script dialogue box and I can't figure out how to have that box output its text into a text file to use as a variable. Does anyone know how to do this/ has a better way?
Thanks in advance!
Use cscript to output text from slmgr to the console.
cscript slmgr.vbs /xpr
Try this, you may just change slmgr.vbs /dli to slmgr.vbs /xpr.
It will automatically generate a text file saved to your C:\ drive:
cscript c:\Windows\System32\slmgr.vbs /dli > c:\slmgr_result.txt
I have a small command line tool and after running it, I'd like to display the text output in a way that's easy for someone to copy/paste and save it or email it to someone else.
Copy/pasting from a command prompt is not done in the standard way, so I don't want people to have to copy/paste from there. Saving the file to disk is possible, but the folder where the tool is located may not have access rights so the user would have to configure the output file location (this may be too tricky for some users).
I was thinking of launching notepad with some text in it, generated from the command line tool. Is this possible? Any other suggestions?
You can use clip.
After you have clip, which can be downloaded from the link above, you use the pipe (|) command to copy the previously executed command's output to the clipboard.
The article gives you the full explanation, but here are the basics with examples:
dir /h | clip – Copy the help manual for DIR command to the clipboard
tracert www.labnol.org | clip – Trace the path from your computer to another website – the output is automatically copied to the clipboard and not displayed on the screen.
netstat | clip - Check if your computer is connecting to websites without your knowledge.
I think your command sould receive the destination e-mail as a parameter and then after executing, your command you can have simple script/.BAT file which e-mails your text output to the user using the standard Telnet SMTP commands, like explained for example in the following page:
"http://www.yuki-onna.co.uk/email/smtp.html".
You could add an option to your program that tells it to copy its own output to the clipboard using the clipboard API. Then the user could just paste it.
I like the clip suggestion, though.
I have a directory of files that I would like to scan on a regular basis and execute with the default application they are associated with. They are not executable so system("file.torrent"); does not work. How are you able to run files with there associated applications in Perl?
The standard windows way is with ShellExecute.
In perl you can do it with, well, ShellExecute. Its in the Win32::GUI package.
Have not tried it. But it looks simple enough.
start
You could manually parse the relevant part of the registry, find the associated application, and kick it off yourself: but the command prompt's built-in start command life easier.
So, for your example you would simply do a system("cmd /c start file.torrent")
Not Perl specific but you can always use the 'start' command. The first argument will be the title of the new command prompt opened and the second argument is the file to open.
system('start "dummy title" "some file.doc"'); # opens the document in word
Another option we use is
system("RunDLL32.exe SHELL32.DLL,ShellExec_RunDLL file.torrent")
Never use system() on windows !
Crappy and bad method (PAS)
Just to highlight the comment by BeowulfOF above
system( "test.log" )
will open test.log in it's associated application just the same as entering
test.log
on the command line
I find myself running scripts and copy-pasting the output of these runs into emails or into some other documents. Is there a way such that I can make the copy-to-clipboard step a part of the script itself? Most of my scripts are either Perl or bat files and I work on Windows.
Thanks.
There's a utility called clip.exe that you can use. Just pipe the output of your script or any other command into clip.exe (First, put it on your path somewhere. If you don't have a usual place for these kindss of utilities, you can dump it in the directory you usually run your scripts from, or I've known people to use c:\Windows\system32 in a pinch...):
somescript.bat | clip
Then paste away.
In Perl, install and use Win32::Clipboard module
Not sure about the clipboard but you can pipe the output to a text file but doing something like this:
somescript.bat > output.txt