Hi I first i new here hope this correct place to post.

I currently making a 3dsmax load which converts a 3ds file to direct x file so it can be loaded. My problem is that i using a old .exe file called conv3ds.exe which when used in cmd would load the file and convert it easily. This only works in cmd and cant be used outside. The command to do this conversion would be

conv3ds.exe -A Maxmodel.3ds

i trying get a c++ program to load that command into cmd and then excute it. it works normal outside of c++ but inside the white spaces between .exe -A and the space between -A Max wont allow it to work. can someone help please.

i tryed doing this using createprocess and system (i dont care about it running on anything other than windows). also i tried loading this into a batch file but the batch file does nothing. also if you look for conv3ds (google it) you see what it does.

Someone please help it starting get on my nerves fact it dont work for me

Dani AI

Generated

Brief follow-up: 's final post reveals the real culprit — the child process was inheriting the caller's working directory, so the converter wrote output into the project folder. This is a very common Windows pitfall when launching command-line tools from an IDE or a GUI app. The three things that reliably prevent this kind of surprise are: pass absolute (and quoted) paths, explicitly set the child process working directory, and check the API return codes for diagnostics.

A compact, safe CreateProcess pattern (generic names) that sets the working directory and supplies a writable command-line buffer:

STARTUPINFOW si = { sizeof si };
PROCESS_INFORMATION pi;
wchar_t cmd[] = L"\"C:\\Tools\\converter.exe\" -A \"C:\\MyProject\\model.3ds\"";

if (!CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL,
                    L"C:\\MyProject", &si, &pi)) {
    DWORD err = GetLastError();
    // record/log err for troubleshooting
} else {
    WaitForSingleObject(pi.hProcess, INFINITE);
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}

Extra notes and troubleshooting tips: batch scripts are not native executables — either invoke them via cmd.exe /C "path\to\script.bat" or use ShellExecute/ShellExecuteEx. Always quote paths that may contain spaces, and make the command line buffer writable (CreateProcess can modify it). To capture output, redirect stdout/stderr with pipes; to suppress a console window, pass CREATE_NO_WINDOW. Checking GetLastError() on failure will usually point directly to the remaining issue. Thanks to for prompting the code samples — that line of questioning is what typically finds the working-directory root cause.

Recommended Answers

All 3 Replies

Post some code and someone might see what you did wrong.

here one my attempts

STARTUPINFO si;
    PROCESS_INFORMATION pi;
	ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

LPTSTR szCmdline = _tcsdup(TEXT("H:\\HndProg\\conv3ds.exe -A H:\\HndProg\\Maxmodel.3ds"));
	CreateProcess(NULL, szCmdline,  
		NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance to FALSE
        0,              // No creation flags
        NULL,           // Use parent's environment block
        NULL,           // Use parent's starting directory 
        &si,            // Pointer to STARTUPINFO structure
        &pi );           // Pointer to PROCESS_INFORMATION structure

the second is

STARTUPINFO si;
    PROCESS_INFORMATION pi;
	ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

LPTSTR szCmdline = _tcsdup(TEXT("H:\\HndProg\\Load.bat"));
	CreateProcess(NULL, szCmdline,  
		NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance to FALSE
        0,              // No creation flags
        NULL,           // Use parent's environment block
        NULL,           // Use parent's starting directory 
        &si,            // Pointer to STARTUPINFO structure
        &pi );           // Pointer to PROCESS_INFORMATION structure

the bat file for this is

ECHO OFF
REM check whether a file called 'H:\HndProg\Maxmodel.3ds' exists
IF EXIST H:\HndProg\Maxmodel.3ds GOTO :success
IF NOT EXIST H:\HndProg\Maxmodel.3ds GOTO :error

:success
call H:\HndProg\conv3ds.exe -A H:\\HndProg\\Maxmodel.3ds
GOTO :end

:error
ECHO Error - can't find the Maxmodel.3ds file
GOTO :end

:end
REM do nothing. This is just the end of the file 
pause

please someone help.

ha i just relised what i done wrong. sorry for wasting ya time

the output was being stored in project folder. I corrected it now in the bat file.
Thanks anyone who did try to help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.