log.txt file not geneating
Dim objFSO, objFolder, strDirectory
strDirectory = "c:\logs"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
MsgBox "Just created " & strDirectory
0 Comments
[ + ] Show comments
Answers (9)
Please log in to answer
Posted by:
honeyslim
14 years ago
Posted by:
pjgeutjens
14 years ago
Posted by:
honeyslim
14 years ago
Dim objFSO, objFolder, strDirectory
Set objFolder = objFSO.CreateFolder(strDirectory)
MsgBox "Just created " & strDirectory
Posted by:
pjgeutjens
14 years ago
Mohammed,
the part that I don't get is that, while you do define a variable holding the path to the text file, you don't actually do anything with it.
I would expect something along the lines of
Set objFile = objFSO.CreateTextFile("C:\Logs\Micro.txt ")
but I don't see any line in your script that would actually create the file.
Rgds,
PJ
the part that I don't get is that, while you do define a variable holding the path to the text file, you don't actually do anything with it.
I would expect something along the lines of
Set objFile = objFSO.CreateTextFile("
but I don't see any line in your script that would actually create the file.
Rgds,
PJ
Posted by:
honeyslim
14 years ago
Hi, below have Script not working
Option Explicit
Dim objFSO, objFolder, strDirectory,strFile
strDirectory = "c:\logs"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
MsgBox "Just created " & strDirectory
Set objFile = objFSO.CreateTextFile
strFile = "C:\logs\micro.txt"
Option Explicit
Dim objFSO, objFolder, strDirectory,strFile
strDirectory = "c:\logs"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
MsgBox "Just created " & strDirectory
Set objFile = objFSO.CreateTextFile
strFile = "C:\logs\micro.txt"
Posted by:
timmsie
14 years ago
Posted by:
anonymous_9363
14 years ago
Excellent. Now you can edit it so that it's a little more professional. Something like:
Option Explicit
Dim objFSO
DIm objFolder
Dim strDirectory
Dim strFileName
Dim strFile
strFileName = "micro.txt"
strDirectory = "c:\logs"
strFile = strDirectory & "\" & strFileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not IsObject(objFSO) Then
'// Maybe display an error message here?
WScript.Quit(False)
End If
With objFSO
Set objFolder = objFSO.CreateFolder(strDirectory)
If Not .FolderExists(strDirectory) Then
'// Maybe display an error message here?
WScript.Quit(False)
End If
MsgBox "Just created " & strDirectory
Set objFile = objFSO.CreateTextFile(strFile)
If Not .FileExists(strFile) Then
'// Maybe display an error message here?
WScript.Quit(False)
End If
End With
'// Clean up
Set objFile = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
Newcomers to coding always make the mistake of assuming that everything will always work. You should assume the exact opposite and code accordingly.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.