Question Locked

How do I get a VBScript to read the wscript.echo output?

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How do I get a VBScript to read the message box's output after, first searching my computer for that output and second creating a new folder named after that output?

I am trying to create a VBScript that displays the current month/year, searches my computer for that month/year folder and if that folder doesnt already exist creates a new folder labeled after the current month/year displayed, here is what I have so far:

today = Date
Wscript.Echo "Month/Year: " & Month(today)& "/" & Year(today)

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("K:\ESInbox\backup\(& Month(today)& "/" & Year(today))") Then
Wscript.Echo "Folder exists."
Else
Wscript.Echo "Folder does not exist."
End If

3 replies

by dan.cox

Instead of doing wscript.echo
create a log file and do a writeline.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(C:\file.log)
objFile.Writeline "Folder Exists."

by guiedo

Try this

DIM intMonth, intYear

intMonth = Month(date)
intYear = Year(date)

Wscript.Echo "Month/Year: " & intMonth & "/" & intYear
Dim objFSO, FC
strFolder = "C:\ESInbox\backup\"& intMonth & "-" & intYear ' \/:*?"<>| can not be used

Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(strFolder) Then
SET FC = objFSO.CreateFolder(strFolder)
CreateFolder = FC
Else
Wscript.echo MyFolder& " This Folder already exists"
End If

This discussion is closed to new replies.