VB Script error

Hey guys.

So, I've been trying to teach myself scripting by looking at my company's existing scripts and attempting to reverse engineer.  I've had some experience with scripting and programming many moons ago, but I can still more or less follow what's going on.

So, I have a maddening issue.  A script created in 2004 by either a former employee or one found on the internet intermittently works.  The job of the script is to take an AD group as input, verify the domain and OU and return a list of accounts in that group.  As I've said, it works sometimes and other times it fails with an access denied message on a specific line.  I've added it below.

Set objGroupLog = fso.CreateTextFile(strGroupLog, True)

This line is in a section where it's trying to write a log, but I'm not sure where it's trying to write to.  I have more lines of the script, but have seen people be annoyed at posters for copy and pasting the entire script.  I can add any info you'd like to give me a hand.
Ray DrummondLan Administrator IIIAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
Check the content of strGrouplog variable, it contains the file name. If that contains some special character not allowed for file names, this could raise this error
Ray DrummondLan Administrator IIIAuthor Commented:
Hi Guy.

Thanks for responding.  I think this is the line you're referencing.

strGroupLog = "c:\" & strGroup & "_" & strDateStamp & ".txt"

When I run the script, where I would enter the group name there is a value already listed and I have to delete it and enter the correct group name.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
So can you show some group names where your script goes into the error?
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

(Hi Guy :^)

My guess would be it's not launching from an elevated environment.  Typical users won't have access to write to the root of C:
Either launch the script elevated, or modify the variable strGroupLog.

strGroupLog = "c:\ADGroupInfo\" & strGroup & "_" & strDateStamp & ".txt"

Open in new window

'(Make sure C:\AdGroupInfo exists before running)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray DrummondLan Administrator IIIAuthor Commented:
So, both of you helped, but it turns out that SirBounty's info is what fixed the issue.  I always commented to colleagues that it always worked on Windows XP.  Forgot about that difference to Windows 7

Thank you both.
Ray DrummondLan Administrator IIIAuthor Commented:
Another step closer to understanding this.  Thanks.
Glad you found your solution.  Thanks for the grade! :^)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.