Best solution for making an Autorun application? - c#

For my work I need to create a Autorun application for a CD for our client. The problem is all I'm a C# programmer by trade and .NET does not make for the best autoruns since not all computers will have .NET installed on them.
What is a good solution that will work on Win98-Vista computers?

The answer to this question is really one of preference. Technically, anything can be instructed to open as an autorun. The autorun.inf file is simply an instruction file that Windows knows how to read in order to determine what it should do when a CD is inserted. That could be an application (written in any language you choose), a powerpoint presentation, opening a link to a website, etc. As long as you follow the rules of the autorun.inf file:
http://autorun.moonvalley.com/autoruninf.htm

There are many small autorun-utils (some free) that are configurable. I would go for one of those.
http://www.ezau.com/latest/articles/083.shtml

You need two things:
Follow this steps (http://support.microsoft.com/kb/324733 OR http://support.microsoft.com/kb/888469)
When your application is ready (with bootstrapper), you'll have to create a autorun.inf file on CD root path. Search 'autorun.inf create' on your favorite Search Engine.

It is possible using Mono's bundling feature:
"The resulting executable is self contained and does not need the Mono runtime installed to run."
Mono is an Open Source .Net clone and should be able to run most .Net applications. See "Bundles" section here: http://www.mono-project.com/Guide:Running_Mono_Applications

You could use .hta file on CD to launch as splash page, and from there detect if .NET is installed (using COM from HTA file) and then run your custom executable.
.hta files are what Microsoft SQL Server (and most of their others) installation cd uses from memory, easy to make them look very professional (its just html in the background basically)

You can include the runtime with the CD, but you'll have to install it before running your app. You might look into just popping open an html file from the CD.
Otherwise, you can look at writing a small native program that can prompt to install the runtime if it's not there, or run your .NET app if it is.

Try Delphi; it's by far the best way to create native win32 application nowadays.
It creates slick stand-alone .exe files with rich GUI's that don't need any runtime libraries or other annoying dependencies. Works on any windows machine.

There was a program from Macrovision called "Demoshield" that worked well back in the day. I'm not sure if its available anymore, but it was an alright program for creating the auto-run programs.

Related

Select .app Files in MacOS File Browser using C#/DotNet

I'm working on a MacOS application built in Unity3D. I'm using a native file browser plugin to open native MacOS file dialogs for selecting files.
In order to generate PDFs, my app relies on using Chromium's Headless/command line functionality.
On Windows, I can easily get the path to the included Microsoft Edge as that's standard, but on Mac, unless I guess and check (which I already do), there isn't a way to guarantee a Mac user has a Chromium-based browser installed.
So I intend on allowing the user to set the path manually by selecting the .app file with a file dialog. But even when I specify .app to be a valid extension, they still don't appear selectable.
I assume this is some sort of MacOS-specific limitation or default permissions, though I can't find much info on this online.
Using C#/DotNet s there any way of allowing this behavior as needed?
For some more info: I'm just running the application using System.Diagnostics.Process.Start() with command line arguments.
Based on my experiments searching for Google Chrome (though Edge or Opera are just as usable), the path I'm looking for is:
/Applications/ {{APP NAME}}.app/Contents/MacOS/{{APP NAME}}
Because Contents isn't accessible by most users, I figured I would just automatically go in and grab the binary with the correct name.
I know I could include some lightweight version of ChromeDriver with my app, but I'd rather keep everything as self-contained as possible, especially as so many people already have Chrome (or Opera, Edge, etc) installed. The challenge is that not everyone has it installed in the same place, hence my need to make it customizable.
Any ideas or help would be appreciated!
Thanks!
After doing some testing: It seems that this limitation is only when running inside the Unity Editor. Once the app is built into a standalone Mac application, the file dialog does allow the selection of .app files and it works as expected.
Not a 100% solution to this problem, but definitely clears up some concerns.

Deploying C# application on any computer

I am new to C#.
I have a program that I want to work on any computer.
How do I compile the application to work on any computer without dependencies?
A simple hello world let's say:
class MainApp {
public static void Main() {
// Write text to the console.
Console.WriteLine("Hello");
}
}
In order to run a .Net application, you need the .Net Framework installed on that computer.
If this is a problem for you, pick another language.
To compile the application, you can either use Visual Studio and choose the Build Solution from the Build menu.
You can also use the command line and csc.exe
To compile your application via csc you will need to execute the following statement in the command prompt.
csc YourFile.cs
Any computer attempting to execute the assembly will need the .NET framework installed.
The other computer will need the ability to run .NET programs.
There are two ways that I know of that you can run your software on someone elses computer assuming they meet the above requirement.
The first way is to go into the bin folder and get the executable
(or the .exe file) this can just be distributed and ran. This is ussually in a path simular to this C:\Users\username\Documents\Visual Studio 2012\Projects\YourProjName\YourProjName\bin
The second way is to create a click once application. How to create a click once
On a side note, if you want your program to run on almost any machine I would choose a different language. Java is pretty popular and it is VERY close to C#. Many colleges focus on Java as well so it gives you a leg up if you ever go to school for it. That said, I did my whole degree in Java and ended up in a .NET shop so I had to relearn a ton of stuff.... On second thought, just learn everything...

Starting .NET application from network share with extern DLL runs into crash

I've developed a tool in C#.NET/Visual Studio, which uses an imported dll.
The dll will be copied to output folder, when the project is built.
It doesn't need to install the application, you can just copy the exe and dll to a local folder to start.
Now I want to start the application from a network share:
\\localhost\program\prog.exe
All is fine while I don't call a function from the external dll. Then it crashes with the following error window:
Program has stopped working...
Question: Is there a way to make it work without copying both to a local folder and without changing policies on client computers?
Answer: Mapping \localhost to Z: solved this problem.
Please feel free to ask, this is my first question ;-)
Best regards,
Christian
This sounds like a "caspol" issue. Network shares like \\localhost\program\ get reduced trust. Interestingly, from (some time ago), named shares actually get more trust - so one simple option is to map, say, z: as \\localhost\program, and access z:\prog.exe - you might find that this makes it work. Beyond that, the options are:
caspol changes to the each client machine
ClickOnce
of those, the latter is simpler. Then you simply run the ClickOnce application (rather than the .exe) - ClickOnce then basically makes it work. The user will, IIRC, need to click an "ok" the first time they run the application, but that's about it. You would need to ensure that the external dll is known the the ClickOnce deployment, i.e. it is in the project and marked to be shipped.

Trying to launch a Visual Studio C# program from inside another one

I am having great difficulty getting a Windows program, written in VS 2008 C#, to launch another type program. I've put a main program to offer you the ability to launch some other VS 2008 C# programs. When one of them is selected the following code is intended to do the launch:
System.Diagnostics.Process.Start(#"C:\Documents and Settings\rat\My Documents\Visual Studio 2008\Projects\PV_002_082708\PV_001\PV_001\bin\Debug\PV.exe");
It works, but each user will have a different path. The path shown is for my computer. The code would have to know where each persons program was installed! In the past, I could easily call a program that was in the C:\Program Files location because that's where the MS Package & Deployment program put the programs. VS 2008/2010 doesn't put them there!
I'm sure I am not knowledgeable about Visual Studio 2008/2010 to know if there is a way around this, so any help would be greatly appreciated.
System.Diagnostics.Process.Start(System.Io.Path.Combine(System.Windows.Forms.Application.StartupPath, "PV.exe"));
assuming that the program is in the launched application's path.
or...
System.Diagnostics.Process.Start(System.Io.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), #"Visual Studio 2008\Projects\PV_002_082708\PV_001\PV_001\bin\Debug\PV.exe"));
assuming you want to open the project from it's place.
Once you create the installation package you can set the install path to some fixed path that users will not be able to change and than use that from your code (not very user friendly but it would work) or insert the user chosen path value into the registry and get it from there instead.
May want to have a look at this thread. How-to as well as lots of pro's and cons.
Embedded a *.exe into a dll
If you see the first answer to his question, I think this would work for you.
Simply he is saying, you add a resource file to your project, then when the user runes your program, it extracts your exe file that you added as a resource file to somewhere you know on the end users maching.

How can I add items to Windows Shell (rightclick)?

I'm going to make a desktop application that will run in the background, meaning no visible window, and I'd like an option called: "Upload Text" to appear when a user right clicks a file.
Can someone point me in the right direction? I also have to make sure that if someone wants to uninstall the program at any point, that the shell modification is also cleanly eliminated.
The app will run Windows XP, Windows Vista and Windows 7. How different are these OS's in handling my shell dilemma?
This is a shell extension. You've tagged this question with the C# tag; you should know that writing shell extensions in a managed language is strongly discouraged:
Unfortunately unmanaged C++ is really
the only way to go here.
Writing in-process shell extensions
in managed code is actually a very
dangerous thing to do because it has
the effect of injecting your managed
code (and the .NET Framework) into
every application on the machine that
has a file open dialog.
The problems occur because only one
version of the .NET Framework can be
loaded in a process at any given time
(other shared components such as java
and msxml have the same property and
thus the same restriction).
If you write your shell extension
using the 2.0 .NET Framework and an
application built with the 1.1 .NET
Framework uses a file open dialog,
your shell extension will fail because
it can not run on an earlier version.
Things can get even worse if your
shell-extension manages to get loaded
in a process before another
applications managed code does: your
extension may force an existing
application onto a different runtime
version than the one it was expecting
and cause it to fail.
Because of these problems we strongly
recomend against using any
single-instance-per-process runtime or
library (such as the .NET Framework,
java, or msxml) in an in-process shell
extension.
That said, people have done it.
Here's a guide to creating shell extensions, using C++.
You could add your app to the SendTo folder.
What about a stand-alone program using SendTo?
Install the exe to "Program Files\mycompany\myprogram" and a shortcut to the exe into the SendTo folder. Then when a user right clicks on a file, selects SendTo, and then selects your program, your exe will be executed by Windows and the full path to the filename will be passed in via argv[1]. If they select n files they will be in argv[1]..argv[n].
If you want your program to be invisible then do not make the default form visible. You could optionally place an icon in the tray so the user could double click on it to see the upload progress. When the upload of argv[1] is complete, process argv[2]...argv[n] if they exists and exit. To cleanly uninstall, remove your program and the shortcut from the SendTo folder.

Categories