Hi,
i tried to capture the exit code for =0 value but it is failing at !=0
folder delete c:\temp\test
folder create c:\temp\test
parameter “error” = “{exit code of action}”
if {parameter “error” = “0”}
exit 0
else
exit 100
endif
Hi,
i tried to capture the exit code for =0 value but it is failing at !=0
folder delete c:\temp\test
folder create c:\temp\test
parameter “error” = “{exit code of action}”
if {parameter “error” = “0”}
exit 0
else
exit 100
endif
Interesting.
It looks like the exit code of action does not actually exist until you do a wait, waithidden or waitdetached action line.
folder delete c:\test
folder create c:\test
parameter "error"="{exit code of action}"
exit 100
Command succeeded folder delete c:\test (action:2555)
Command succeeded folder create c:\test (action:2555)
Command failed (Relevance substitution failed) parameter "error"="{exit code of action}" (action:2555)
vs
wait cmd.exe /C rd c:\test
wait cmd.exe /C md c:\test
parameter "error"="{exit code of action}"
exit 100
Command succeeded (Exit Code=0) wait cmd.exe /C rd c:\test (action:2554)
Command started - wait cmd.exe /C md c:\test (action:2554)
Command succeeded (Exit Code=0) wait cmd.exe /C md c:\test (action:2554)
Command succeeded parameter "error"="0" (action:2554)
Command succeeded (100) exit 100 (action:2554)
And inside the if does work
wait cmd.exe /C rd c:\test
wait cmd.exe /C md c:\test
parameter "error"="{exit code of action}"
if {false}
exit 0
else
exit 100
endif
Command succeeded (Exit Code=0) wait cmd.exe /C rd c:\test (action:2556)
Command started - wait cmd.exe /C md c:\test (action:2556)
Command succeeded (Exit Code=0) wait cmd.exe /C md c:\test (action:2556)
Command succeeded parameter "error"="0" (action:2556)
Command succeeded (100) exit 100 (action:2556)
still same issue
Your debugger is running in a different context than the actual BigFix agent.
Try it again from the console on a test machine?
I believe the action will always be marked as Failed of you use the exit
statement to end prematurely.
A better check may be
continue if {exit code of action = O}
…
The ‘exit code of action’ property is only being set by the ‘wait’ or ‘waithidden’ commands. You should put the ‘continue if’ statement after the ‘wait’ statements.
This is the same case as before, you’re forcing an ‘exit 100’ command, which ends the action early with a failure.
I’m not sure what you’re trying to do here, with your relevance clause escaped by {{
Just try
wait cmd.exe /c rd c:\tmp\test1
wait cmd.exe /c md c:\tmp\test1
continue if {exit code of action = 0}
Hi @JasonWalker,
I am trying to capture success / failure with action script
if bigfix action script executed successfully then post of it do stat-1 or if failed then post do stat -2
Is ti possible via to get this with exit code of action??
Sure, just don’t use the ‘exit’ statement unless you want the script to end with a Failure.
wait cmd.exe /c rd c:\tmp\test1
wait cmd.exe /c md c:\tmp\test1
if {exit code of action = 0}
wait cmd.exe /c echo "I succeeded" > c:\temp\output.txt
// Do not exit the action, leave it with Success
else
wait cmd.exe /c echo "I failed" > c:\temp\output.txt
// Terminate action and mark Failed
exit {exit code of action}
endif
thanks for your help. but it failed at with exit code 7 ? Is it expected behavior as there is nothing failed in the command side.
I think the exit code 7 is an artifact of the Fixlet Debugger. Have you run this on a client through an Action?
yes it worked from console action on client , thanks for your help.
Finally run the query with origional code and found when i add prefetch block it throws Relevance substitution error
but with prefetch block is works fine. is it something else i need to take care of prefetch block to execute with exit code ??
//Download SetDefaultBrowser.exe file to set the default browser
prefetch e4ce8622391558f88271a3fb9a78061fc414eb7b sha1:e4ce8622391558f88271a3fb9a78061fc414eb7b size:31118 http://server:52311/Uploads/e4ce8622391558f88271a3fb9a78061fc414eb7b/SetDefaultBrowser.exe.tmp sha256:cff98bc01881ce34e08841c7661ef89c5bb723f24c6900cafc8675ec902e0a46
extract e4ce8622391558f88271a3fb9a78061fc414eb7b “c:\temp”
override wait
hidden=true
completion=job
RunAs=currentuser
wait c:\temp\SetDefaultBrowser.exe HKLM “Google Chrome”
if {exit code of action = 0}
delete __createfile
delete c:\temp\snow.bat
createfile until eof
cd c:\temp\curl
<<snow-query - replaced>
eof
move __createfile c:\temp\snow.bat
override wait
hidden=true
completion=job
RunAs=currentuser
wait c:\temp\snow.bat
endif
ActionLogMessage: (action:1190148) Action signature verified for Downloads
ActionLogMessage: (action:1190148) Relevance substitution error.
ActionLogMessage: (action:1190148) ending action
Can you please try this variation?
if {exists action whose (exit code of it = 0)}
Could the substitution error be coming from your <<snow-query - replaced>
?
yes it is working now with successful message, but not taking failed scenario. I think there is no issue with snow.bat file
i wrongly given exe to exe1 and it failed there itself not taking else part
// create auto close incident via snow.bat download http://server:52311/Uploads/stage/curl/curl.bfswd extract "curl.bfswd" "{name of drive of windows folder}\temp\curl"//checking c:\temp exists
if { not exists folder “c:\temp”}
folder create “c:\temp”
endif
prefetch e4ce8622391558f88271a3fb9a78061fc414eb7b sha1:e4ce8622391558f88271a3fb9a78061fc414eb7b size:31118 http://server:52311/Uploads/e4ce8622391558f88271a3fb9a78061fc414eb7b/SetDefaultBrowser.exe.tmp sha256:cff98bc01881ce34e08841c7661ef89c5bb723f24c6900cafc8675ec902e0a46
extract e4ce8622391558f88271a3fb9a78061fc414eb7b “c:\temp”
waithidden cmd.exe /C cacls.exe c:\temp\SetDefaultBrowser.exe /E /G Everyone:R
override wait
hidden=true
completion=job
RunAs=currentuser
wait c:\temp\SetDefaultBrowser.exe1 HKLM “Google Chrome”
if {exists action whose (exit code of it = 0)}
// Do not exit the action, leave it with Success
delete __createfile
delete c:\temp\snow.bat
createfile until eof
cd c:\temp\curl
<>
eof
move __createfile c:\temp\snow.bat
override wait
hidden=true
completion=job
RunAs=currentuser
wait c:\temp\snow.bat
else
// Terminate action and mark Failed
delete __createfile
delete c:\temp\snow.bat
createfile until eof
cd c:\temp\curl
<>
eof
move __createfile c:\temp\snow.bat
override wait
hidden=true
completion=job
RunAs=currentuser
wait c:\temp\snow.bat
exit {exit code of action}
endif
Command failed (Thread execution failed (2)) wait c:\temp\SetDefaultBrowser.exe1 HKLM “Google Chrome” (action:1190233)
Your action is failing before you get to the Exit Code check. Something going on with
wait c:\temp\SetDefaultBrowser.exe1 HKLM "Google Chrome"
i changed the exe to exe1 to see the failed scenario , so that it should go to else part , but it failed there itself
I have multiple part of action it may fail anywhere to see the failed , but not sure why it not going to else part
The thread execution failure is fatal to the action.
Your action will stop there regardless of any processing after.
any suggestion how to go with else part to generate the snow case ?