/build/static/layout/Breadcrumb_cap_w.png

log.txt file not geneating

Hi,

Scenario Like this - while installing package it’s should create new folder and inside folder logfile.txt file should be generate for the app. below have script.i m able to create new folder but unable to create logfile.txt inside the folder could you plz any one tell me where i am missing ,

Option Explicit
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)

Posted by: pjgeutjens 13 years ago
Red Belt
0
I'd say you're missing the part where you create a textfile...
Posted by: honeyslim 13 years ago
Senior Yellow Belt
0
Hi ,
Below string i am using not able to create
strDirectory="C:\logs"
strFile = "C:\log\micro.txt"
Posted by: pjgeutjens 13 years ago
Red Belt
0
strDirectory="C:\logs"
strFile = "C:\log\micro.txt"
Typo or mistake? (log<->logs)
Posted by: honeyslim 13 years ago
Senior Yellow Belt
0
Hey below have Script still not able to create logs

Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "c:\logs"
strFile = "C:\logs\micro.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.CreateFolder(strDirectory)
MsgBox "Just created " & strDirectory
Posted by: pjgeutjens 13 years ago
Red Belt
0
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
Posted by: honeyslim 13 years ago
Senior Yellow Belt
0
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"
Posted by: timmsie 13 years ago
Fourth Degree Brown Belt
0
Read PJ's reply above and look at your script

Set objFile = objFSO.CreateTextFile("C:\Logs\Micro.txt")
Posted by: honeyslim 13 years ago
Senior Yellow Belt
0
Hey all Thanks a lot it's working fine :) :)
Posted by: anonymous_9363 13 years ago
Red Belt
0
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.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ