Skip to content

Instantly share code, notes, and snippets.

@nadvolod
Created November 30, 2016 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadvolod/acb3064d2fe16200368fc86f0bc9608a to your computer and use it in GitHub Desktop.
Save nadvolod/acb3064d2fe16200368fc86f0bc9608a to your computer and use it in GitHub Desktop.
write to file VBS
Set objFSO=CreateObject("Scripting.FileSystemObject")
' How to write file
outFile="c:\test\autorun.inf"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write "test string" & vbCrLf
objFile.Close
Copy link

ghost commented Jun 13, 2018

you can't put quotes in the stuff and it messes things up if you're trying to do something specific.

such as writing a file to do
objFile.Write "oShell.Run "taskkill /f /im explorer.exe", , True" & vbCrLf
won't work because of the quotes between the quotes. is there any way to get around that?

@egryaznov
Copy link

You need to escape the quotes by doubling them:
objFile.Write "oShell.Run ""taskkill /f /im explorer.exe"", , True" & vbCrLf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment