0

I'm trying to figure out why my script isn't running It don't show no error code nor does my script work. Is there a way I can see what the issue is?

Set WshShell = Server.CreateObject("WScript.Shell")
Dim ExecOperation, ExCode, StdOut

python_program = "c:/python37-32/python.exe "

py_file = "C:/inetpub/webroot/hcoutreach.com/PythonScripts/PrintQrCodeConverter.py"

cmdLine = python_program & " " & py_file & " " & intFam_Id

Set ExecOperation = WshShell.Exec(cmdLine)
        
' ' Check the operation's status
While (ExecOperation.Status = 0)
   WaitForMilliseconds(100)
WEnd


' ' Get the operation's exit code
ExCode = ExecOperation.ExitCode

' ' Get the application's StdOut stream
Set StdOut = ExecOperation.StdOut
        
value = StdOut.ReadAll
  • Check you have given the ASP `Execute` permission in the ISAPI extension in IIS. The anonymous user (`IUSR` or whatever you are using) will also need permission to the executable path in NTFS. – user692942 Oct 05 '22 at 13:23
  • Have you tried displaying the `ExCode` and `value` variable back to the page using `Response.Write()`? – user692942 Oct 05 '22 at 13:26
  • @user692942 ExCode=1 and Value is nothing when I response.write – TimmyTurn123 Oct 05 '22 at 13:31
  • @user692942 Look like everything has access – TimmyTurn123 Oct 05 '22 at 13:39
  • So what does `1` mean in the python script? That is the returned output of the script execution. – user692942 Oct 05 '22 at 13:45
  • @user692942 the 1 should be the FamId that I pass – TimmyTurn123 Oct 05 '22 at 13:52
  • @user692942 Im running this on vb script and calling a python program – TimmyTurn123 Oct 05 '22 at 13:53
  • You're running an ASP page (using VBScript) and trying to execute a python script locally on the server and return the output of said script. – user692942 Oct 05 '22 at 13:56
  • @user692942 Correct I just want it to run my python script which print my qr code. – TimmyTurn123 Oct 05 '22 at 13:58
  • So as stated in the [documentation for `Exitcode`](https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/za76z6hh(v=vs.84)) - "Returns the exit code set by a script or program run using the `Exec()` method.", you need to look at the python script to understand why it returns `1`. – user692942 Oct 05 '22 at 14:13
  • @user692942 Can I view this in a window? – TimmyTurn123 Oct 05 '22 at 14:15
  • You can try running the command via the `cmd.exe` on the server but if it's permission related you might not get the same response. What you have to understand about the execution of executables in Classic ASP is it's executed locally to the web server without any access to the GUI (as that wouldn't make sense). – user692942 Oct 05 '22 at 14:23
  • The fact is though, the script executes and returns an `ExitCode` of `1`. You should be looking at the python script to understand what constitutes returning `1`. – user692942 Oct 05 '22 at 14:25
  • @user692942 Yea I checked nothing returns 1 I tested to run from the command line and it works fine. – TimmyTurn123 Oct 05 '22 at 14:27
  • Sounds like a permissions issue if I'm honest. – user692942 Oct 05 '22 at 14:31
  • @user692942 It may be I might be looking at the wrong thing but the permissions have full control except the Creator Owner – TimmyTurn123 Oct 05 '22 at 14:34

0 Answers0