I don't think it is specifically related to Server 2016 but more likely something the script itself is doing. If the script is erroring then you should be able to determine which line it is failing on. Provide the code that is failing so we can see what is going on.
Run .vbs file

Hi!
I don't know about scripting in vbs. Here in the environment we have a 2008 Standard R2 server with scheduling that executes a .bat file with: cscript file.vbs
Everything works normally. But I need to migrate this server to a 2016 and when testing this same process it gives error "Microsoft VBScript runtime error: Array fixed or temporarily blocked" code 800A000A
I noticed that when I run it in 2008 it shows "Microsoft (R) Windows Script Host Version 5.8" and when I run it in 2016 the version is "Microsoft (R) Windows Script Host Version 5.812"
What do I need to do for this same .vbs script that is functional to also run in 2016?
If it was a problem in the script it wouldn't work on server 2008, don't you think?
It seems to me that it needs some specific configuration to run, but I really don't know about vbs scripts. I even tried to do the same process all in bat but the script is quite complex, it does several date and file name checks.
Not necessarily true, but we are working with a single error message and no context so we are only guessing. The more information you provide the quicker you can get a solution. The error itself, if it occurs before the script runs, indicates a configuration issue perhaps. But if it occurs after the script starts running then it indicates a problem with either whatever the script is working with or the script itself. The error leads me to believe that previously it was working with multiple items (an array??) and now it is working with one. This could be a change in an API call. Again, we have absolutely no way of diagnosing this without more information.
You can quickly confirm VBS works on the new server by creating a simple vbs script that simply displays a message box. If it works then VBS is fine. At that point you need to debug the script itself.
OK.
This is the vbs that is running on 2008:
This is the error when trying to run the same in 2016:
This script isn't correct for VBS. Honestly I'm not sure how it would have worked before. The first thing I notice is that
NumPC(0) = "221"
is invalid. VB arrays are 1 based so the first element isNumPc(1)
. But maybe this is a quirk with VBS.The actual error you're seeing though is the
foreach
. You are attempting to store intoNumPC
the current element ofNumPC
(the array). This is trying to use the array variable as a temp variable for elements in the array and that won't work.Change each reference to
NumPC
inside the for loop toitem
. Then try it again.I made the adjustment with the item variable and the error changed. Then I changed the array starting with 1 and it showed the same error:
It seems that the previous errors were solved. Show the line 37 that gives the new error, or better show your current full script. Maybe the error is caused by incorrect assumption regarding the lower bound of arrays.
At this point the code appears correct and you're now running into a runtime error related to the file management. Since we don't have your server setup it would be difficult for us to debug this for you so you might need to debug yourself. However I ran the equivalent code and it correctly copies/creates/deletes files. Here's the updated script that I cleaned up a little while checking to see if there are any issues.
I suspect that the issue might be that one of the machines in your array that you're enumerating through is returning
Nothing
for one of the FSO calls. Therefore the script fails. You should consider wrapping the contents of the actual work inside thefor each
in an error handler so you can skip over machines that have issues.Perfect! It worked correctly.
Following your code I realized that I had missed changing the variable between &&. It was still NumPC instead of Item.
Sign in to comment
0 additional answers
Sort by: Most helpful