This commit is contained in:
german 2026-02-01 20:51:18 +04:00
parent 5ca6bd7979
commit 3332a0f135
5 changed files with 33 additions and 3 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"makefile.configureOnOpen": false
}

View File

@ -21,4 +21,16 @@ wincmd
# Передача команды через параметр
wincmd --command КОМАНДА
wincmd -c КОМАНДА
# Запуск скрипта
wincmd ИМЯ_СКРИПТА.bat
wincmd -c "call ИМЯ_СКРИПТА.bat"
```
## Скрипты
Можно использовать для запуска файлов [**WIN_BATCH**](https://w.wiki/HgPq "Batch скрипты").
Пример:
```bash
touch hello.bat
echo -e "@echo off\necho Hello, world!" > hello.bat
wincmd hello.bat
```

2
hello.bat Normal file
View File

@ -0,0 +1,2 @@
@echo off
echo Hello, world!

BIN
wincmd

Binary file not shown.

View File

@ -45,6 +45,7 @@ static void __help(void) {
"Console wincmd on Wine API V" VERSION "\n"
" " "Run Windows command on the Linux" "\n"
"Using:" "\n"
" " "wincmd SCRIPT_NAME" "\n"
" " "wincmd [--help/--version]" "\n"
" " "wincmd --command WINDOWS_COMMAND"
);
@ -55,6 +56,7 @@ int _lib_wincmd_main(int argc, char** argv) {
char command_buffer[BUFFER_SIZE] = "wine cmd.exe /C ";
long add_count = BUFFER_SIZE - strlen(command_buffer) - 1;
bool get_command = false;
char* file_name = NULL;
while (pos != (size_t)argc) {
char* str = argv[pos];
if (get_command == true) {
@ -75,7 +77,7 @@ int _lib_wincmd_main(int argc, char** argv) {
switch (str[1 + loc]) {
default:
if (get_command == true) break;
wincmd_error("Cannot find option!");
printf("\033[1mwincmd: \033[91mCannot find option \"%s\"!\033[0m\n", str);
return EXIT_FAILURE;
break;
case 'c':
@ -89,8 +91,8 @@ int _lib_wincmd_main(int argc, char** argv) {
return EXIT_SUCCESS;
}
} else {
wincmd_error("Cannot find option!");
return EXIT_FAILURE;
file_name = str;
break;
}
pos ++;
}
@ -99,6 +101,17 @@ int _lib_wincmd_main(int argc, char** argv) {
wincmd_error("Unable to find critical dependencies for running the CMD.EXE shell!");
return EXIT_FAILURE;
}
if (file_name != NULL) {
strcpy(command_buffer, "wine cmd.exe /C call ");
strncat(command_buffer, file_name, BUFFER_SIZE - 10);
command_buffer[BUFFER_SIZE - 1] = '\0';
stat = system(command_buffer);
if (stat != EXIT_SUCCESS) {
printf("\033[1mwincmd: \033[91mThe program terminates with status %d!\033[0m\n", stat);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
if (get_command == true) {
stat = system(command_buffer);
if (stat != EXIT_SUCCESS) {