Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7707829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:27:33+00:00 2026-06-01T00:27:33+00:00

That’s my first time posting on stackoverflow. I’ve been finding usefull answers on this

  • 0

That’s my first time posting on stackoverflow. I’ve been finding usefull answers on this site but this time, I can’t find no help with this problem.

General context

I wrote a VBScript Toolkit script (S:\Universe_bo\prod\batch\BO\libs\PXI_Toolkit.vbs) included in scripts (S:\Universe_bo\prod\batch\BO*.wsf) that are executed by a scheduler software.

The system is a Windows Server 2003 server (this server is part of an active-passive Windows cluster and the S: drive is a resource of this cluster). The Windows user running the scripts has permission to write in the directory and is an Administrator.

In the scripts, I open a new file and write some text in it (it is the content of an e-mail).

The problem

Here is what happens (today, it crashed 7 out of 10 times):

(—) [24/03/2012 10:34:23] Ouverture du fichier [S:\universe_bo\prod\data\email_rad98038.tmp]
S:\universe_bo\prod\batch\BO\BOLANC_BOAPP500_TOP100.wsf(2451, 8) Erreur d’exécution Microsoft VBScript: Permission refusée

It means “Runtime error Microsoft VBScript: Permission denied”.

The line 2451 from the script is the following:

Set objFichier = fso.OpenTextFile(_
      pvstrNomFichierCorpsEmail, _
      ForWriting, _
      True)

We have been using them for two years without a problem on the test server (not a cluster) but now that it finally passed production, it doesn’t work all the time.

I have no idea what the problem could be, I’m all ears and will take any suggestion.

Thanks in advance.

Guillaume

Source scripts

.wsf script

The .wsf scripts look like this:
(I removed the irrelevant parts, and comments are in French since we are)

'===============================================================================
' BOLANC_BOAPP500_TOP100.wsf (script)
'===============================================================================
<job><?job debug="true"?>
<script language="VBScript" src="libs/PXI_Toolkit.vbs"/>
<script language="VBScript">
Dim codeRetour ' Le code retour du script
codeRetour = 0 ' est initialisé à 0 (tout va bien)

' [...]
' Irrelevant stuff
' [...]

' Exécuter le rapport
codeRetour = rapport.Executer


LibererRessources
Wscript.Quit codeRetour
</script>
</job>

Toolkit script

And here are the involved parts of the PXI_Toolkit.vbs script:

Option Explicit
'===============================================================================
' PXI_Toolkit.vbs (script)
'===============================================================================


'*******************************************************************************
' fso (objet)
'       Scripting.FileSystemObject
'*******************************************************************************
dim fso
set fso = CreateObject("Scripting.FileSystemObject")

'*******************************************************************************
' Constantes pour l'ouverture des fichiers
'*******************************************************************************
Private Const ForReading = 1 ' Ouvre un fichier en lecture seule. 
Private Const ForWriting = 2 ' Ouvre un fichier en écriture.
Private Const ForAppending = 8 ' Ouvre un fichier et permet l'écriture à la fin
                               ' du fichier.

'*******************************************************************************
' WshShell (objet)
'       Objet Permettant d'accéder aux fonctionnalités systèmes Windows.
'*******************************************************************************
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

'*******************************************************************************
' WshSysEnv (tableau de chaînes)
'       Tableau contenant les variables d'environnements. WshSysEnv est indexé
'       par le nom des variables qu'il contient.                            
'       Exemple : Ecrire "Utilisateur="& WshSysEnv("USERNAME")
'*******************************************************************************
Dim WshSysEnv
Set WshSysEnv = WshShell.Environment("Process")

' Lots of stuff

'*******************************************************************************
' EcrireErr (procédure)
'       Affiche un message d'erreur.
'
' Paramètres :
' - pstrMessage (chaîne)
'       Message d'erreur à afficher.
'*******************************************************************************
Sub EcrireErr(pstrMessage)
  WScript.stdErr.WriteLine "(!!!) ["& Now &"] "& Cstr(pstrMessage)
End Sub ' EcrireErr

'*******************************************************************************
' EcrireLog (procédure)
'       Journalise un message dans les logs.
'
' Paramètres :
' - pstrChaine (chaîne)
'       Texte à journaliser.
'*******************************************************************************
Sub EcrireLog(pstrChaine)
  Ecrire "(---) ["& Now &"] "& Cstr(pstrChaine)
End Sub ' EcrireLog

'*******************************************************************************
' LibererRessources (procédure) 
'       Libère les ressources potentiellement ouvertes au cours de l'exécution
'       des fonctions de ce script.
'
' Paramètres : Aucun
'*******************************************************************************
Sub LibererRessources()
  EcrireLog "LibererRessources"

  ' Libérer les variables système
  Set WshArguments = Nothing
  Set WshSysEnv = Nothing
  Set WshShell = Nothing
  Set fso = Nothing
End Sub ' LibererRessources

Class ClsRapportBO
  Private pvarrstrMessageEmail pvstrNomFichierCorpsEmail

  Public Function Executer()
    ' Ecriture du fichier contenant le corps du mail
    If Not IsEmpty(pvarrstrMessageEmail) Then
      Dim objFichier, strLigne

      EcrireLog "Ouverture du fichier ["& pvstrNomFichierCorpsEmail &"]"
      Set objFichier = fso.OpenTextFile(_
          pvstrNomFichierCorpsEmail, _
          ForWriting, _
          True)

      ' Ecriture de l'en-tête du message
      objFichier.WriteLine "Bonjour"
      objFichier.WriteLine

      ' Lecture des éléments du tableau construire le fichier
      For Each strLigne In pvarrstrMessageEmail
        objFichier.WriteLine strLigne
      Next

      ' Ecriture du pied de page
      objFichier.WriteLine 
      objFichier.WriteLine "NB : Ce message est envoyé automatiquement. "&_
                           "Merci de ne pas y répondre."

      objFichier.Close
    End If

    ' More stuff

    If Not IsEmpty(pvarrstrMessageEmail) And fso.FileExists(pvstrNomFichierCorpsEmail) Then
      EcrireLog "Suppression du fichier ["& pvstrNomFichierCorpsEmail &"]"
      fso.DeleteFile(pvstrNomFichierCorpsEmail)
    End If
  End Function ' Executer
End Class ' ClsRapportBO

Function CreerRapportBO(pstrChemin, parrstrInvites, pstrToken)
  Dim objRapport

  Set objRapport = new ClsRapportBO
  ' ...
  Set CreerRapportBO = objRapport
End Function ' CreerRapportBO

' Tests de la boîte à outils
Sub TestsUnitaires()
  ' Unit tests...
End Sub ' TestsUnitaires
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:27:35+00:00Added an answer on June 1, 2026 at 12:27 am

    Is “S:\universe_bo\prod\data\email_rad98038.tmp” a file created by the script, or a file created by another process? A likely cause of this problem is that the file is in use. You can wrap the statement with:

    On Error Resume Next
    Set objFichier = fso.OpenTextFile(_
      pvstrNomFichierCorpsEmail, _
      ForWriting, _
      True)
    On Error GoTo 0
    
    If Not IsObject(objFichier) Then
    ...
    More Logic Here
    ...
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That should be simple web site but with an editable tree. This tree will
That might sound silly but can't do it myself :( Need your help guys.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's it. It's a dumb dumb (embarrassing!) question, but I've never used C# before,
that one has been nagging me ever since I dabbled in web developpement; is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That show up on menu bar It's like this question: How to create a
That is the question. Background: C# Params In C#, you can declare the last
That's it. How can I get the old value of a textarea in order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.