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

LVL 1
MCLRAsked:
Who is Participating?
 
alexey_gusevConnect With a Mentor Commented:
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
 
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
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
 
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
 
MCLRAuthor Commented:
Thank that did the job ,much appriciated
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.