A simple way to run C# code from bat file

I read an interested article demonstrated how to run a bat file with embedded C# code. I repost this example here, because the original post is written in Russian. Despite the fact that there are other more powerful solutions and frameworks to achieve the same goal (e.g. Powershell) – I think the way presented by the author, is very useful for different scenarios.


/*
@echo off && cls
set WinDirNet=%WinDir%\Microsoft.NET\Framework
IF EXIST "%WinDirNet%\v2.0.50727\csc.exe" set csc="%WinDirNet%\v2.0.50727\csc.exe"
IF EXIST "%WinDirNet%\v3.5\csc.exe" set csc="%WinDirNet%\v3.5\csc.exe"
IF EXIST "%WinDirNet%\v4.0.30319\csc.exe" set csc="%WinDirNet%\v4.0.30319\csc.exe"
%csc% /nologo /out:"%~0.exe" %0
"%~0.exe"
del "%~0.exe"
exit
*/

class HelloWorld
{

    static void Main()
    {
        System.Console.WriteLine("Hello, World!\r\nI am at " + System.Environment.Version);
        System.Console.ReadLine();
    }
}

Avoid the shutdown of your ASP.NET application after inactivity

To avoid the shutdown of your application after 20 min inactivity, you can use a ping tool like:

SmarterPing

SmarterPing is a Windows Service built around solving this problem. SmarterPing will hit selected web pages at regular intervals to keep them alive on the server. For low-activity sites, and those using shared hosting, SmarterPing will keep sites running smoothly and quickly.

 

Features:

  • Connects to only the pages you specify, exactly as you specify them
  • Customizable ping period
  • Implemented as a Windows Service to ensure continual operation
  • Easy-to-use front end
  • Installation on one computer in your network is enough to keep all of your sites alive

Download SmarterPing

 

WebMon

WebMon is a freeware web page update monitoring program – it saves you time and keeps you updated by automatically checking web pages to see if they have changed.

main

Features:

  • Checking an unlimited number of web pages.
  • Scheduling automatic checking at set intervals.
  • Optional pop-up alerts and sounds when updates are found.
  • Running other programs when updates are found.
  • Selecting which part of the web page to check.
  • Update logging.
  • Proxy support, with authentication.
  • Unintrusive tray icon when minimized.
  • Importing IE favorites and Netscape bookmarks.
  • Help system – simply press F1 at any time.
  • Simple installation and removal.
  • Freeware, with no advertising or spyware.

Download WebMon

Detecting Net Framework directory

You can use

System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()

or

HttpRuntime.ClrInstallDirectory property ( don’t forget to add reference to System.Web.dll )

Create an RSS feed from your IM conversations

Sabifoo  – IM boot that turns all incoming messages(from  AOL Instant Messenger, Jabber, MSN Messenger, and Yahoo Messenger ) into an RSS feed or web page.It will even deliver them on to your blog or other soft via gateways.

[Via Larkware News]

Technorati Tags:  IM messenger yahoo jabber gateway rss

Turn your MSN Messenger into a multi-protocol client.

IMTiger is a simple and very useful add-on that turns MSN Messenger into a multi-protocol client. IMTiger allows you to have one combined contact list for multiple accounts of MSN, ICQ and AIM.

IMTiger Features:
Support unlimited number of MSN/AIM/ICQ account in one MSN messenger
Turn your MSN Messenger into a Multi-Protocol Client.
List AIM/ICQ buddy’s present status in MSN Messenger’s contact list
Chat with AIM/ICQ  buddy in MSN Messenger

Get the IMTiger!

[Via Neno Loje's Treasury ]


Page 1 of 212