-1

I'm trying to run a program that will web scrape from Pastebin using PowerShell. I used the following code to do so:

Set Wshell = CreateObject("WScript.Shell")
Wshell.Run "%ComSpec% /c powershell & $result = Invoke-WebRequest 
""https://pastebin.com/raw/wAhYB4UY"" & $result.content ", 0, True

$result.content will bring up everything I need from Pastebin. How can I transfer $result.content to a VBScript variable?

I know this is possible using the Exec() method as demonstrated here, but I can't use it because I want my code to stay hidden, which to my knowledge is not possible with Exec() (without having a window popping and closing)

I also don't want to use File I/O in Powershell because that can really complicate other things I want my program to do in the future; however, If absolutely no options are available, then I can use it.

EDIT: Some readers pointed out that my script only consists of running Powershell, so why not program my script in PowerShell? Well, not everything I am planning for this script to do can be done in PS. for example, I want my script to type some stuff outside of PS. I also want to wait until the user has pressed a certain key, in my case PrtSc (which will create a popup a message using MsgBox).

halfer
  • 19,824
  • 17
  • 99
  • 186
Mr. Magic
  • 13
  • 7
  • 1
    Why vbscript? What's the point of using powershell at that point – Maximilian Burszley Aug 15 '17 at 18:12
  • 1
    Agree - why run a PowerShell command from VBScript when you can just run it from PowerShell? – Bill_Stewart Aug 15 '17 at 18:30
  • 1
    Anything you could do in batch or VBScript you could do in PowerShell too. And more. However, I find your continued dodging the question what you actually want to achieve with this code rather suspicious, so no cookies from me. – Ansgar Wiechers Aug 15 '17 at 20:01

1 Answers1

0
$Path = 'https://pastebin.com/raw/etc'
$Raw = Invoke-WebRequest $Path
$Raw.Content

What do you want to do with the data that using VBScript is the preferable tool?

Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63