running IDA python without gui

I am trying to run IDA without GUI. My purpose is to run a specific script that receives arguments via my main program against multiple files, but for some reason, it does not work for me. Sometimes it opens IDA without any reason.

I am using the following commands:

One command is: 'C:\\IDA\\ida.exe -B %s' % file

Second command is: cmd = 'C:\\IDA\\ida.exe -a- -A -S"script.py "%s"" %s' % (file, file)

• How is IDA supposed to distinguish the script name from the parameter? You're using the exact same type of quotes (") to denote two different things. You're attempting to quote the overall script+parameters, but you seem to also be quoting the parameter(s) with the same type of quotes. Not sure how you execute this (i.e. which Python module), but cmd.exe is likely going to have an issue telling these apart ... not to mention that file names with blank spaces will garble up the whole thing anyway. Dec 17, 2019 at 22:49

ida.exe -A -S"<path\to\script> <params>" <path\to\file>

-A - autonomous mode - no dialog boxes.

You can use idat.exe instead if ida.exe, which will not open the GUI of IDA.

You can end your script with:

from idc import *
idc.exit()


Which will exit the program when the script is finished.

You can see the complete list of command-line switches here

• Hi, Thanks for the answer. after some tries(the script run) for some reason it does not rerun my scripts anymore. Do you know why ? I use the idat.exe as you said Dec 16, 2019 at 16:13
• Maybe your script fails/gets an exception and dies in certain cases? Dec 16, 2019 at 16:55
• No, nothing fail. Dec 16, 2019 at 20:52
• It's really hard to understand the issue without seeing the script. Another thing that you can do is to look in process monitor and see if instances are created and die, or it doesn't happen. Dec 17, 2019 at 8:45
• @DanielDan how do you know nothing fails? You gave us no indication that there is any error checking involved. Dec 17, 2019 at 22:50

You can make your IDApython script in this format below:


from idautils import *
from idaapi import *
from idc import *
import os
autoWait() # to wait until ida analysis finished
f=open('result.log')#output result to a file
f.write('run script')
f.close()
exit() #close IDA after script finished


then use this command to run,you would see a GUI in a flash，Almost equivalent to no GUI.

./ida -A   -S"<path_to_your_script>" <path_of_binary>  -t


-A means auto run without interactive windows.
-t means make a temporary idb file.