How to create a exe that installs a driver - c#

I want to create a very simple .exe that will install a driver. I have an .inf (and all it's DLL files). The driver is for a usb device.
The end goal is to find a simple solution to install a driver with my application installer. The installer is generated using Visual Studio 2008 setup and deployment project. I believe that having a separate exe that does the driver install can be called by my setup and deployment project.
I am a newbie at this so i am looking for a step by step tutorial or something that i can really understand.
Please help :(
EDIT:
The following command line installs the driver just fine. How can I transfer this into a EXE or DLL, which can be launched by custom actions in Visual Studio
rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 .\<file>.inf

Have you checked How do I deploy a .inf based driver?

The Visual Studio Setup & Deployment project is fairly limited in functionality: probably the easiest way to create an installer for your driver is to use WiX and DIFx - you just need to add a difx:Driver tag to your source file and use the WixDifxAppExtension extension when running candle/light. An example from the project I work on can be seen at http://www.bluestop.org/viewvc/repos/sctpDrv/trunk/wix/ - the candle/light commands are in Makefile.wix and module-common.wxs contains the DIFx code.
The output of WiX is an MSI file. If you want a .exe I'd recommend using dotNetInstaller, which can bootstrap any prerequisites before running your MSI.

Doesn't the .inf file itself install the driver?
If for some reason you are using a tool that (unlike say explorer) isn't smart enough to know that is what inf's are for, perhaps you could write a little program that tells windows explorer to run the inf file.

I believe that the 'start' command will run an associated file at the command line.
So a one line script aught to do (example run.cmd file):
start myWordDoc.doc
That command will open up Word and Load that document.
It 'should' do the same for INF files, let me know if it does.

Related

Creating a dll from classes in c#

I have a few classes with the same namespace, and I want to put all of them in a dll file, and use it in other places.
I read the guide on Microsoft's website:
http://msdn.microsoft.com/en-us/library/3707x96z(v=vs.80).aspx
They suggested this:
To build the file [myDllName].DLL, compile the two files [myClass1].cs and
[myClass2].cs using the following command line:
csc /target:library /out:[myDllName].DLL [myClass1].cs [myClass2].cs
I wrote it in a cmd window and got an error that there is no such command as csc.
Plus, how it will find my files without a path?
So what is the right way of doing it? Where should I write it?
I saw some posts here with Library classes.. but not sure how it can help me.
My classes are in a different solution, and I just want to use it as an external dll, and not within the same solution.
In this case, Microsoft's guide seems perfect, if it will work.
If you use the Visual Studio Command Prompt window, all the necessary environment variables are set for you. In Windows 7, you can access that window from the Start menu by opening the Microsoft Visual Studio Version\Visual Studio Tools folder. In Windows 8, the Visual Studio Command Prompt is called the Developer Command Prompt for VS2012, and you can find it by searching from the Start screen.
source
You can run the vsvars batch file from a command prompt and it will set paths for you, for that instance of cmd.exe
Mine is here:
>"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat"
Why don't you just create a separate 'Class Library' project in your solution in Visual Studio?
You can than easily add it as a project reference to all other projects that need it.
You can create Solution Folders in VS to logically group projects.
Make sure csc.exe is in your PATH environment variable.
You should have a vsvars32.bat that was installed with Visual Studio. You can run that to automatically add it to the path, or dig down in regedit to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
Look through the subtrees in there for your framework version, and for an InstallPath key. That should tell you what directory to look in.
You can then use that, and:
WHERE /r "the_directory_you_found" csc.exe
to find the path. Add that to your system environment variables, and you should be able to find it.
As for the path of the class files, either run the command from the directory they're in, or specify the path when specifying the class files.
If you have Visual Studio installed, you could try creating a 'Class Library' project; Or you can run csc.exe by Launching "Visual Studio Command Prompt".
If you don't have Visual Studio installed but have .net framework installed. You can run csc.exe from the framework installation directory.
Installation directory path for .net Framework 4.0 :
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

create exe from visual studio 2012 c#

I made a little app with c# which I wanted to send to a friend to get an opinion. Problem is when I selected release configuration and click rebuild I get 7 additional files(3 dll's, 1 exes,...) along with the exe I want. Am I doing something wrong? I used to get single .exe files back when I used c++ with VS 2005.
You are not doing anything wrong. Its just that at release additional files are generated like AppConfig.xml for instange that holds your application settings, or a ClickOnce deployment package so that your friend can install the app. To get more used to c# you can start by googling articles about the differences between debug and release
Have you considered using the Click Once facility built into Visual Studio 2012?
Click Once Deployment - MSDN
Click Once will generate an installer that will that your friend can execute. It will automatcially download and install any dependencies (such as a specific .NET Runtime) if necessary.
To distribute referenced DLLs look at the following URL as it suggests the correct configuration settings:
How to: Specify Which Files Are Published by ClickOnce
It's been an horrible hour. Couldn't get Clickonce working for such a simple app. Moving just the 3 referenced dlls and the exe to another folder worked. Wix on the other hand...is difficult to say the least.
However, this allowed me to create a single setup file if not an exe in 10 mins. I sent a shortcut to the desktop which is more or less what I want.

How to run an application as soon as installation is completed?

I am writing an installer for a c# application using visual studio 2008.There i have created a setup project and created the .msi file also.it is working properly.Now I need to run my application at the end of the installation.Is there any way to override the installer class to do that?
need a help
thanks
Download Orca from microsoft which lets you read and edit msi files. That helped me puzzle out a different problem with installs.
And check this out Run exe after msi installation?
does it have to be in MSI ? why not have a batch file (run.bat) and run your msi first followed by your app

someone knows how to add a setup file into a setup project in visual studio?

i have a project that also need to install other msi's files to be able to works my previous app, but i was wondering if my installer project could do all this thing in only one setup file, it is possible?
From what I know, you can add merge module (msm) in the VS Setup project and not MSI files directly. You can check with msi provider if msm file is also available or not. In case msm files are not available, one of the work-around would be to include msi files in setup package and launch them using custom action. Obvious issue is that if child msi fails then you may not able to rollback entire thing cleanly.
Usually this is done through prerequisites. In Visual Studio you can add them through the project properties dialog.
This requires an EXE bootstrapper. So if you want a single setup file you can try finding a tool which can include everything in a bootstrapper. Most commercial setup authoring tools can do this.

Is there any point to the setup.exe file created by a setup project in Visual Studio?

I've created my first setup project using Visual Studio 2010. I've noticed that when I build the setup project it generates an MSI installer file and a setup.exe executable. However, I seem to be able to just right click on the MSI file and choose install to install my application rather than running setup.exe.
Does the setup.exe file that is generated do anything other than just fire up the MSI file? When distributing my application can I just provide the MSI file rather than the MSI file and the setup.exe file?
Kristopher Johnson is correct about the older machines, but it also does something else. When you are setting up the installer you can set dependencies and locations to download those dependencies. The Setup.exe does those dependency checks and launches the other MSI files in to install them. This is most often used to make sure Windows has the correct version of .NET or the C++ runtime installed.
If you do not have dependencies and you can guarantee .NET or the C++ runtime is installed then you do not need to distribute the setup.exe file.
Many (most?) users are accustomed to running the "SETUP" program to install something. That's why it's there. It's a good idea to provide it, unless you are certain that only technically knowledgeable users will be installing your application.
SETUP.EXE is also useful if somebody tries to install on an older version of Windows which doesn't have support for MSI files. In that case, it displays some sort of "You cannot install this program on this version of Windows" error message.
I believe (but could be mistaken) that it performs boot-strapping of the correct version of MSI.

Categories