1

I want my powershell/batch/vbscript to be able to copy a text start notepad and then paste it I found how to copy which is here but I don’t know how to paste it any ideas how can I do it without third party tools?

4
  • What I would suggest you is to paste the text into a new file and then open the file using Notepad. This would produce same result, except that it will create a new file, but this will also save you a lot of effort, because doing it the other way seems to be difficult Commented Aug 19, 2021 at 9:52
  • And if you are using the ways mentioned in the link, You can instead just make a new file with the required text and open it using notepad. This way you won't even require copy pasting commands. Commented Aug 19, 2021 at 9:57
  • Yes but I want to copy and paste it to notepad which'll yes be harder to do Commented Aug 19, 2021 at 11:20
  • There's a reason it's harder -- it's poor coding! From the [Ciipboard class]() documentation: Security Alert: For security purposes, the following points should be kept in mind. Paste operations need to be user initiated (Ctrl-V, Paste Menu). Commented Aug 19, 2021 at 21:21

1 Answer 1

2

This is a very common thing. A quick web search would show you many.

powershell 'capture and send output to notepad'

Just use SendKeys and pass CRTL+V.

Pass your content to the clipboard

Example:

Get-NetIPConfiguration | clip | notepad
Sleep -Seconds 1
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait('^V')

Or use other pre-built examples that already exist for this use case as shown in the link provided.

2
  • I'd like to suggest using scb alias to Set-ClipBoard instead of using Clip.exe. Commented Aug 20, 2021 at 1:47
  • 1
    Choices, choices, choices..... it's always a prefernece.
    – postanote
    Commented Aug 20, 2021 at 4:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .