Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8981079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:14:40+00:00 2026-06-15T20:14:40+00:00

I am trying to execute a dos command using CreateProcess function : LPWSTR cmd=(LPWSTR)QString(C:\\windows\\system32\\cmd.exe

  • 0

I am trying to execute a dos command using CreateProcess function :

 LPWSTR cmd=(LPWSTR)QString("C:\\windows\\system32\\cmd.exe  subst " + DLetter+"  \""+mountPath+"\"").utf16();



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

        if ( CreateProcessW(0,     // Application name
                           cmd,                 // Application arguments
                           NULL,
                           NULL,
                           TRUE,
                           0,
                           NULL,
                           L"C:\\windows\\system32",          // Working directory
                           &si,
                           &pi) == TRUE)
        { ...

it give as last error 3 = ERROR_PATH_NOT_FOUND, when I separate the application path "C:\\windows\\system32\\cmd.exe" from the command it shows the console without executing my subst command.

Any help will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:14:41+00:00Added an answer on June 15, 2026 at 8:14 pm

    You need to include either /C or /K in the options to cmd.exe.

    /C      Carries out the command specified by string and then terminates
    /K      Carries out the command specified by string but remains
    

    Without one these options, the subst command that you pass is simply ignored.

    Having said that, subst, at least on my Windows 7 box, is not implemented inside cmd.exe. It is a separate executable. So you can invoke it directly and bypass cmd.exe completely.

    Regarding your call to CreateProcess I have the following comments:

    1. Don’t include the path C:\\windows\\system32. Just invoke subst.exe and let the system locate the executable using the standard search path.
    2. Pass FALSE for bInheritHandles. You aren’t passing any handles to the new process and so you don’t need the new process to inherit your handles.
    3. Pass NULL as the working directory. There’s just no need to specify it here.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to execute shell command in background using pythons commands module >>>import commands >>>output
I'am trying to call a DOS command: subst with QProcess : QProcess process; int
Im trying to execute a scalar valued function in an insert query. Im using
When trying to execute the command cap deploy from a Windows machine, I'm getting
Trying to execute powershell script in my C# code. Using .NET Framework v. 4.0.30319
I`m trying to execute a shell command with arguments in C# , and The
I'm trying to execute command prompt commands and read the output in C#. This
I'm trying to execute MS-DOS DEL commands inside a Win32 C program, and I
<?php $output=shell_exec('gcc prog.c'); echo $output; ?> I'm trying execute a c program using php
Trying to execute a Powershell cmdlet from a MVC 3 Controller using impersonation but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.