Link to home
Start Free TrialLog in
Avatar of Andrew Davis
Andrew DavisFlag for Australia

asked on

VBS Script Microsoft VBScript runtime error: Permission denied: 'CreateObject'

I created a small vbs script as per below, it resides on a 2003 Terminal server. i can run the script without issue and so could the receptionist. However now when the receptionist runs it she gets the following message:

X:\directory\rename.vbs(3, 1) Microsoft VBScript runtime error: Permission denied: 'CreateObject'

I have googled to my hearts content and most of the answers relate to giving iusr and iwam access to the folder, (I tried doing this to no effect, however we are not accessing this via the web). I can still run the script but I am the administrator. I have given the user full permission to the folder and the active folder, but still no good.

Can you help.

----------------------Script---------------------------
Dim fso,fold,fil,NewName,NewNameStart,CreateTime,arrTime,AmPm,C1,C2

Set fso = CreateObject("Scripting.FileSystemObject")
Set fold = fso.GetFolder("X:\scans")

    Wscript.echo "Renaming all the Tif files in the scan directory"
' loop through files
For each fil in fold.files
  ' make sure we only have files that begin with 192168 and end in .tif*
  If Left(fil.Name,6) = "192168" And Left(Mid(fil.Name,InstrRev(fil.Name,".")),4) = ".tif" Then
   ' Build New Filename based on original name
    NewName = Right(fil.name,14)
    newnamestart = left(newname,10)
    If fso.FileExists(fold.Path & "\" & NewName) Then
      C1=1
      C2=1
      Do
            newname=newnamestart & "-" & C2 & ".tif"
            C2 =C2 + 1
            If Not fso.FileExists(fold.Path & "\" & NewName) Then
             C1=2
            End If
      Loop Until C1=2      
    End if
    Wscript.echo "Processing " & newname
    fso.MoveFile fil,fold.Path & "\" & NewName
  End if
Next

Set fil = Nothing
Set fold = Nothing
Set fso = Nothing

---------------------End of Script-------------------------
Avatar of Nightman
Nightman
Flag of Australia image

Have a look at this - suggests using the permission checker.
http://authors.aspalliance.com/brettb/FileAndFolderCheckers.asp

This way you can at least determine which file or folder it is failing on.

Also, look at http://www.aspemporium.com/tutorials.aspx?tid=9 - suggests that perhaps the user needs permission to access the SCRRUN.dll
check whether ur server runs any anti virus application and that blocks script running.
if so disable that option and try again

>>fso.MoveFile
u need to have write permission on the folder
also check the folder permission
Avatar of Andrew Davis

ASKER

Nightman
the asp alliance doesnt work as the script is not running from ASP, But i tried anyway.
as for the acrrun.dll i changed that to give iusr, iwam, and the user's accouts full access to this dll but still no good.
i tried giving the user full rights to the system32 directory (and propagated the setting) but still no good. so this indicates its nothing in that directory.

shijusn
not antivirus. and the user has full access to the related folders and files. i can create modify delete any file in this directory with the users account.
Is it failing on trying to access the files, or on the CreateObject?
on the createobject
Then it is not folder permissions - will google.
Found an article suggesting that you need the latest scripting runtime. Don't know if this is the cause, but worth a shot - will keep looking
ASKER CERTIFIED SOLUTION
Avatar of Nightman
Nightman
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dave_moats
dave_moats

If you can run the script the script with no issue on the term serv and the receptionist gets a "can't create object" on line three of the script:

              Set fso = CreateObject("Scripting.FileSystemObject")

Would I be correct in assuming that you are an admin on the server and the receptionist is not?

If this is the case, It may be an issue with the scrrun.dll permissions.  Check c:\windows\system32\scrrun.dll and make sure the receptionist has read /read & execute permissions to it.
Sorry dave that was covered ealier when i gave the entire sytem32 directory the privilages.

just to throw a weird one in this problem seems to have resolved itself with no known fix.

i went awy from this problem for a couple of weeks and in the mean time the problem has stopped and everything is now working properly. In that time i did install SP1 for 2003 so that is the most likely answer. But who knows.

Nightman i will give you the points as i beleive everything you told me was correct.