ntdll: Expand previous patch to use pthread_mutex
[wine/multimedia.git] / programs / cscript / main.c
blobf326260daaeca1c6c78a41265a60fe0afcfdf8d7
1 /*
2 * CSCRIPT Implementation
4 * Copyright 2011 André Hentschel
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_LEAN_AND_MEAN
22 #include <stdio.h>
23 #include <windows.h>
24 #include <winbase.h>
26 #include <wine/debug.h>
27 #include <wine/unicode.h>
29 WINE_DEFAULT_DEBUG_CHANNEL(cscript);
31 int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cmdshow)
33 static const WCHAR wscriptW[] = {'\\','w','s','c','r','i','p','t','.','e','x','e',0};
34 static const WCHAR parbW[] = {' ','/','B',' ',0};
35 WCHAR app[MAX_PATH];
36 WCHAR cmd[MAX_PATH];
37 PROCESS_INFORMATION pi;
38 BOOL ret;
39 DWORD exitcode;
40 STARTUPINFOW si = { sizeof(si) };
42 WINE_FIXME("(%p %p %s %x) forwarding to wscript\n", hInst, hPrevInst, wine_dbgstr_w(cmdline), cmdshow);
44 GetSystemDirectoryW(app, MAX_PATH);
45 strcatW(app, wscriptW);
46 strcpyW(cmd, app);
47 strcatW(app, parbW);
48 strcatW(app, cmdline);
50 if (!CreateProcessW(app, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) return 1;
51 WaitForSingleObject( pi.hProcess, INFINITE );
53 ret = GetExitCodeProcess(pi.hProcess, &exitcode);
54 CloseHandle( pi.hProcess );
55 CloseHandle( pi.hThread );
57 if (ret)
58 return exitcode;
59 else
60 return 1;