Skip to main content

Testing File System Object in Vbscript


  1. 'The code is as shown below
  2. Dim WshShell
  3. choice=InputBox("Filename","Type File Name")
  4. If choice="" Then
  5. Wscript.Quit
  6. End If
  7. choice2=InputBox("Foldername", "Type Folder Name to be created")
  8. If choice2="" Then
  9. Wscript.Quit
  10. End If
  11. foldername="C:\"& choice2
  12. filename=foldername&"\" & choice & ".txt"
  13. Set WshShl=WScript.CreateObject("Wscript.Shell")
  14. WshShl.Run"cmd /c mkdir C:\" & choice2
  15. Set Fso=WScript.CreateObject("Scripting.FileSystemObject")
  16. RR=InputBox("Batch file writer" & vbCrLf & " Write Something to be saved in " &_
  17. vbCrLf & filename,"Batch Writer")
  18. Do While UCase(RR)<>"QUIT"
  19. If RR="" Then
  20. MsgBox "I will run the script"
  21. WshShl.Run "C:\" & choice2 & "\" & choice &".txt"
  22. Wscript.Quit
  23. End If
  24. Set filehandle=Fso.OpenTextFile(filename,8,"True")
  25. Filehandle.WriteLine RR
  26. Filehandle.Close()
  27. RR=InputBox("Batch file writer" & vbCrLf & " Write Something to be saved","Batch Writer")
  28. Loop

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.