Skip to content
Advertisement

Copy to clipboard from php command line script in Windows 7

I have a php (5.5) script which I run from the command line in Windows 7. Something like this:

C:php-5.5.5php.exe C:scriptsputString.php

My question is, is it possible to copy something to windows clipboard from the script? I want users to have some text available in the clipboard after running this script from the command line. How can it be done?

Advertisement

Answer

If you want to add some intermediate result to the clipboard, instead of the output of the entire script

//...your script...
$someVar="value";
shell_exec("echo " . escapeshellarg($someVar) . " | clip");
//rest of script...
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement