Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Const FileFormat = 0 ' -2 - System default, -1 - Unicode, 0 - ASCII
- strCurDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "\"
- strPath = strCurDir & "child.vbs"
- strFnName = "ChildScript"
- WriteTextFile split(split(ReadTextFile(WScript.ScriptFullName, FileFormat), "Function " & strFnName & "()" & vbCrLf)(1), "End Function")(0), strPath, FileFormat
- Function ChildScript()
- MsgBox "Extracted Child Script"
- End Function
- Function ReadTextFile(strPath, lngFormat)
- ' lngFormat -2 - System default, -1 - Unicode, 0 - ASCII
- With CreateObject("Scripting.FileSystemObject").OpenTextFile(strPath, 1, False, lngFormat)
- ReadTextFile = ""
- If Not .AtEndOfStream Then ReadTextFile = .ReadAll
- .Close
- End With
- End Function
- Sub WriteTextFile(strContent, strPath, lngFormat)
- ' lngFormat -2 - System default, -1 - Unicode, 0 - ASCII
- With CreateObject("Scripting.FileSystemObject").OpenTextFile(strPath, 2, True, lngFormat)
- .Write (strContent)
- .Close
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement