mukeshdak

2025-09-29_read and write to a file

Sep 28th, 2025
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.56 KB | None | 0 0
  1. Set objFSO=CreateObject("Scripting.FileSystemObject")
  2.  
  3. ' How to write file
  4. outFile="c:\test\autorun.inf"
  5. Set objFile = objFSO.CreateTextFile(outFile,True)
  6. objFile.Write "test string" & vbCrLf
  7. objFile.Close
  8.  
  9. 'How to read a file
  10. strFile = "c:\test\file.txt"
  11. Set objFile = objFS.OpenTextFile(strFile)
  12. Do Until objFile.AtEndOfStream
  13.     strLine= objFile.ReadLine
  14.     Wscript.Echo strLine
  15. Loop
  16. objFile.Close
  17.  
  18. 'to get file path without drive letter, assuming drive letters are c:, d:, etc
  19. strFile="c:\test\file.txt"
  20. s = Split(strFile,":")
  21. WScript.Echo s(1)
Tags: BASH
Advertisement
Add Comment
Please, Sign In to add comment