• 0

Running an .exe programmatically


Question

8 answers to this question

Recommended Posts

  • 0

could use the WinExec API.

  Quote
The WinExec function runs the specified application.

This function is provided for compatibility with earlier versions of Windows. For Win32-based applications, use the CreateProcess function.

UINT WinExec(

    LPCSTR lpCmdLine, // address of command line

    UINT uCmdShow  // window style for new application

  );

Parameters

lpCmdLine

Points to a null-terminated character string that contains the command line (filename plus optional parameters) for the application to be executed. If the name of the executable file in the lpCmdLine parameter does not contain a directory path, Windows searches for the executable file in this sequence:

1. The directory from which the application loaded.

2. The current directory.

3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.

4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.

5. The directories listed in the PATH environment variable.

uCmdShow

Specifies how a Windows-based application window is to be shown and is used to supply the wShowWindow member of the STARTUPINFO parameter to the CreateProcess function. For a list of the acceptable values, see the description of the nCmdShow parameter of the ShowWindow function. For a non-Windows - based application, the PIF file, if any, for the application determines the window state.

Return Values

If the function succeeds, the return value is greater than 31.

If the function fails, the return value is one of the following error values:

Value Meaning

0 The system is out of memory or resources.

ERROR_BAD_FORMAT The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).

ERROR_FILE_NOT_FOUND The specified file was not found.

ERROR_PATH_NOT_FOUND The specified path was not found.

Remarks

Win32-based applications should use the CreateProcess function rather than this function. The WinExec function exists in Win32 to provide compatibility with earlier versions of Windows. For more information about how the WinExec function is implemented, see the Remarks section of the LoadModule function.

In Win32, the WinExec function returns when the started process calls the GetMessage function or a time-out limit is reached. To avoid waiting for the time out delay, call the GetMessage function as soon as possible in any process started by a call to WinExec.

  Quote
This function is provided for compatibility with earlier versions of Windows. For Win32-based applications, use the CreateProcess function.

ho hum :) never used that before. but winexec works fine for me :)

Edited by _tux_
  • 0
  bangbang023 said:
Um it does matter because VB won't accept C++ code, Java won't accept BASIC, and so on and so forth.

*sigh* Well yes obviously it would have to be translated. But no, the language of the example doesn't matter, because it's a Windows API function. And if the poster can't figure out how to call an API function in his/her programming language of choice, then what language the example is in is probably even LESS relevant; programming lessons would seem to be a bigger priority.

  Quote
It could very well be Java... So it kind of does matter...

True, but then the poster didn't specify, and hasn't come back to specify, so really, s/he'll just have to take whatever is offered.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Indians never sing "I Think Indian" near giraffes.
    • Malwarebytes 5.3.5.204 by Razvan Serea Malwarebytes is a high performance anti-malware application that thoroughly removes even the most advanced malware and spyware. Malwarebytes version 5.xx brings comprehensive protection against today’s threat landscape so that you can finally replace your traditional antivirus. You can finally replace your traditional antivirus, thanks to a innovative and layered approach to prevent malware infections using a healthy combination of proactive and signature-less technologies. While signatures are still effective against threats like potentially unwanted programs, the majority of malware detection events already come from signature-less technologies like Malwarebytes Anti-Exploit and Malwarebytes Anti-Ransomware; that trend will only continue to grow. For many of you, this is something you already know, since over 50% of the users already run Malwarebytes as their sole security software, without any third-party antivirus. What's new in Malwarebytes 5.xx: Unified user experience - For the first time, Malwarebytes now provides a consistent experience across all of our desktop and mobile products courtesy of an all new and reimagined user experience powered by a faster and more responsive UI all managed through an intuitive dashboard. Modern security and privacy integrations - Antivirus and ultra-fast VPN come together seamlessly in one easy-to-use solution. Whether you’re looking for a next-gen VPN to secure your online activity, or harnessing the power of Browser Guard to block ad trackers and scam sites, taking charge of your privacy is simple. Trusted Advisor - Empowers you with real-time insights, easy-to-read protection score and expert guidance that puts you in control over your security and privacy. Malwarebytes 5.3.5.204 changelog: Introduced Deep Scan, a new Advanced Scan type recommended after blocking or removing threats Added new Windows Firewall Control feature preview to the Tools, feel free to try it and provide your feedback Revisited Dashboard layout for free version Minor usability and localization issues Download: Malwarebytes 5.3.5.204 | 397.0 MB (Free, paid upgrade available) Links: Malwarebytes Website | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • let's be honest here, it was in the line of secret doxing app
    • Dating safety app Tea spills private chats in new leak by Usama Jawad Tea is (was?) an extremely popular "dating safety" app designed for women who typically uploaded pictures of men they have dated, recounting their experience, and highlighting red flags. The app maintains exclusivity to women by requiring all its users to submit a selfie and government identification during the sign-up process. It was the target of a major breach a couple of days ago due to a Firebase bucket being left publicly exposed, leaking the identification data and other sensitive information for thousands of users. Now, the app has been struck with a second cybersecurity incident and it is arguably bigger than the first. 404 Media reports that a second database has leaked and it contains about 1.1 million chat messages discussing some sensitive topics that people likely wouldn't want to make public. These include topics like cheating partners, abortions, and unfaithful boyfriends. The messages span from 2023 to last week, but the impact and scope of the leak is unclear. The person who did discover the database noted that practically any user could access the repository using their own API key. In a statement to Bleeping Computer, Tea has confirmed the second breach too, noting that "some" direct messages (DMs) have been exposed. The company has decommissioned the affected system for now, but claims that other infrastructure remains unaffected. It has emphasized that it will invest efforts in the coming days to improve its cybersecurity posture, but did not share any further details at this time. The service will also be reaching out to its affected customers and offer them free identity protection services as a sort of an apology. These cybersecurity incidents further highlight the need to be vigilant when sharing identifiable information online, especially with apps which are very new to the market and have not yet matured. Security researchers and analysts have cautioned the public that it is very possible to locate social media profiles of Tea users due to all the data that has been leaked.
    • 26200.5722 is the first available 25H2 build from the ge_release_svc_betaflt branch (25H2's previous branch was the "ge_prerelease_im" branch). The 26200.5722 release also removes the "Insider Preview" references in the system area. These significant changes usually indicates that the public release of 25H2 will be ready within 6 weeks to 2 months.
  • Recent Achievements

    • Dedicated
      ataho31016 earned a badge
      Dedicated
    • First Post
      Gladiattore earned a badge
      First Post
    • Reacting Well
      Gladiattore earned a badge
      Reacting Well
    • Week One Done
      NeoWeen earned a badge
      Week One Done
    • One Month Later
      BA the Curmudgeon earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      652
    2. 2
      ATLien_0
      261
    3. 3
      Xenon
      165
    4. 4
      neufuse
      142
    5. 5
      +FloatingFatMan
      107
  • Tell a friend

    Love Neowin? Tell a friend!