• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4119
  • Last Modified:

run a cab file programatically in compact framework

I have an application called autorun.exe that i am placing on an sd card , from within this application i am trying to run a cab file to install an application on windows mobile 5. i just get an error message saying the application was not installed correctly so it looks like its trying to run the cab file to some extent

any suggestions ?
string filepath = "Cabfiles\\test.cab";
System.Diagnostics.ProcessStartInfo startinfo;
 
startinfo = new System.Diagnostics.ProcessStartInfo(filepath, "");
startinfo.UseShellExecute = true;
 
System.Diagnostics.Process.Start(startinfo);

Open in new window

0
MCLR
Asked:
MCLR
  • 4
  • 4
1 Solution
 
alexey_gusevCommented:
you should launch WceLoad.exe with the CAB name as a parameter
0
 
MCLRAuthor Commented:
I tried the following but with the same result

System.Diagnostics.Process.Start("wceload.exe","CabFiles\\test.cab");
0
 
alexey_gusevCommented:
hmm, and what happens if you install it manually? besides, I would try "\\Cabfiles" instead of just "Cabfiles" (or whatever full path it is)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
MCLRAuthor Commented:
Yes i had tried both , if i run the cab file manually it installs correctly with no issue
0
 
alexey_gusevCommented:
ah, I remember that sometimes there is a problem with WceLoad and CAB files being not in the root folder. try launch the CAB from root folder of the PDA, eiither with UseShellExecute = true for CAB or without it for WceLoad

I have somewhere working code in C++ which is easily convertible to C#
0
 
MCLRAuthor Commented:
ya if you could post some code that would be great
0
 
alexey_gusevCommented:
here you go. I had to copy cab file from some SD card location to the root and only then launch WceLoad.exe.
otherwise it didn't work.
int LaunchWceLoad(LPCTSTR lpszRoot, LPCTSTR lpszCabName, int nDoCopy, BOOL bWait)
{
	DWORD dwExitCode = 0;
	PROCESS_INFORMATION pi;
	WCHAR szCmdLine[255] = {0};
	WCHAR szSrcCAB[255] = {0};
	WCHAR szDstCAB[255] = {0};
	WCHAR szInfo[255] = {0};
 
	_stprintf(szSrcCAB,_T("\\%s\\Setup\\%s"), lpszRoot, lpszCabName);
	_stprintf(szDstCAB,_T("\\%s"),lpszCabName);
	if ( nDoCopy )
	{
		if ( !CopyFile(szSrcCAB,szDstCAB,FALSE) )
		{
			DWORD dwError = GetLastError();
			_stprintf(szInfo,_T("Failed to copy CAB file to root: 0x%X"),dwError);
			Log(szInfo);
			return 1;
		}
	}
	else
	{
		_stprintf(szInfo,_T("No copy operation was requested"));
		Log(szInfo);
	}
	_stprintf(szCmdLine,_T("%s"), szDstCAB);
	memset(&pi,0,sizeof(pi));
	if ( CreateProcess(_T("wceload.exe"),szCmdLine,NULL,NULL,FALSE,0,NULL,NULL,NULL,&pi) )
	{
		if ( bWait )
		{
			DWORD dwRes = WaitForSingleObject(pi.hProcess,INFINITE);
			if (dwRes != WAIT_OBJECT_0)
			{
				_stprintf(szInfo,_T("Waiting for process completion returned error: 0x%X"),dwRes);
				Log(szInfo);
				return 1;
			}
			else
			{
				if ( !GetExitCodeProcess(pi.hProcess,&dwExitCode) )
				{
					dwExitCode = 1;
				}
				else
				{
					_stprintf(szInfo,_T("Return code: %lu"),dwExitCode);
				}
			}
		}
	}
	else
	{
		_stprintf(szInfo, _T("Create Process error: 0x%X"), GetLastError());
		Log(szInfo);
		return 1;
	}
	return dwExitCode;
}

Open in new window

0
 
MCLRAuthor Commented:
Thank that did the job ,much appriciated
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now