![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | Script file has 'OS Handle' error when run from script For my batch automation product, ActiveBatch, I've written a ps1 which is called from a cmd file, and which runs fine when run from command prompt. The script runs fine from a command prompt, but when I run it from within ActiveBatch, it starts off ok but then fails with this message: "Write-Host : The OS handle's position is not what FileStream expected. Do not use a handle simultaneously in one FileStream and in Win32 code or another FileStream. This may cause data loss." The code it doesn't like is a write-host that documents the script's progress. Interactively, messages appear on the console, but as it's being run by ActiveBatch the messages are being written to a log file. The first 3 messages appear in the log file ok: C:\XXExtract\XXExtract_Scripts>powershell .\XXExtract.ps1 "userid" "password" 16:20:00: Initialising 16:20:00: Getting subs list 16:20:00: Processing XXXX sp (return status = 0) The point at which it's failing is when the '(return status = 0)' message is generated, which I've checked by redirecting it: > NULL, whereupon the error doesn't appear there, but then does appear for subsequent messages. Actually, I'd like to keep all the output in the log file. The message isn't documented anywhere I can find. Can anybody explain why it might be getting upset and what I can do to get all my messages logged and a happy and fulfilled script? Jay |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Script file has 'OS Handle' error when run from script On Sep 18, 12:03 pm, "Jay" <j...@xxxxxx> wrote: Quote: > For my batch automation product, ActiveBatch, I've written a ps1 which is > called from a cmd file, and which runs fine when run from command prompt. > The script runs fine from a command prompt, but when I run it from within > ActiveBatch, it starts off ok but then fails with this message: > > "Write-Host : The OS handle's position is not what FileStream expected. Do > not use a handle simultaneously in one FileStream and in Win32 code or > another FileStream. This may cause data loss." > > The code it doesn't like is a write-host that documents the script's > progress. Interactively, messages appear on the console, but as it's being > run by ActiveBatch the messages are being written to a log file. The first 3 > messages appear in the log file ok: > > C:\XXExtract\XXExtract_Scripts>powershell .\XXExtract.ps1 "userid" > "password" > 16:20:00: Initialising > 16:20:00: Getting subs list > 16:20:00: Processing XXXX sp > (return status = 0) > > The point at which it's failing is when the '(return status = 0)' message is > generated, which I've checked by redirecting it: > NULL, whereupon the error > doesn't appear there, but then does appear for subsequent messages. > Actually, I'd like to keep all the output in the log file. > > The message isn't documented anywhere I can find. Can anybody explain why it > might be getting upset and what I can do to get all my messages logged and a > happy and fulfilled script? > > Jay captured in any way) to a file. Additionally, I take it you meant "> nul" (one L, not two?) If this annoys you as much as I think it probably will (you're not alone), you can vote for it (to be fixed for v2) here: https://connect.microsoft.com/feedba...7055&SiteID=99 - Oisin |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Converting a BAT script into a PowerShell Script | PowerShell | |||
| Logon Script Causing Laptops To Hang - Problems in script? | VB Script | |||
| problem passing args to script 'There is no script engine for file extenstion' | VB Script | |||
| Include another script, keep variables in included script? | PowerShell | |||
| Can you drag-n-drop a file on top of a PS script to run the script? | PowerShell | |||