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!

Microsoft VBScript runtime error: Permission denied

Status
Not open for further replies.

kendas

Technical User
Joined
Feb 2, 2004
Messages
108
Location
SG
hi,
i always get "C:\scripts\1.vbs(8, 1) Microsoft VBScript runtime error:
Permission denied" error when trying to run the below script.
any idea?

Set objFSO = CreateObject("Scripting.FileSystemObject")
set objshell = CreateObject("WScript.Shell")

Const ForAppending = 8
Set objFile = objFSO.CreateTextFile("c:\scripts\results.txt")
If objFSO.FileExists("\\server\c$\backup\file222.txt") Then
Set objTextFile = objFSO.OpenTextFile ("c:\scripts\results.txt",
ForAppending, True)
objTextFile.WriteLine "\\server\c$\backup\file222.evt exists"
ObjTextFile.Close
end if

 
you are trying to open the file ("c:\scripts\results.txt") twice which isnt possible. you can only have a reference to it as a Textstream once.

get rid of the first CreateTextFile method
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top