Windows 10: How do i run a program with spaces in it's name eg: my program.exe from a batch file?

Discus and support How do i run a program with spaces in it's name eg: my program.exe from a batch file? in Windows 10 Gaming to solve the problem; When I run the following batch filecd "C:\Program Files x86\FSTramp" start FSTramp for MSFS11.exeWIN11 returns "...cannot find 'FSTramp'If I change the... Discussion in 'Windows 10 Gaming' started by Phantom Pherret, Sep 21, 2023.

  1. How do i run a program with spaces in it's name eg: my program.exe from a batch file?


    When I run the following batch filecd "C:\Program Files x86\FSTramp" start FSTramp for MSFS11.exeWIN11 returns "...cannot find 'FSTramp'If I change the file tocd "C:\Program Files x86\FSTramp" start "FSTramp for MSFS11.exe"the Command window shows that the directory has changed, otherwise nothing happens.It appears that because the program name contains space characters, the start command does not work.Any suggestions?

    :)
     
    Phantom Pherret, Sep 21, 2023
    #1

  2. Batch file program pathway error

    I am making a batch program. It gives me a file error when I ask it to open Internet Explorer. Here is the BATCH script:

    start C:\Program Files\Internet Explorer

    and here's the error:

    Could not find "C:\Program"

    so does anyone know how to space file paths so they come out whole?

    I need it like C:\Program Files\Internet Explorer instead of C:\Program

    is there a way to put a space in it?
     
    MichaelHRothkopf, Sep 21, 2023
    #2
  3. Program File (.exe) in windows 10

    Hello,

    We need more information so we can identify why you're unable to open .exe program files. Kindly answer the following questions:

    • What happens when you try to open or run the file?
    • Are you getting any error messages?
    • Which specific program are you trying to run or install?
     
    Raymond Ave, Sep 21, 2023
    #3
  4. How do i run a program with spaces in it's name eg: my program.exe from a batch file?

    Batch file programming

    When using start /w it'll only wait for the program in the first argument to quit. Consequently if your "Loader.exe" quits the second it starts "sumprogram.exe" then the start /w will finish even if "sumprogram.exe" is still running.

    So in answer to your question:
    No. I do not believe it would.

    If you wanted to use *nearly* pure batch you could poll "sumprogram.exe" until it ends:
    Code: Loader.exe sumprogram.exe :again sleep 500 tasklist /FI "IMAGENAME eq sumprogram.exe" | find "sumprogram.exe" IF %ERRORLEVEL%==0 GOTO again <delete crap here>[/quote] You'd need to obtain a sleep.exe file (mine uses millisecond but the linked one uses seconds and I've never tested it *Oh Well How do i run a program with spaces in it's name eg: my program.exe from a batch file? :eek:hwellHow do i run a program with spaces in it's name eg: my program.exe from a batch file? :). There is a ping method that is similar to sleep.exe, but it's a pile of crap if you ask me.

    It would also be fairly simple to write a program in C that you could use in a batch file.
    PHP: #include <windows.h> #include <psapi.h> #include <stdio.h> int PrintProcessNameAndID( DWORD processID, const char *name ) { TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>"); // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if (NULL != hProcess ) { HMODULE hMod; DWORD cbNeeded; if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) ) { GetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName)/sizeof(TCHAR) ); } } if(strcmp(szProcessName, name) == 0) // right process { CloseHandle(hProcess); return 1; } // Release the handle to the process. CloseHandle( hProcess ); return 0; } int find(const char *name) { // Get the list of process identifiers. DWORD aProcesses[1024], cbNeeded, cProcesses; unsigned int i; if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) { return -1; } // Calculate how many process identifiers were returned. cProcesses = cbNeeded / sizeof(DWORD); // Print the name and process identifier for each process. for ( i = 0; i < cProcesses; i++ ) { if( aProcesses != 0 ) { if(PrintProcessNameAndID( aProcesses, name )) { //found it return aProcesses; } } } return -1; } int main(int argc, char **argv) { if(argc < 2){ /* Check if we have two parameters on the command line, including the program name */ printf("Usage: Process name required \n"); exit(1); } int pid = find(argv[1]); if (pid!=-1) { HANDLE hProcess = OpenProcess(STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE, FALSE, (DWORD)pid); if (NULL != hProcess ) { DWORD dwWaitResult = WaitForSingleObject (hProcess, INFINITE); CloseHandle( hProcess ); return 0; } } return 1; }[/quote] (some code shamelessly stolen from here) *Big Grin How do i run a program with spaces in it's name eg: my program.exe from a batch file? :D

    Assuming the aforementioned code was compiled as "waitfor.exe" (and everything was 32-bit), you could include it in your batch like so:
    Code: Loader.exe sumprogram.exe waitfor.exe sumprogram.exe <delete crap here>[/quote] I'm probably over engineering this, but that's what I'm supposed to do right? *Big Grin How do i run a program with spaces in it's name eg: my program.exe from a batch file? :D

    Also, do you have to use "Loader.exe"? If you can just do "start /w sumprogram.exe" this would be a lot easier! *Smile How do i run a program with spaces in it's name eg: my program.exe from a batch file? :)
     
    streetfighter 2, Sep 21, 2023
    #4
Thema:

How do i run a program with spaces in it's name eg: my program.exe from a batch file?

Loading...
  1. How do i run a program with spaces in it's name eg: my program.exe from a batch file? - Similar Threads - run program spaces

  2. How do i run a program with spaces in it's name eg: my program.exe from a batch file?

    in Windows 10 Software and Apps
    How do i run a program with spaces in it's name eg: my program.exe from a batch file?: When I run the following batch filecd "C:\Program Files x86\FSTramp" start FSTramp for MSFS11.exeWIN11 returns "...cannot find 'FSTramp'If I change the file tocd "C:\Program Files x86\FSTramp" start "FSTramp for MSFS11.exe"the Command window shows that the directory has...
  3. How do I stop a Program from running as administrator?

    in Windows 10 Gaming
    How do I stop a Program from running as administrator?: How do I stop a Program from running as administrator? And before you say uncheck it, it's greyed out https://answers.microsoft.com/en-us/windows/forum/all/how-do-i-stop-a-program-from-running-as/ca4a09a4-22e6-463d-b5da-1590ee75a5d7
  4. Restart a specific program with a batch file

    in Windows 10 Ask Insider
    Restart a specific program with a batch file: I have to restart Windows Audio Device graph multiple times a day to the point that I just want to map a button on my stream deck to end the task. Is there a way to create a shortcut to end the task? I've tried taskkill /f /im audiodg.exe but that was unsuccessful. Any ideas?...
  5. How do I prevent programs from running at startup?

    in Windows 10 Ask Insider
    How do I prevent programs from running at startup?: It seems some programs just want to start up no matter what. I have disabled them in Task Manager startup manager, deleted them from the startup folder ("shell:startup"), and deleted all of their task scheduler tasks, and they still start up. There are many programs like...
  6. Program's exe file missing

    in Windows 10 Software and Apps
    Program's exe file missing: Hello, So I ran into this issue where a program I downloaded Photofiltre 7 is now missing it's executable. It does even if I uninstall and reinstall the program. The installation shows the exe file being created, but than, the shortcut for the exe is blank, and the exe file...
  7. Start a program from a batch file

    in Windows 10 Software and Apps
    Start a program from a batch file: I'm trying to create a batch file that should - call another batch file - start a program and then wait for the program to close - call another batch file My goal with this is to work around an issue in Windows 10 where the screensaver won't work when I have my game...
  8. How to create a batch file to run a program at high priority?

    in Windows 10 Software and Apps
    How to create a batch file to run a program at high priority?: I have tried many ways for changing and saving the priorities to high, for games I play,and they succeeded,but only for one game the priority saves only as ''Above normal'' ! How do I fix this? Please help me!Thanks!
  9. Start a program from a batch file

    in Windows 10 Software and Apps
    Start a program from a batch file: 4 Apps of mine run a batch file that -tries- to call/start and EXE program. These Batch files need to work with OS XP thru Win 10. Win 10 has a pop-up window asking user if its okay to run/execute my EXE. No other Win version does this and thus I suspect a timing problem....
  10. How do I prevent multiple .exes (eg notepad) from running?

    in Windows 10 Support
    How do I prevent multiple .exes (eg notepad) from running?: I sometimes accidentally run two copies of notepad. Sometimes, I don't spot them both in my taskbar. I wondered if there was a way to alert me that I'm attempting to run the same .exe, if I already have it open? For example, on my desktop I have a notepad file. I'll run...