How to run an exe file in a completely hidden way - python-2.7

I'm able to execute an exe file via command prompt using below line:
process = subprocess.Popen("LogCollector.EXE ")
But the LogCollector.EXE GUI is still visible, Please suggest some method to run this completely in hidden way.

import os
os.system('start /MIN notepad.exe');
Use this command in the window, it will run the application and minimize the application.
Maybe it will help you

Related

How to enable System Error message when running executable from command line

According to Microsoft, "If [the system] cannot locate the DLL, the system terminates the process and displays a dialog box that reports the error. " This is the result I get when I run my application outside of the command line, but I do not get the same system error when I run the application from a shell environment such as command prompt or powershell.
Is there a way to show the same error message when the application is run from a command line interface?
https://msdn.microsoft.com/en-us/library/aa271571(v=vs.60).aspx
SetErrorMode(GetErrorMode() & ~SEM_FAILCRITICALERRORS);
but I don't think you want to do this, as you do not know in which environment the user will run your application.
It is usually now a good idea to popup a dialogbox in e.g. a service environment.
What is the problem with examining the error code of whatever is failing e.g. LoadLibrary() and reacting to this error?

Strange CMD errors only when CMD is opened from my program

This is a weird one for sure.
If I open a command prompt window directly (searching cmd in start, right click > open command window here, cmd within bat file, etc....) all commands entered run perfectly fine.
If I open a command prompt window from within my C++ application (system("cmd"); or QProcess::startDetached("cmd"); etc....) the commands I enter throw errors.
Here are a few commands that don't work in the cmd opened from my app:
vssadmin delete shadows /all
vssadmin list shadows
wmic
shadowcopy
and so on... I get Class not registered and Initialization failure errors all around. Anything to do with shadow copies isn't working at all. But again, the weird thing is, those same commands work perfectly fine when cmd was opened traditionally (not from a program). Both instances of cmd have admin privileges.
So my question is, how come the way I open cmd affects whether or not some commands work? Everything I can see says there should be no difference.
32-bit applications running on WOW64 will be put under file system redirection. Therefore if your app is a 32-bit one, the call system("c:\\windows\\system32\\cmd.exe"); will be redirected to C:\Windows\SysWOW64\cmd.exe and 32-bit cmd will always be invoked. You have some solutions:
Use system("c:\\windows\\sysnative\\cmd.exe"); to access the real system32 folder and get the 64-bit cmd
Turn off file system redirection explicitly (should be avoided in general)
Or better compiling it as a 64-bit app.

Windows Qt Invoke batch file and exit the App

I am developing an application in Windows8 using Qt, where I need to create an updater for it. I have Already wrote the update downloader part, and an update script to replace all the previous content with newly downloaded data.
Now I need to execute the bat file from the application itself, and exit the app before the script get executed, because the script going to remove all the dlls and application binary currently I am running.
How can I resolve this issue?
Thanks
Haris
You can use QProcess::startDetached to run an instance of command prompt with the batch file as the argument in a new process and detach from it. After that you should exit the application :
QProcess::startDetached("cmd.exe", QStringList() << "/c" << "path\\to\\mybat.bat");
qApp->quit();

How to open text file in notepad with cmd window in background?

I want to open a text file without opening cmd window in the background. I have tried:
webbrowser.open('file.txt')
but it crashes ArcGIS so I tried following:
os.system('file.txt')
it opens text file without crashing ArcGIS but cmd window remains in the background and goes away when I close text file.
It is more of a display choice question and just checking if there is any suggestion to avoid cmd window in the background.
I don't know if this is what you want, but maybe you should create .bat file (something like here) and run this with Python subprocess.
Save your script with a .pyw extension and the console window won't appear.
From the Python documentation :
On Windows systems, there is no notion of an “executable mode”. The Python installer automatically associates .py files with python.exe so that a double-click on a Python file will run it as a script. The extension can also be .pyw, in that case, the console window that normally appears is suppressed.
You need to modify the program that calls the "add-in script" to run it with pythonw.exe (and not python.exe which is the default).

Load a new exe with gdb

I am currently trying to make use of gdb to disassemble an exe, and from my home, I start the application like such:
gdb "c:\file.exe"
And gdb starts and loads that file automatically.
Now the problem is that from where I am atm, the command prompt is disabled and thus I cannot run the terminal window with the filename as the argument.
The only thing I think can do atm is open the gdb.exe file directly and then load the exe with a command or something, from gdb itself.
Is there a command I can use to load the exe to debug from within the application itself rather than passing it as an argument?
(gdb) <some command> "c:\file.exe"
(gdb)file c:\file.exe
To start debugging it , use the file command, as #Arkaitz Jimenez said
If your file.exe is a running process, you can use the attach command