I have a C# win form application and I build a "setup" for it by visual studio 2010
my application needs some parameters like username , pass, ip and ...
i want to get these values from user before setup complete and save it to a file to use by my application. but how?
This answer presumes that you are using the Setup Project in Visual Studio. If you aren't edit your question and we can take another look.
To gather user input you need to introduce a new dialog to the installer.
The following steps will bring you to the part of the installer project that will allow you to add new dialogs:
In the Solution Explorer menu select the option "User Interface Editor"
In the newly opened screen right click on of the options (Install for example) and select "Add Dialog"
This displays a range of pre-built user dialogs. You will probably want one of the text box dialogs.
If you want something different you can also create a custom setup dialog. There is a nice code project post on doing this here.
Once you have this information you need to actually access it and use it during installation.
For this you need to add an installer class to your target project (the project you want to install).
In that installer class you can reference the text boxes you created using code like this:
public override void Install(System.Collections.IDictionary stateSaver)
{
string myPassedInValue=this.Context.Parameters["TEST"];
//Do what you want with that value - such as storing it as you wanted.
}
This answer is a little bit from 10000 feet - if I went into all the detail I'd end up writing a full article. If you have any sticking points, please ask. Also - have a look at this excellent article on the subject, it should get you most if not all of the way.
In VS solution explorer
Right click yoursetup >> View >> USerInterface
Right Click Start >> Add Dialog >> Select TextBox
Now made a Custom Class And add Install class file
Sample code
In Install.cs
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
string targetDirectory = Context.Parameters["Username"];
string servername = Context.Parameters["password"];
}
Related
I created a VSIX package in order to find a list of methods implementations having a certain parameter type (using Roslyn and code analysis API). At this time I jump to a certain file location in solution. Using :
ws = componentModel.GetService<VisualStudioWorkspace>();
ws.TryGoToDefinition(mySymbol, myProject, cancelToken);
The thing is I have many symmbols I would like to display to user, using the same 'references' window that gets displayed when pressing Shift + F12 keys. Or a similar approach.
Has anyone got examples or link to code samples ?
I want to set in the right-click menu of windows, a shortcut to my app.
The goal is to select a document (image, pdf etc.) -> right-click -> 'Send with my app' ( and optionnaly open a certain class with arguments, like the files path)
I've saw some many possibilities to do that ...
but I would like to know the good way to do that with a c# wpf app.
The goal is to send an installation program to many clients to allow them to use the app, and set the entry on the context menu
In order to show custom options in Windows context menu, you will need to update the registry. Here is how to do it
http://www.howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/
Once done, in your wpf application, you can get the command line arguments passed using :
string[] args = Environment.GetCommandLineArgs();
from these args, you can extract any argument passed (file location etc)
I'm creating a setup program for an application that will require the user to choose between three setup options. I would like to take the result of the user input and write to the registry, so that the application can read this value at run-time. From what I've read so far I've been able to create the custom dialog with radio buttons, but what I haven't been able to find is how to take the result of the user's selection and then run a custom action which will write the result to the registry. I assume I can write a small script or executable which I can launch from the custom action by adding this script or exe by adding it to the application folder, but how do I get the value selected to be passed to this script or exe?
Thanks for any advice.
Maybe those links will help you:
RadioButtons User Interface Dialog Box
How to: Set Conditional Installation Based on User Choices
creating setup c#
My two cents: I think you may consider using another suite to create your installation, like Installshield. The VS 2010 setup program is, IMHO, not a good setup program.
Following the advice of Henk, I've created a Setup Project in VS10 with the aim of adding a custom action. This custom action will hopefully add an EventLog whilst running as admin (ie during installation) rather than having my app throw an exception on OSes with UAC.
Unfortunately, I don't ordinarily have access to an OS that uses UAC. The next time I do, I hope the installation will go smoothly.
With that in mind, is there anything in the below code which is obviously wrong?
using System;
using System.Diagnostics;
namespace EventLogCreator
{
class Program
{
static void Main(string[] args)
{
switch (args[0])
{
case "-i":
if (!EventLog.Exists("SSD Log"))
{
Console.WriteLine("Log not found, creating.");
EventLog.CreateEventSource("setup", "SSD Log");
}
break;
case "-u":
if (EventLog.Exists("SSD Log"))
{
Console.WriteLine("Log found, removing.");
EventLog.Delete("SSD Log");
}
break;
}
}
}
}
The output of this project is sucked into the setup project. I then have two custom actions:
On install with "-i" as an argument
On uninstall with "-u" as an argument
I'm not expecting a free code review, but I'm venturing into the unknown here, so I'd appreciate a heads up if I'm humping the wrong bit of trash.
PS I'm particularly concerned that I'm specifying the actual log name, but not an actual source. Will this matter?
You will probably be better off using the "EventLogInstaller" found in the "System.Diagnostics" assembly.
You can see a implementation of this when you create a custom component, then adding a event log component to the design surface, fill in the properties for the component, then click on the "Add Installer" link/command in property window. This will add a project installer component, which will contain a event log installer component.
The event log installer component is what you are looking for, basically it is a windows installer action that can be run when you create a windows installer package (MSI). All you have to do is specify the installer action in the "Custom Actions Editor" of your visual studio deployment project. There is quite a bit of information regarding custom actions in the MSDN library.
Also have a look at the following:
EventLogInstaller Class
Installer Tool (Installutil.exe) - msdn.microsoft.com/en-us/library/50614e95(VS.80).aspx
I can't remember or access the details right now but somewheren in that (horrible) UI for setup-projects there should be alist of 'standard' actions for, amongst others, creating an EventLog. That would be the safest way.
But you should be OK testing this w/o UAC. If it works, it works. A setup.exe runs as Admin
How to open files from explorer into different tabs. I can associate an open with menu with the file type, now when I already have the program working, how to open the new file into another tab, instead of new program.
How to find the already running process exactly, not with the name and send the filename to it.
Let me make myself clear: I want my app to be single instance, so that when user select 10 text files and press enter key, my application will open all the 10 text files into 10 tabs, instead of creating 10 processes. How to do that? How to communicate between various instances of the same process.
EDIT SOLVED: Implemented the functionality using WM_COPYDATA in C# and the SingleApplication class from codeproject.
I am not quite sure what you mean in this question. Are you trying to open Windows Explorer windows into one window with tabs? If that is the case, then I recommend you look into QT TabBar, which extends Windows Explorer to allow for such behavior.
Or perhaps you are trying to have a link open to a new tab in a web browser. If that is the case, this behavior is defined by the web browser itself. For Internet Explorer 7, you can set this behavior under Tools > Internet Options.
In the General tab, click the Settings button next to the "Tabs" section. You will want to set the "Open links from other programs in:" option to open a new tab.
Keep in mind that this behavior is defined by each user, and you can't ever make any guarantees that they will have the same browser settings as you do.
After reading your comments, I think I understand a bit better. It sounds like you want your application to only allow one instance at a time. Since you tagged this post C#, I will assume that is what you are writing your program in.
Codeproject.com has a great tutorial on how to make your program only allow a single instance.
Here is a snippet of code from their site:
static void Main()
{
if(SingleInstance.SingleApplication.Run() == false)
{
return;
}
//Write your program logic here
}
You would want to write code just before the return statement to have the existing instance open the file in a new tab.
If you are able to provide detailed information about what your program is doing, we might be able to help you with some of the specifics.