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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MCLRAuthor Commented:
Thank that did the job ,much appriciated
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.