.net make console exe hidden? - vb.net

I'm using Windows Task Scheduler Wrapper to schedule the tasks (basically to launch an exe console every two minutes or so) in a .net desktop application.
However, I don't want it to pop-up the console every 5 minutes or even once.
How do I hide it?
I understand if I was using vb.net to launch the exe, there are several things I could have done. However, I am using windows task scheduler to launch it. What do you suggest in that scenario?

The console app will only display if scheduled to run under your account. Simply create a new account, and schedule it to run under that account.

Related

How should I design a portable (one executable) WinForm GUI app and Windows Service?

I want to develop an application with VB.NET 4.7.2 Framework, using WinForms. The application must run like a service, that is, ran at Windows startup (after boot, before login). It's intended to run only on a local enviroment, and play some sound files while the local user hasn't logon yet.
My first aproach to this problem was developing a WinForm app that accepted command line args, so when it was executed without args, the GUI appeared to let the user customize some of the features of the program, and when it was executed with args, then no GUI is shown and music is played.
However, the method for detecting when login/logouts and other NT Session Events happened was by hooking a script onto the Windows Scheduler, which ended up being a bad idea, because half of the times, the program would lock up (as the Windows Scheduler would try to execute multiple times) or didn't even execute the program (because it didn't even fire up correctly the login event).
Now, I've considered remaking my code into two programs, a service that runs the code, and a GUI app that sets up the settings for the service program. My idea is to embed an executable inside the main GUI app executable, so it automatically extracts it to a folder in order to run the service program.
However, I can imagine this isn't a pretty clean solution; more so if it triggers by error an antivirus.
I would appreciate some kind of help to get this working on a much clean and safe way.
Note: The main goal of this question is to preserve the all-in-one executable format, if possible. If not, either design a way to run a WinForm app like a system service (run at Windows startup, before login), or two individual programs, one as a service and the other as the GUI program.

start service from asp.net core web application

I am Building web application on asp.net core.
my application needs some data once in a week.
I have created console application which gets this data (really, it parses some website once in a week and stores that data in a database).
I have configuration file when should that console application start to get that data.
My question is how to start that console application from my web app and is it a good idea to start console application from web application?
IMHO it's not best practice to start a console application from an web application. If you would like to do that, please consider using a Windows Service with an timer or a cron job for that.
What you can do is create a scheduled tasks using Windows Task Scheduler. This task's action will be to State a Program and then you can set Program/Script to your console exe file. You can schedule this task to run once a week.
You can check this task history to ensure the task is executing weekly and can run it manually in case of failure.

Start application with administrative privileges when user logs on

I'm trying to find a way to start an application when the user logs on. The application must have administrative privileges.
This seems to be easy: just create a new registry key under:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
This works, but the user is asked every time by the User Account Control window. This is annoying, especially at startup. So I'm trying to find a way to launch this applications with elevated privileges but without the UAC prompt.
I've found here a solution: it uses Windows Task Scheduler. However, this Windows utility seems a bit unreliabled: sometimes it works well, sometimes not. On two computer tested, my application is started with a delay average of 46 seconds.
On the link given below, it says that you can recall the Task Scheduler operation with this command (where MyOperationName is the name of the scheduled task):
schtasks /run /tn "MyOperationName"
so, if I try to combine this command to a new key in CurrentVersion\Run I should get what I want. Would this work?
I'm working on VB.NET WinForms, Visual Studio 2013 and I use this library to interoperate with Task Scheduler.
Thanks,
FWhite

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 do I start a console application in one project from a web form in another project?

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.