Making a CAB file which doesn’t prompt for installation location
来源:互联网 发布:lrc字幕制作软件 编辑:程序博客网 时间:2024/05/13 21:47
Whendeveloping bespoke line of business applications it is common for yoursolution to require some form of hard reset recovery.
A common technique for implementing this is to package theapplication as a CAB file and then use a device specific technique toensure that this file survives and automatically installs after a hardreset.
One problem you may come across in implementing this scenario is that a Smart Device CAB projectcreated by Visual Studio will by default prompt the user to selectwhere to install the application if one or more storage cards arepresent. This blog post covers one technique to remove this prompt whenyou want to reduce user interaction and need to hard-code theinstallation location of your application.
Finding an explanation
The first step towards finding a solution is to determine the reasonwhy we are seeing the current behaviour. We can find an answer withinthe User Selected Installation section of the CAB Wizard documentation available on MSDN. This document states the following:
The user is prompted for the preferred installation volume only if the following two conditions are met:
- The application developer has created an %installdir% variable in the [CEStrings] section of the .inf file.
- The device has more than one storage volume available (such as a secondary MultiMedia card storage).
We obviously can not control the number of storage volumes presenton a user’s device, but what is an *.inf file and how can we controlthe content of it’s [CEStrings] section?
Manually rebuilding a CAB file
The Smart Device CAB project type within Visual Studio is a simple GUI front end to a command line utility called CAB Wizard (cabwiz).When Visual Studio builds your project it takes the settings you havespecified and behind the scenes generates a specially formatted textfile (an *.inf file) which instructs the command line utility how tocreate your application’s CAB file.
Unfortunately for us the Visual Studio IDE always includes an%installdir% variable within the [CEStrings] section of the file itgenerates and there is no option that allows us to override thisbehaviour.
One possible work around to remove this variable is to allow VisualStudio to generate it’s *.inf file and then manually edit it and re-runthe cabwiz utility by hand.
First we need to determine where the *.inf file is stored and theproper command line required to execute cabwiz.exe. This informationcan easily be found by looking at the Output Window of Visual Studioafter you build your solution. Near the end of the log you should see asection that looks similar to the following:
------ Build started: Project: BespokeLOBApplicationCAB, Configuration: Debug ------
Building file 'C:/BespokeLOBApplicationCAB.cab'...
"C:/Program Files/Microsoft Visual Studio 9.0/smartdevices/sdk/sdktools/cabwiz.exe"
"C:/Project/BespokeLOBApplicationCAB.inf"
/dest "C:/Project/"
/err CabWiz.log
Windows CE CAB Wizard
If you open the inf file specified in the above command line youshould be able to find and then delete a line declaring the%installdir% variable (as highlighted in the screenshot below).
Once you have saved this change the last step is to open a MSDOScommand prompt window and execute the command line discovered above tore-generate your CAB file. This new CAB file won’t prompt for aninstallation directory due to the lack of the %installdir% variable.
One thing to be aware of is that removing the %installdir% variablemeans placing files in the “Application Folder” directory within theFile System Editor window will cause an error when you run cabwiz.Instead you should build up your directory structure by hand by rightclicking in the file system editor and selecting the option to add newCustom Folders.
Sample Application
[Download BespokeLOBApplication.zip - 18.1KB]
A small sample application is available for download whichdemonstrates this technique. A “dummy” application calledBespokeLOBApplication is packaged into a CAB file via a Smart DeviceCAB project.
Notice if you build the CAB via the Visual Studio interface that theuser will be prompted to select an installation location even thoughevery file specified in the filesystem editor is deployed to a hard-coded location.
If you then alter the CAB file using the technique outlined abovethe user will not be prompted to select an installation location duringinstallation.
For your convenience the download also contains two pre-built cabfiles called BespokeLOB_Prompt.cab and BespokeLOB_NoPrompt.cab todemonstrate the principal.
One disadvantage of this technique is that manual edits to the *.inffile will be lost the next time you rebuild your project via VisualStudio. If the structure of your CAB file does not change that oftenone solution is to remove the Smart Device CAB project from yoursolution and instead build your CAB file by executing the command linediscovered above via a custom Post Build step.
- Making a CAB file which doesn’t prompt for installation location
- Creating a CAB file for your application
- How to involve a new JAR which doesn't exist in MVN Repository
- File@CompanionFile doesn't work
- error: address doesn't contain a section that points to a section in a object file
- The CD-ROM drive contains a CD which cannot be used for installation.
- First token must be SYMBOLSET, this doesn't look like a symbol file错误的解决
- Template for making a class
- error:'a' doesn't name a type
- unity3d 解决doesn't have a clipped shader version for SoftClip 和 (AlphaClip)
- Unity3d NGUI doesn't have a clipped shader version for SoftClip 和 AlphaClip错误的解决方法
- [Q&A] Predefined Search Help for WERKS doesn't work properly
- IE8 Crashes on Cab File Installation using <OBJECT> tag
- Creating CAB File for Windows Moblie
- Field Doesn't Have a Default Value
- 【java】:selection doesn't contain a maintype
- C++ doesn't name a type
- English notes for Making a Call
- 汇编语言指令集
- JavaScript实例教程2
- C++的内存分配
- 格式化输出函数: Format
- JMS简明学习教程
- Making a CAB file which doesn’t prompt for installation location
- 暑假数据库知识小结
- ASP.NET控件开发
- 批处理查杀不正常svchost进程
- sql anywhere 的unload和reload(数据迁移) 用微软sql server 的DTS实现从 ORACLE导出数据到Sql Anywhere数据库中
- Oracle实战练习(续二)
- 如何部署.NET Compact Framework2.0 应用程序到Windows Mobile(制作CAB文件)
- 文字翻页 防Google分页
- 智能指针CComPtr 和 CComQIPtr