Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's wrong here? 1

Status
Not open for further replies.

Finnerbahce

Technical User
Joined
Sep 29, 2005
Messages
12
Location
IE

slog = "c:\log\" & Year(date) & "_" & Month(date)
if Not fso.FolderExists(slog) then fso.CreateFolder(slog)
slog = slog & "\Test" & Right("0" & Day(Date), 2) & Right("0" & Month(Date), 2) & Year(Date) & ".log"

set logfile=fso.opentextfile(slog,8,true)



It's giving me a permission denied error
 
Well, I guess the obvious question would be:
"Do you have write access to the root of C: and to C:\log?"

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
also when it gives you the error what does sLog look like?
which line is giving the error? where is your End If?
are there any loops? is logfile already used else where? do you have that logfile already open somewhere?
 
"where is your End If?"

Single line If statements are valid and do not need an End If.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Ok, well what does happen is that it creates a folder. It doesn't create a text file though within the folder.
 
Can you as the same user that the script is running as create a file in the folder?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
your one point of failue i can see is that the script will error if the "c:\log" folder doesnt already exist.
CreateFolder is not hte same a MD in that respect.

nice to know about the one line and End If etc.
I would advise against using it in some cases,,,as in this one. it proves harder to track down errors and makes it harder to log what has happened. you have 2 method calls on the same line....which is the one causing the error??? i had to re-write your code to figure out which one was causing the problem..not the best approach i would say.
 
I agree that single line if-thens should be used judiciously.

Do you have an On Error Resume Next statement anywhere in your script? If so, remove it.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top