i wrote such as this script in installshield.
NUMBER nvResult;
STRING svResult;
STRING szDllName;
LPSTR szBuf;
NUMBER size;
BOOL bCopy;
BOOL bDelete;
begin
//////////////////////////////////////////////
GetSystemInfo (OS,nvResult,svResult); //Get system Operation system type
//Disable the component that not for windowsNT or Win2000
if (nvResult = IS_WINDOWSNT) then
// XCopyFile (SUPPORTDIR^"xxx.inf",WINDIR^"inf",COMP_NORMAL|LOCKEDFILE);
szDllName = WINSYSDIR^"setupapi.dll";
UseDLL(szDllName);
bCopy =SetupCopyOEMInfA(SUPPORTDIR^"xxx.inf",NULL,0,8,NULL,0,0,NULL) ;
UnUseDLL(szDllName);
// if (!bCopy) then
// exit;
// endif;
endif;
if (nvResult = IS_WINDOWS9X) then
bCopy=XCopyFile (SUPPORTDIR^"xxx.sys",WINDIR^"system32\\drivers",COMP_NORMAL|LOCKEDFILE);
bCopy=XCopyFile (SUPPORTDIR^"xxx.inf",WINDIR^"inf",COMP_NORMAL|LOCKEDFILE);
szDllName = WINSYSDIR^"kernel32.dll";
UseDLL(szDllName);
DeleteFileA(WINDIR^"Inf\\Drvidx.bin");
bDelete =DeleteFileA(WINDIR^"Inf\\Drvdata.bin");
UnUseDLL(szDllName);
// if (!bDelete) then
// exit;
// endif;
endif;
//
// Verify the Arguments.
//
if (argc < 2)
{
_tprintf(TEXT("usage: remove <Hardware_ID>\n"));
return 1; // Remove Failure
}
//
// Create a Device Information Set with all present devices.
//
DeviceInfoSet = SetupDiGetClassDevs(NULL, // All Classes
0,
0,
DIGCF_ALLCLASSES | DIGCF_PRESENT ); // All devices present on system
if (DeviceInfoSet == INVALID_HANDLE_VALUE)
{
DisplayError(TEXT("GetClassDevs(All Present Devices)"));
return 1;
}
//
// Enumerate through all Devices.
//
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i=0;SetupDiEnumDeviceInfo(DeviceInfoSet,i,&DeviceInfoData);i++)
{
DWORD DataT;
LPTSTR p,buffer = NULL;
DWORD buffersize = 0;
//
// We won't know the size of the HardwareID buffer until we call
// this function. So call it with a null to begin with, and then
// use the required buffer size to Alloc the nessicary space.
// Keep calling we have success or an unknown failure.
//
while (!SetupDiGetDeviceRegistryProperty(
DeviceInfoSet,
&DeviceInfoData,
SPDRP_HARDWAREID,
&DataT,
(PBYTE)buffer,
buffersize,
&buffersize))
{
if (GetLastError() == ERROR_INVALID_DATA)
{
//
// May be a Legacy Device with no HardwareID. Continue.
//
break;
}
else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
//
// We need to change the buffer size.
//
if (buffer)
LocalFree(buffer);
buffer = LocalAlloc(LPTR,buffersize);
}
else
{
//
// Unknown Failure.
//
DisplayError(TEXT("GetDeviceRegistryProperty"));
goto cleanup_DeviceInfo;
}
}
if (GetLastError() == ERROR_INVALID_DATA)
continue;
//
// Compare each entry in the buffer multi-sz list with our HardwareID.
//
for (p=buffer;*p&&(p<&buffer[buffersize]);p+=lstrlen(p)+sizeof(TCHAR))
{
_tprintf(TEXT("Compare device ID: [%s]\n"),p);
if (!_tcscmp(argv[1],p))
{
_tprintf(TEXT("Found! [%s]\n"),p);
//
// Worker function to remove device.
//
if (!SetupDiCallClassInstaller(DIF_REMOVE,
DeviceInfoSet,
&DeviceInfoData))
{
DisplayError(TEXT("CallClassInstaller(REMOVE)"));
}
break;
}
}
if (buffer) LocalFree(buffer);
}
if ((GetLastError()!=NO_ERROR)&&(GetLastError()!=ERROR_NO_MORE_ITEMS))
{
DisplayError(TEXT("EnumDeviceInfo"));
}