I have a strange requirement, I have been asked to code a certain validation script in VBScript because its in plain text. But I am more comfortable in c#. So is there anyway to schedule it in Task Scheduler such that the compiler will compile the program(source code in .cs file) and run it on the fly.
Assuming you want behavior similar to VBScript/JavaScript in command line where they behave similar to normal EXE files. To see how JS/VBS are executed check output of assoc .js
and ftype JSType
commands.
Basically you want to create CMD/BAT file that will launch CSC to compile you .cs file and than run executable with all original parameters of CMD file. Than associate this new CMD file with .CS file type. To configure associations check ftype /?
provides plenty of info.
Note that it may be good idea to have custom extension instead of default .cs (i.e. .cssript) to avoid confusion with regular .cs files.