# INFSetupCommand

```
#define RSC_FLAG_INF 1
#define RSC_FLAG_QUIET 4

BOOL CreateProcessFromINFSetupCommandW(_In_ LPCWSTR PathToInfFile, _In_ LPCWSTR NameOfSection)
{
	typedef HRESULT(WINAPI* RUNSETUPCOMMANDW)(HWND, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, PHANDLE, DWORD, LPVOID);
	RUNSETUPCOMMANDW RunSetupCommandW = NULL;
	HMODULE hMod = NULL;
	BOOL bFlag = FALSE;

	hMod = LoadLibraryW(L"advpack.dll");
	if (hMod == NULL)
		goto EXIT_ROUTINE;

	RunSetupCommandW = (RUNSETUPCOMMANDW)GetProcAddress(hMod, "RunSetupCommandW");
	if (!RunSetupCommandW)
		goto EXIT_ROUTINE;

	if (!SUCCEEDED(RunSetupCommandW(NULL, PathToInfFile, NameOfSection, L".", NULL, NULL, RSC_FLAG_INF | RSC_FLAG_QUIET, NULL)))
		goto EXIT_ROUTINE;

	bFlag = TRUE;

EXIT_ROUTINE:

	if (hMod)
		FreeLibrary(hMod);

	return bFlag;
}

BOOL CreateProcessFromINFSetupCommandA(_In_ LPCSTR PathToInfFile, _In_ LPCSTR NameOfSection)
{
	typedef HRESULT(WINAPI* RUNSETUPCOMMANDA)(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, PHANDLE, DWORD, LPVOID);
	RUNSETUPCOMMANDA RunSetupCommandA = NULL;
	HMODULE hMod = NULL;
	BOOL bFlag = FALSE;

	hMod = LoadLibraryW(L"advpack.dll");
	if (hMod == NULL)
		goto EXIT_ROUTINE;

	RunSetupCommandA = (RUNSETUPCOMMANDA)GetProcAddress(hMod, "RunSetupCommandA");
	if (!RunSetupCommandA)
		goto EXIT_ROUTINE;

	if (!SUCCEEDED(RunSetupCommandA(NULL, PathToInfFile, NameOfSection, ".", NULL, NULL, RSC_FLAG_INF | RSC_FLAG_QUIET, NULL)))
		goto EXIT_ROUTINE;

	bFlag = TRUE;

EXIT_ROUTINE:

	if (hMod)
		FreeLibrary(hMod);

	return bFlag;
}
```

