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

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
I'd say you're missing the part where you create a textfile...
Answered 11/09/2010 by: pjgeutjens
Red Belt

Please log in to comment
0
Hi ,
Below string i am using not able to create
strDirectory="C:\logs"
strFile = "C:\log\micro.txt"
Answered 11/09/2010 by: honeyslim
Senior Yellow Belt

Please log in to comment
0
strDirectory="C:\logs"
strFile = "C:\log\micro.txt"
Typo or mistake? (log<->logs)
Answered 11/09/2010 by: pjgeutjens
Red Belt

Please log in to comment
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
Answered 11/09/2010 by: honeyslim
Senior Yellow Belt

Please log in to comment
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
Answered 11/09/2010 by: pjgeutjens
Red Belt

Please log in to comment
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"
Answered 11/10/2010 by: honeyslim
Senior Yellow Belt

Please log in to comment
0
Read PJ's reply above and look at your script

Set objFile = objFSO.CreateTextFile("C:\Logs\Micro.txt")
Answered 11/11/2010 by: timmsie
Fourth Degree Brown Belt

Please log in to comment
0
Hey all Thanks a lot it's working fine :) :)
Answered 11/11/2010 by: honeyslim
Senior Yellow Belt

Please log in to comment
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.
Answered 11/11/2010 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity