Russian Qt Forum
Сентябрь 24, 2024, 11:31 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: [Qt 4.6] QProcess не запускает системные утилиты  (Прочитано 8117 раз)
Racheengel
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 2679


Я работал с дискетам 5.25 :(


Просмотр профиля
« : Декабрь 14, 2009, 17:49 »

Заметил такую проблему - в винде QProcess не запускает системные утилиты типа copy, del и т.д.
Вообще ничего не выводит, ни ошибок, тихо ничего не делает.
Бага?
Записан

What is the 11 in the C++11? It’s the number of feet they glued to C++ trying to obtain a better octopus.

COVID не волк, в лес не уйдёт
SimpleSunny
Гость
« Ответ #1 : Декабрь 14, 2009, 17:58 »

Насколько понимаю в винде "del, copy" не являются программами, чтобы их запускать, в отличие от *nix.
Можно извратится и написать свои *.bat (copy.bat, del.bat) и их уже запускать =)

P. S. Или я что-то путаю.
« Последнее редактирование: Декабрь 14, 2009, 17:59 от SimpleSunny » Записан
Пантер
Administrator
Джедай : наставник для всех
*****
Offline Offline

Сообщений: 5876


Жаждущий знаний


Просмотр профиля WWW
« Ответ #2 : Декабрь 14, 2009, 18:09 »

Под виндой запускаешь cmd.exe и команды передаешь в параметрах.
Записан

1. Qt - Qt Development Frameworks; QT - QuickTime
2. Не используйте в исходниках символы кириллицы!!!
3. Пользуйтесь тегом code при оформлении сообщений.
Racheengel
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 2679


Я работал с дискетам 5.25 :(


Просмотр профиля
« Ответ #3 : Декабрь 14, 2009, 18:10 »

через бантики работает, а вот вариант с cmd - нет. Вешает процесс.
Записан

What is the 11 in the C++11? It’s the number of feet they glued to C++ trying to obtain a better octopus.

COVID не волк, в лес не уйдёт
Alex Custov
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 2063


Просмотр профиля
« Ответ #4 : Декабрь 14, 2009, 18:20 »

в винде QProcess не запускает системные утилиты типа copy, del и т.д.

это не утилиты, это встроенные в cmd команды. Надо пробовать через cmd запускать. Например

Код
Bash
C:\Program Files\Far>cmd /C copy macros.txt macros.txt2
Скопировано файлов:         1.
 
C:\Program Files\Far>
 
Записан
Racheengel
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 2679


Я работал с дискетам 5.25 :(


Просмотр профиля
« Ответ #5 : Декабрь 14, 2009, 18:28 »

что есть странно, ибо в хелпе к QProcess написано, что можно вызывать как есть... И если я не ошибаюсь, до 4.6 это работало.
Записан

What is the 11 in the C++11? It’s the number of feet they glued to C++ trying to obtain a better octopus.

COVID не волк, в лес не уйдёт
MoPDoBoPoT
Гость
« Ответ #6 : Декабрь 14, 2009, 21:08 »

что есть странно, ибо в хелпе к QProcess написано, что можно вызывать как есть... И если я не ошибаюсь, до 4.6 это работало.
Ничего подобного
Цитата: QtAssistant
Notes for Windows Users
Some Windows commands (for example, dir) are not provided by separate applications, but by the command interpreter itself. If you attempt to use QProcess to execute these commands directly, it won't work. One possible solution is to execute the command interpreter itself (cmd.exe on some Windows systems), and ask the interpreter to execute the desired command.
Записан
virtual_root
Гость
« Ответ #7 : Май 26, 2011, 19:53 »

Здравствуйте! Кто-нибудь может мне подсказать почему QProcess не запускает cmd.exe.
Пишу следующий код:
       QProcess *myProcess = new QProcess();
        myProcess->start("C:\\Temp\\os\\cmd.exe");
В этой папке я разместила несколько exe файлов: calc.exe,notepad.exe,mspaint и cmd.exe;
Любой другой файл запускается а cmd.exe нет. Почему? Может нужны какие-то дополнительные параметры для этого файла?

Записан
thechicho
Гость
« Ответ #8 : Октябрь 26, 2011, 20:51 »

Код
C++ (Qt)
QString program = "cmd";
QStringList arguments;
arguments << "/C" << "help";
 
QProcess *cmd = new QProcess(this);
cmd->start(program, arguments);
cmd->waitForFinished();
qDebug() << cmd->readAll();
cmd->close();

только насчет cmd->close(); не уверен, надо ли?

Цитировать
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>cmd /?
Starts a new instance of the Windows XP command interpreter

CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
    [[/S] [/C | /K] string]

/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains
/S      Modifies the treatment of string after /C or /K (see below)
/Q      Turns echo off
/D      Disable execution of AutoRun commands from registry (see below)
/A      Causes the output of internal commands to a pipe or file to be ANSI
/U      Causes the output of internal commands to a pipe or file to be
        Unicode
/T:fg   Sets the foreground/background colors (see COLOR /? for more info)
/E:ON   Enable command extensions (see below)
/E:OFF  Disable command extensions (see below)
/F:ON   Enable file and directory name completion characters (see below)
/F:OFF  Disable file and directory name completion characters (see below)
/V:ON   Enable delayed environment variable expansion using ! as the
        delimiter. For example, /V:ON would allow !var! to expand the
        variable var at execution time.  The var syntax expands variables
        at input time, which is quite a different thing when inside of a FOR
        loop.
/V:OFF  Disable delayed environment expansion.

/C      Carries out the command specified by string and then terminates
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.132 секунд. Запросов: 23.