//***************************************************************************
//FUNCTION NAME : CheckValidServerURLPath
//Purpose : Check the syntax of Transcend server url.
//***************************************************************************
function BOOL CheckValidServerURLPath(serverPath)
NUMBER nLength,nResult,nLocation;
STRING svString,szFindMe,szMsg;
BOOL bValid;
begin
nLength = StrLength (serverPath);
if (nLength = 0) then
MessageBoxEx("Please enter Transcend Server URL.","",INFORMATION);
return FALSE;
else
nLength=256;
bValid=FALSE;
// Check for presence of http://, https://, file:// in the URL
//********************START***************************
nResult = Is (VALID_PATH, serverPath);
if (nResult = TRUE) then
bValid=TRUE;
else
szMsg="The server URL you entered is invalid. Please try again";
MessageBoxEx(szMsg,"",WARNING);
return FALSE;
endif;
//********************END***************************
// Search for "/" at the end of the server URL and removing it, if exist.
//********************START***************************
if(StrRemoveLastSlash (serverPath) =0) then // removing trailing "\" at end
// Ckeck for trailing "/" at end
// START
nResult=StrFindEx ( serverPath, "/", nLength-1);
if(nResult>=0) then
StrSub(serverPath,serverPath,0,nLength-1);
if(MsiSetProperty(ISMSI_HANDLE,"CUSTOMURL",serverPath)==ERROR_SUCCESS) then
endif;
endif;
// END
endif;
//********************END***************************
return TRUE;
endif;
end;
This blog will provide you with Installshield code and help which are the result of a long term experience.
Friday, June 18, 2010
Check Multiple instance of setup to run at one time
Hello Friends, today I want to share a script which will help you in preventing multiple instances of an installer simultaneously. For this you need to declare below two prototypes in your setup.rul file. 

prototype Kernel32.CreateMutex(byval NUMBER, BOOL, STRING);
prototype Kernel32.ReleaseMutex(HWND);
Below I had used a function named 'CheckMultipleInstance' which will help in preventing multiple instances of an installshield installer to run at a time.
//***************************************************************************
//FUNCTION NAME : CheckMultipleInstance
//Purpose : To prevent multiple instances of setup to run at one time.
//***************************************************************************
function CheckMultipleInstance(hMSI)
STRING strMutex;
HWND hMutex;
NUMBER nError;
begin
strMutex = "MY_SETUPMUTEX" ;
hMutex = Kernel32.CreateMutex(NULL, TRUE, strMutex);
nError = Err.LastDllError();
if (hMutex != 0 && nError == 183) then
MessageBoxEx("Another instance of this setup is already
running","",SEVERE);
ReleaseMutex(hMutex);
if(MsiSetProperty(ISMSI_HANDLE,"ANOTHERINSTANCE","1") ==
ERROR_SUCCESS) then
SprintfMsiLog("CUSTOM LOG: %s","Version is not Valid.");
endif;
abort;
else
if(MsiSetProperty(ISMSI_HANDLE,"ANOTHERINSTANCE","0") ==
ERROR_SUCCESS) then
SprintfMsiLog("CUSTOM LOG: %s","Version is not Valid.");
endif;
endif;
end;
prototype Kernel32.CreateMutex(byval NUMBER, BOOL, STRING);
prototype Kernel32.ReleaseMutex(HWND);
Below I had used a function named 'CheckMultipleInstance' which will help in preventing multiple instances of an installshield installer to run at a time.
//***************************************************************************
//FUNCTION NAME : CheckMultipleInstance
//Purpose : To prevent multiple instances of setup to run at one time.
//***************************************************************************
function CheckMultipleInstance(hMSI)
STRING strMutex;
HWND hMutex;
NUMBER nError;
begin
strMutex = "MY_SETUPMUTEX" ;
hMutex = Kernel32.CreateMutex(NULL, TRUE, strMutex);
nError = Err.LastDllError();
if (hMutex != 0 && nError == 183) then
MessageBoxEx("Another instance of this setup is already
running","",SEVERE);
ReleaseMutex(hMutex);
if(MsiSetProperty(ISMSI_HANDLE,"ANOTHERINSTANCE","1") ==
ERROR_SUCCESS) then
SprintfMsiLog("CUSTOM LOG: %s","Version is not Valid.");
endif;
abort;
else
if(MsiSetProperty(ISMSI_HANDLE,"ANOTHERINSTANCE","0") ==
ERROR_SUCCESS) then
SprintfMsiLog("CUSTOM LOG: %s","Version is not Valid.");
endif;
endif;
end;
Check Free space on disk
function CheckFreeSpace(hMSI)
_DISK_INFO di;
NUMBER n; // to do: something with function return values
NUMBER nvSizeTargetHigh, nvSizeTargetLow, nUnitsTarget;
begin
// init. _DISK_INFO members: what drive, what info
di.szDiskPath = INSTALLDIR;
di.nInfoToQuery = DISK_INFO_QUERY_DISK_FREE_SPACE;
n = GetDiskInfo(&di);
// change to desired unit for free space
nUnitsTarget = MBYTES;
n = ConvertSizeToUnits(di.nFreeSpaceHigh, di.nFreeSpaceLow, BYTES,nvSizeTargetHigh, nvSizeTargetLow, nUnitsTarget);
//SprintfBox(INFORMATION, "Free Space", "Free space: %d MB", nvSizeTargetLow);
if(nvSizeTargetLow<500) then
MsiSetProperty(hMSI,"VALIDFREESPACE","0");
MessageBoxEx("Atleast 500 MB space is required on the destination drive to install Beyond TXT G4 Client. Please free the required space and try again..","",INFORMATION);
else
MsiSetProperty(hMSI,"VALIDFREESPACE","1");
endif;
end;
_DISK_INFO di;
NUMBER n; // to do: something with function return values
NUMBER nvSizeTargetHigh, nvSizeTargetLow, nUnitsTarget;
begin
// init. _DISK_INFO members: what drive, what info
di.szDiskPath = INSTALLDIR;
di.nInfoToQuery = DISK_INFO_QUERY_DISK_FREE_SPACE;
n = GetDiskInfo(&di);
// change to desired unit for free space
nUnitsTarget = MBYTES;
n = ConvertSizeToUnits(di.nFreeSpaceHigh, di.nFreeSpaceLow, BYTES,nvSizeTargetHigh, nvSizeTargetLow, nUnitsTarget);
//SprintfBox(INFORMATION, "Free Space", "Free space: %d MB", nvSizeTargetLow);
if(nvSizeTargetLow<500) then
MsiSetProperty(hMSI,"VALIDFREESPACE","0");
MessageBoxEx("Atleast 500 MB space is required on the destination drive to install Beyond TXT G4 Client. Please free the required space and try again..","",INFORMATION);
else
MsiSetProperty(hMSI,"VALIDFREESPACE","1");
endif;
end;
Subscribe to:
Posts (Atom)