How to extract cabinet files programmatically?

  • Thread starter Thread starter krupa.p
  • Start date Start date
K

krupa.p

Hi All,

I need to install a cab file that is already downloaded to my Windows
Ce device. How can I do it from my program?

I want to run my application when the device boots up. Any thoughts on
this? My application is in C#, compact frmework 2.0. Is there anything
similar to CreateProcess() in C#?

Thanks,
Krupa
 
Thanks Chris! That helped.

I have a new issue now. I am trying to install a cab file that will
install my application. During the process it pops up a window asking
the user if he wants to reisntall the application as it already exists.
Is there a way where I can bypass this process. I want to restart my
application without any human interference.

Could someone please help?
 
I am not running wceload.exe. Let me add a snippet of my code.

///////////////////////////////////
Process extractCAB = new Process();
extractCAB.StartInfo.FileName = execute_path + @"\" + file.Name;
extractCAB.StartInfo.Verb = "Open";
extractCAB.Start();
///////////////////////////////////

I am not familiar with the usage of wceload.exe. Is there any web
resource I can refer to know about it?

Thanks,
Krupa
 
You'll need to specify command line arguments. You are, actually, running
it, as it's the application associated with CAB files. Use the link from my
last message...

Paul T.
 
You need to change a registry entry such that it does not think your
application is already installed, and then it will happily install over
it without asking.

think its HKLM\SOFTWARE\Apps\[Your Application Name] , and you set
"Instl" from 1 to 0.
 
I tried doing the following:

ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "wceload";

psi.Arguments = string.Format("/noaskdest /noui
/delete 1 " + execute_path + @"\" + file.Name);
Process p = Process.Start(psi);

This is supposed to install the cab file and my application which is
there in the cab file should be installed in Program Files directory. I
plan to execute my application later from the Program files directory.
But after executing the above code, I don't find my application in
Program Files. That means the application is not installed. I think it
still is asking me if I want to re-install my application, but it's not
being shown to me as I have given /noui argument to this process.

As Scott Ayton said, I might need to change registry entry. Scott,
could you tell me how to do it programmatically?
 
I got the following code working:

RegistryKey MyReg =
Registry.LocalMachine.OpenSubKey("SOFTWARE\\Apps\\Barz TCE_Setup",
true);
int i = (int)MyReg.GetValue("Instl");
if(i == 1)
{
MyReg.SetValue("Instl", 0);
}

But even after this the cab is not getting installed.

Any thoughts?
 
You need to do some P/Invokes, these definitions should get you started:

[DllImport("coredll.dll")]
public static extern int RegOpenKeyEx(
uint key, string subKey, int options,
int samDesired, ref uint phkResult);

[DllImport("coredll.dll")]
public static extern int RegCloseKey(uint key);

[DllImport("coredll.dll")]
public static extern int RegQueryValueEx(
uint key, string valueName, int reserved,
out int type, byte[] data, ref int ldata);

Simon.
 
This should work fine if you are not installing onto a WM5 device

If it is a WM5 device and your application is not signed or something
passing the extra arguments to install with wceload silently will just
stop it from installing anything.

will it install if you do not specify /noaskdest and /noui ?

After you do the registry edit, try using extractcab like you
originally were and see if it prompts you for reinstalling.
 
Hi Scott,

I am working on a WinCE 5.0 device. When I do not specify /noaskdest
and /noui, I get a message saying: "No .CAB file to install. Please
specify a .cab file to install the application."

When I perform the following code, it does not prompt for reinstalling,
but the cab file is installed. But it prompts to select a destination
directory for installation. Is there a way I can get rid of this
prompt?
Process extractTCE = new Process();
extractTCE.StartInfo.FileName = execute_path + @"\" + file.Name;
extractTCE.StartInfo.Verb = "Open";
extractTCE.Start();

I think something is going wrong when I use wceload. Any ideas?

Thanks,
Krupa
 
Chris, I tried the following:

ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "wceload";
psi.Arguments = string.Format("\\Storage Card\\Execute\\TCE_Setup.cab
/noaskdest");
Process p = Process.Start(psi);

But, I still get ""No .CAB file to install. Please specify a .cab file
to install the application."

Could you please elaborate on what you said?

-Krupa
 
Yes, because there's a space in the path and you have no quotes, just like I
said. It's trying to run a CAB file that it thinks is called \Storage which
is obviuosly wrong. Put in quotes - something like this:

psi.Arguments = "\"\\Storage Card\\Execute\\TCE_Setup.cab\" /noaskdest";

-Chris
 
Back
Top