#define UNICODE 1 #include #include #include static const wchar_t * skipLocalUNCPart (const wchar_t * path) { size_t offset = 0; if ((wcslen (path) < MAX_PATH + 4) && (!wcsncmp (path, L"\\\\?\\", 4)) && (path[5] == L':')) return path + 4; else return path; } int main(int argc, char *argv[]) { STARTUPINFO si; PROCESS_INFORMATION pi; char resolved_command[PATH_MAX]; if (argc != 2) { printf("Usage: cygexec \n"); return 1; } wchar_t *win_command = cygwin_create_path(CCP_POSIX_TO_WIN_W, argv[1]); if (!win_command) return 2; ZeroMemory(&si, sizeof(si)); ZeroMemory(&pi, sizeof(pi)); si.cb = sizeof(si); si.wShowWindow = SW_SHOW; cygwin_internal (CW_SYNC_WINENV); if (CreateProcess(NULL, (wchar_t*)skipLocalUNCPart(win_command), NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)) { CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } else { printf("Failed to execute %s.\n", argv[1]); return 3; } free(win_command); return 0; }