I have been playing around with this a bit for the last two days and it looks like there are two versions of cscript. If I run cscript from path or from system32 I was having your issue, even though I'm using 32 bit Python as well.
Finally found that there's a 64 bit version in .\syswow64 so when using that it started working.
Additionally, I was getting a traceback error using exit(0); or any combination, but when switching to SystemExit(0) it worked with cscript with no issue.
That's not the end of my rabbit hole, but hopefully it helps you resolve this issue.
My test -
C:\Windows\system32>c:\Windows\SysWOW64\cscript.exe /e:python c:\python34\Scripts\test.py
Many thanks for your reply. I tried your method and lo and behold it worked. The next step I guess would be to make it work through the SAM component, which is still giving me the same error, I guess because it is defaulting to the 32bit version.
How did you make the SAM component/Solarwinds default to the 64bit version?
Really appreciate your assistance so far!
Has anyone gotten this to work as a SAM component?
I have not been able to get any 32 bit version of python to work as: cscript.exe /E:Python <myscript.py>
3.4, 3.5, 3.6, 3.7 all work as: C:\Windows\SysWOW64\cscript.exe /E:Python <myscript>
My next step is to replace C:\Windows\System32\cscript.exe w/ the 64 bit version ( which
sounds dangerous ).
You shouldn't need to replace anything on the local machine, both the 32 bit and 64 bit cscript should be there, they are just in different folders as noted in my post above.
I'm using ActiveState Python 3.6 in our environment successfully to monitor and run various scripts, namely for some storage monitoring via API.
This article will help you get started if you haven't reviewed:
The main reason I fell back to using Active State is that they include the pywin bits that you will need as well. You can get Python running on the machines typically without it, but in order to interact with windows the way you would expect my understanding is the pywin bits add registry entries and the like.
In the article it's referenced as Python 3.4 Extension for Windows x86.