How do I start a console application in one project from a web form in another project? - vb.net

I have a website created in VS 2010 with .NET 4.0. There are multiple projects in the solution. In one of the projects I have a form that gives a user the option to run a console application that is in another project of the solution. (called update.exe)
I have tried just using
process.start(filepath + "update.exe")
but it doesn't seem to run.
It finds the file but then finishes immediately. I tried adding Console.readKey() to the console application so it would stay open after being called, but it was to no avail.
On top of this, I know that the console app isn't running as I have logs set up throughout the console's code and it never even seems to kick off.
Should I be calling the console app differently? (note: I am writing in VB.net)
Thanks!

Purely speculative here.. but my guess is that when the page finishes processing the process is terminated. Try having the page wait for the process to close.

My 'work-around' for a similar requirement is this:
Use the ASP page to create a CMD or BAT file on the server.
Create/write a service that 'watches' for the CMD/BAT file - and when it finds one, it runs it. The service can be written to start a process as a user.

Related

Get focus of other application from Vb.net Service

I have got a vb.net windows service that runs a File System Watcher to monitor an xml file for changes, when it detects a change it will stop the screen saver running and what I would then like it to do is give one of the other running applications the focus.
I have successfully used Appactivate from a Windows Form App in the past but I think I am correct in saying this doesn't work with Windowless applications (I have tried it and it doesn't).
I have done some Googling but I can't seem to find any way of getting the focus when called from a service \ windowless app. Is this possible?
Thanks
what if you make it a single instance application? and then simply launch its .exe file? it might give focus to the other running application instead of opening a new instance.

VB.Net running as a service

I have built an application that connects to the exchange server and does some scanning tasks on the incoming mail.
Application has a form where i can start and stop scanning,give in an interval, do some other configuration, and a notificationicon in the taskbar to show hide,end and so on..
The problem is that I would like the application to start as a service, because now a user has to log in first on the server before it starts working.
I tried some tools like RunAsService, i had a service, but obviously it didn't run the application.
Of course i understeand now that when the application will run as a service, scanning will be the only thing that will happen, no forms and no notification icons.
However i do not know where to start, should i extract the scanning logic from my configuration as a separate application? What application type should it become then ?
You have two easy options.
First one just create a new Windows Service Project from your New Project button in the Visual Studio, and then just program your app.
Second one, just create a service from the service management window in your computer and add the executable file of your program. It will start running as a service (with visible windows and everything as you coded it).
You should follow this link and schedule your vb.net windows program as windows task
In Your code, at the end ,when everything gets executed you should write Me.Close() to hide your form.

How to disable WCF Test Client - VS 2012

I have a new WCF Service Application, when I hit F5 to debug, the WCF Test Client always comes up, but I would like to disable it since I am using soapUI to test instead.
I have tried the answer here - https://stackoverflow.com/a/8441887/903056 but this XML node is no longer in the project file for VS 2012. I have tried several other things myself as well, such as changing default start page and trying to force debug to start a browser session instead.
This is realy frustrated but you can try one of the followings to disable the WCF test client:
1.Open the requested project properties and select the Web tab. Select
the Current Page radio button (I believe that the Specific Page
button is selected), Save the project and run(F5).
2.You can modified the prject XML (.csproj) file and add
<EnableWcfTestClientForSVCDefaultValue>False</EnableWcfTestClientForSVCDefaultValue>
attribute to <WebProjectProperties> node. That should be done by the
followings:
2.1 Unload the requested project (right click -> Unload Project).
2.2 Edit <ProjectName>.csproj (right click again on the project)
2.3 Look for WebProjectProperties node and add <EnableWcfTestClientForSVCDefaultValue>False</EnableWcfTestClientForSVCDefaultValue> to it.
2.4 Reload the poject.
I hope you will find that unswer helpfull..
A simple option that works for me (at least in Visual Studio 2012 Update 4):
Open the WCF project properties and go to the Web section. Set the Start Action setting to Don't open a page. Wait for a request from an external application.
After choosing that option I no longer see the WCF Test Client.
I personally usually choose this start action anyway, since I much prefer hitting F5 in my browser than having yet another tab opened each time I hit F5 in VS.
I found a reasonable work around. All I did was add an empty html page to the project, then right clicked on the html file in Solution Explorer and chose Set As Start Page. A debug session starts but it doesn't go to the WCF TestClient. Not elegant but works.
Old thread but found it while I was suffering the same frustration with VS2013. If you run the project (F5) with the (yourProject)\svc.cs file open in the VS editor then the WCF Client starts. If you hit F5 with any other file as the selected and focused file in the VS editor then IIS and the normal first web page starts.
Very simple when one knows.
I had a similar problem, and found this to be caused by the default Start Options under
> Solution Properties
> Debug
>Start Options
>Command line arguemnts:
it was listing a command line argument of /client:"WcfTestClient.exe" which was launching the test client. Simply removing this argument solved my problem.
No need to extra thing just do thing below.
Tools-->Option -->project and solution-->Build and Run and finally
check Only startup project and Dependencies on Run

Debugging activeX dll via classic ASP

I finally got my localhost to display the site locally. Everything seems to be working on that end. My next step is to actually be able to step into the code from the VB6 IDE when the web site uses a function from the ActiveX.dll
UPDATE:
I updated the code and removed the issue I was having compiling the code.
Now when I try to debug the site won't open. It just hangs. I'm wondering are there any tutorials that I can read so figure out how to properly get this application setup for debugging?
UPDATE #2
Just to clarify, I got the web site (which references the ActiveX .dlls) locally on IIS 7.5. My hope is that when I open the site (on localhost) I can step through the .dll code at the same time.
That is really what I'm asking.
It's actually quite easy. First of all, do an iisreset. Then load up Visual Basic with your ActiveX DLL. Place your breakpoint, then Run your project.
Then hit your page containing a call to the ActiveX DLL and it should stop on a breakpoint you just set.

ClickOnce Online-Only Application as a TS RemoteApp

I've attempted just about everything to get our ClickOnce VB.NET app to run under Terminal Services as a RemoteApp. I have a batch file that runs the .application file for the app.
This works fine via RDP desktop session on the terminal server. As a TS RemoteApp, however, well... not so much.
I get a quick flash of command prompt (the batch file) on the client system and then... nothing...
Same goes for having it point to the .application file directly (without using a batch file) or even copying the publication locally and having it point to that.
I found a technet.microsoft.com discussion about a similar issue, but there's no resolution to it listed.
For anyone who has run into this before and got it working, what did you have to do?
We currently use RemoteApp's for everything else on that server, so I'm hoping to stick with that if possible.
The current workaround is to build and run an MSI-based installer for the app on our terminal server whenever we publish via OneClick out to the network, but this can be quite a pain at times and is easy to forget to do.
Since the app works fine via Terminal Services when run in full desktop mode but not during RemoteApp, I don't think it's anything specific to Terminal Server permissions so much as ClickOnce requiring something that isn't available when running as a RemoteApp.
The Key to getting it to work is to use Windows Explorer "C:\windows\explorer.exe". This process is the base process when you login to a full session.
If you setup the RemoteApp to use Windows Explorer and the command line argument of the path to the .application file for the ClickOnce application then it will work when launched as a remote application. Windows Explorer will flash for a second when it starts, but it will disappear then the ClickOnce application will launch.
Why does it have to be a ClickOnce application? I would consider just deploying the exe file and assemblies.
I know it only half a solution, but if the application does not change much, it might be a good solution.
I believe your problem is related to the fact that ClickOnce needs to store it's data in a special user folder called the ClickOnce application cache. Apparently because of how Terminal Services sets up user folders ClickOnce can't access this in TerminalServices mode.
See this link for more information.
http://msdn.microsoft.com/en-us/library/267k390a(VS.80).aspx
There may not be a way to do it :(
Can you launch the .exe directly? It's buried under your profile in \AppData\Local\Apps\2.0[obfuscated folders], but you should be able to find it.
That will skip the built-in update process, but if it can be launched that way you could then write code to do a manual update after the application starts.
Faced the same problem this morning and got it resolved by copying the clickonce app's directory from the user settings folder to somewhere like c:\MyApp\ - I know its nasty and not very ideal.. but good enough for me!
We recently ran across this issue and decided to post a bug report on this issue to the Visual Studio development team. Feel free to comment on the bug report. It has to be a bug in ClickOnce caused by some changes in Server 2008.
https://connect.microsoft.com/VisualStudio/feedback/details/653362/net-clickonce-deployment-not-working-as-remoteapp-or-citrix-xenapp-on-server-2008-server-2008-r2
We also have a discussion on the MSDN forums covering this issue:
http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/7f41667d-287a-4157-be71-d408751358d9/#92a7e5d9-22b6-44ba-9346-ef87a3b85edc
Try using RegMon and FileMon when starting the app - You may be able to track it down to a file and/or registry permission issue.
Also maybe check the event logs to see if anything's getting logged when the process fails.