Using command from clipboard in batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Ed4571
Posts: 3
Joined: 09 Jul 2010 03:41

Using command from clipboard in batch file

#1 Post by Ed4571 » 09 Jul 2010 05:09

Hi,

I am afraid I may well be missing the obvious here, but here goes:
I have created a webpage which I intend to use purely for me, and from my local directory, and this webpage uses forms to create a dos command, which is then copied to the clipboard. I wondered if it is possible to write a batch file which would take the contents of the clipboard and use it as a command. Any suggestions?

Ed

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Using command from clipboard in batch file

#2 Post by aGerman » 09 Jul 2010 10:12

On Vista/Win7 is a tool named clip.exe which is able to copy something to the clipboard. But afaik there is no option to paste from clipboard.

Maybe the SendKeys Method of VBScript could be a possibility for you to emulate Ctrl + V.

Regards
aGerman

Ed4571
Posts: 3
Joined: 09 Jul 2010 03:41

Re: Using command from clipboard in batch file

#3 Post by Ed4571 » 09 Jul 2010 14:53

Thanks for answering,
how would it be possible to execute commands in the command prompt using VB?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Using command from clipboard in batch file

#4 Post by aGerman » 10 Jul 2010 05:50

Well, the example on the URL link shows how to do.
<obj>.Run "cmd.exe" can open a command prompt
<obj>.SendKeys "what ever" will emulate the keyboard
The only thing you have to know is that [Ctrl] + [V] doesn't work for a command prompt. You would need [Alt] + [Space], [E], [P].

Regards
aGerman

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Using command from clipboard in batch file

#5 Post by !k » 10 Jul 2010 23:10

Ed4571 wrote:take the contents of the clipboard
Use getClip from http://vb.mvps.org/tools/ConClip/

Post Reply