WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: morenos1 on November 05, 2013, 09:54:45 AM

Title: Getting different results from uncompiled vs compiled script.
Post by: morenos1 on November 05, 2013, 09:54:45 AM
I have this script to check if a process is running. I can run the script and get the expected result (no match). If I compile and run, I get a result other than no match. I am attaching both debug files.

AddExtender("WWPRC44I.DLL")
AddExtender("WWWNT34I.DLL")

;IntControl(12,5,0,0,0) ; Terminate silently

;ErrorMode(@OFF)

DebugTrace(@on,"C:\temp\comp-trace.log")

username=wntGetUser(@default)
id=tListProc()

start = 1
daend = StrIndexNC(id, "mct", start, @FWDSCAN)

message ("info", daend)

If daend == 0
   exit
Else
   COMSPEC = Environment("COMSPEC")
   runwait (COMSPEC, "/c shutdown /a")
   
   ;Write message to EventLog
      
   ;Type    Value
   ;0       SUCCESS
   ;1       ERROR
   ;2       WARNING
   ;4       INFORMATION
   ;8       AUDIT_SUCCESS
   ;16    AUDIT_FAILURE
      
   msg = StrCat (username, " ", "Issued a MCT shutdown while running...")   
      
   WshShell = CreateObject("WScript.Shell")
   WshShell.LogEvent(4, msg)
   
   Message("Attention", "MCT is still running. MCT needs to exit before a shutdown ..")
EndIf
Title: Re: Getting different results from uncompiled vs compiled script.
Post by: Deana on November 05, 2013, 11:28:44 AM
Try recompiling the script using the same manifest settings as the uncompiled script. Your uncompiled script is using HighestAvailable/True.
Title: Re: Getting different results from uncompiled vs compiled script.
Post by: morenos1 on November 05, 2013, 11:46:10 AM
Same results ..
Title: Re: Getting different results from uncompiled vs compiled script.
Post by: Deana on November 05, 2013, 12:32:56 PM
Ok the problem is the compiled exe (MCT shutdown script.exe) name contains the same keyword the script is looking for

Code (winbatch) Select
daend = StrIndexNC(id, "mct", start, @FWDSCAN)

Rename the EXE to "shutdown script.exe". That should resolve the issue.