Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <code>WScript.Arguments</code> to access the arguments passed to your script.</p> <p>Calling the script:</p> <pre><code>cscript.exe test.vbs "C:\temp\" </code></pre> <p>Inside your script:</p> <pre><code>Set File = FSO.OpenTextFile(WScript.Arguments(0) &amp;"\test.txt", 2, True) </code></pre> <p>Don't forget to check if there actually has been an argument passed to your script. You can do so by checking the <code>Count</code> property:</p> <pre><code>if WScript.Arguments.Count = 0 then WScript.Echo "Missing parameters" end if </code></pre> <p>If your script is over after you close the file then there is no need to set the variables to <code>Nothing</code>. The resources will be cleaned up automatically when the cscript.exe process terminates. Setting a variable to <code>Nothing</code> usually is only necessary if you explicitly want to free resources during the execution of your script. In that case, you would set variables which contain a reference to a COM object to <code>Nothing</code>, which would release the COM object before your script terminates. This is just a short answer to your bonus question, you will find more information in these related questions:</p> <blockquote> <p><a href="https://stackoverflow.com/questions/517006/is-there-a-need-to-set-objects-to-nothing-inside-vba-functions">Is there a need to set Objects to Nothing inside VBA Functions </a> </p> <p><a href="https://stackoverflow.com/questions/30354/when-must-i-set-a-variable-to-nothing-in-vb6">When must I set a variable to “Nothing” in VB6?</a></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload