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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject error

Status
Not open for further replies.

AntiEarnie

Technical User
May 2, 2002
215
US
I'm at a loss on this. I have a simple script that grabs the windows error logs, saves them to disk, then resets the logs. The script I'm using works just fine on 3 other servers and a couple workstations. I have a problem server however that generates a Windows Script Host error when I try and run it though.

Error: Could not create object named "scripting.filesystemobject".
Code: 8000FFFF
Source: WScript.CreateObject

I haven't had any luck tracking this problem down on either the Microsoft site or off google. And the versions on this server match up with the other 3 servers for Windoes, IE, and WSH. I've tried reinstalling the WSH and IE patches again but that had no effect.

Microsft Windows 2000 Server
Service pack 4
patched the Windows Script Host up to 5.6, IE up to 6.0 sp1.


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''
''' This script gets the event log and dumps them to a local log folder.
'''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Time to create the vars that hold the date and time
sDate = DatePart("m", Now) & "-"
sDate = sDate & DatePart("d", Now) & "-"
sDate = sDate & DatePart("yyyy", Now) & ""

sTime = DatePart("h", Now) & DatePart("n", Now)

set oFS = wscript.CreateObject("Scripting.FileSystemObject")


'If correct folder dosen't exist, make it
if oFS.FolderExists("\\Server-a\c\logs\" & sDate) then
else

'This section will create the target folder
set oFileSys = CreateObject("Scripting.FileSystemObject")
set oFolder = oFileSys.CreateFolder("\\Server-a\c\logs\" & sDate )
end if

'Gets the log files for this machine
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
& strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile")


'This section goes out and gets the hostname this is run on for us.
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)

For Each objItem in colItems
strHOSTNAME = objItem.Name
NEXT


'checks to make sure the folder exists, just in case link is down or something
if oFS.FolderExists("\\Server-a\c\logs\" & sDate) then
For Each objLogfile in colLogFiles
strBackupLog = objLogFile.BackupEventLog _
("\\Server-a\c\logs\" & sDate & "\" & strHOSTNAME & "_" & objLogFile.LogFileName & "_" & sDate & "_" & sTime & ".evt")
objLogFile.ClearEventLog()
Next
end if
 
I believe your issue is permissions based. I grabbed your script and ran it on my own machine with the only change being the machine name. It worked great!

I have encountered problems with creating objects at times when I used the context you are using:
set oFS = wscript.CreateObject("Scripting.FileSystemObject")
Try this instead:
set oFS = CreateObject("Scripting.FileSystemObject")
 
Dropping the wscript off the statment really makes it mad.

Error: Catastrophic failure
Code: 8000FFFF
Source: (null)

Just for fun I swapped out wscript for server too and got the same Catastrophic failure.

If this was embedded in asp I might know where to look for permissions. However since this is just a server script I have no clue what permissions it might or might not have on this server. Got any ideas?
 
I'd assume the problem was witht he NTFS permissions for creating the directory.
 
I had the idea that there was some sort of security policy setting that could prevent one from creating an FSO too.

This machine sounds messed up in some way or other.

Server.CreateObject just uses the CreateObject method of a Server object. This is how ASP does it, but ASP provides such an object for this purpose so it makes sense there.

The main difference between using the WSH object's method (WScript.CreateObject) over the built-in VBScript function is that it allows you to wire up event handlers to the created object. VBScript's own built-in function allows remote object creation (via DCOM) instead.

The various "CreateObject" methods take different parameters and produce different effects. In ASP you almost always want to use Server.CreateObject because of thread management and object lifetime management issues. But this isn't ASP, so I'm drifting off topic.
 
I just had time to start working on this again today. I tried using some kown working asp code that also uses the FileSystemObject. It also errors out when I try running it from this problem server. I checked my Internet Options and they are set right. Also neither the vbs script or the asp code are creating any errors that show in the error log on this server. Its almost like the FileSystemObject dosen't even exist.
 
Wel, another thing to check is to go into regedit and navigate to the key:

HKEY_CLASSES_ROOT\Scripting.FileSystemObject

Right-click on it and select Permissions. Then see what restrictions are in place here. Also check:

HKEY_CLASSES_ROOT\Scripting.FileSystemObject\CLSID
 
Thanks dilettante, I've been hunting a slightly more annoying bug and haven't been back here for a day or so.

I went into the regrestry where you said but I was unable to find a permissions for the scripting.filesystemobject or the clsid just under it. I did check and at least I know the data for the clsid is the same now for both the trouble server and a working server.
 
PHV - I neglected to post that. I know for sure I installed WSH_5_6 a couple times now. Both from a file I downloaded from MS and from the MS scripting guide cd. I also remember installing IE6 again from that cd. I *think* I reinstalled the sp4 patch also after this problem was found, only about 80% sure of that one though.
 
You need to locate the key(s) in regedit, then in the left pane (the tree view) you right-click on the key and select Permissions. This brings up the Permissions dialog.

I'm not saying your problem is here, just that this is one thing that could be preventing you from creating an FSO.
 
Because this is a Windows 2000 Server, you can't use Regedit to view the permissions. You need to use Regedt32 instead.

Regedit and Regedt32 were merged into one in XP and 2003, but in 2K they are still different executables.
 
I think that your problem it's that FSO cant access Network Shares.
You can use.
Code:
Set ws = CreateObject("WScript.Network.1")
ws.MapNetworkDrive "Z:", "\\MyServer\public",false,user,pass
'do job

ws.RemoveNetworkDrive "Z:",true


________
George, M
 
Thanks for your help so far! I've tried the various suggestions and these were the results. My other bug is pretty much tracked down and killed so I can start hitting this one a bit harder.

dilettante, markdmac -
I went through each of the permissions for the file scripting object and its classid. After compairing them to a working server I was unable to find anything different between them. All permissions and the advanced tabs were the same.

JohnYingling -
I sifted through all the settings in Norton Corp edition I could find. I was unable to find where I could enable or disable "Script Blocking".

shaddow -
I've also tried using a local drive instead of a network drive. Still get the same error. I'm pretty sure it crashing before I get to mapping a drive. Every error its thrown when this object is used has been on the CreateObject.
 
JohnYingling -
Pretty sure Norton is innocent on this. Even with the NAV service stopped I still get the error. I tried the vbs file at the link you posted. When I comment out the ON ERROR RESUME NEXT line I get the same catistrophic error message I posted above. Also I tried the same NAV script on another machine and it worked ok, so I know the script is fine.
 
Seems there is an awefully lot of effort going into this server when you know others in your environment are fine and that the scripts you are trying to use work.

Have you considered reloading the OS? I'd try an over the top install followed by service pack and hotfix updates. My thinking is that you are spending more time troubleshooting this than it would take to reload.
 
markdmac -
If it was a plain workstation or our development station I would just reload it. Bad thing is that it's the failover server for our production database. In its main function it works just fine. Only when I run my backup event logs script or IIS fails over do we see a problem. This bug is highly annoying but it dosen't really justify scheduling a possible outage (since we will lose redundancy) for the web server and a couple scripts. This issue will probably be using up a call to MS here in the next couple days.
 
Assuming that the problem is not in the NTFS Permissions, I am still betting on Norton.
See
Notice that MS states "it can also occur in other technologies, such as Windows Scripting.

Note This problem occurs even if Norton AntiVirus has been disabled."


PRB: Antivirus Software Causes FileSystemObject Calls to Hang IIS
View products that this article applies to.
This article was previously published under Q295375
SYMPTOMS
When you browse to an Active Server Pages (ASP) page that contains FileSystemObject calls, the request for that page stops responding (hangs), and then eventually times out in the browser.
CAUSE
This problem occurs because the Script Blocking feature in Norton AntiVirus software blocks scripting operations that access the file system, such as FileSystemObject. Although this problem is prevalent in Active Server Pages (ASP) Web applications, it can also occur in other technologies, such as Windows Scripting.

Note This problem occurs even if Norton AntiVirus has been disabled.

In August 2003, Network Associates McAfee added a feature that is named Script Stopper. Script Stopper is similar to Norton AntiVirus Script Blocker. Currently, Script Stopper blocks access to the FileSystemObject. However, Script Stopper may do more than just block access.


Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top