Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have what I thought would be a dead easy question to find an answer to.

Having really, really tried to get on with PowerShell, I find its syntax to be arcane to say the least. I don't doubt its power but I'm not a sysadmin and I don't do batch scripting very often. So every time I come back to PowerShell, it takes me ages to Google the syntax for even the simplest tasks. Almost always, I find myself thinking, I could probably do this no problem in C# and sometimes I do create a full command line .exe in Visual Studio to do what I want. So...

Is there an easy and convenient way to create scripts based on C# syntax and then run them from a Windows command prompt?

Any advice or comments on anything that people have experience of would be appreciated.

Kind wishes - Patrick

What I have tried:

I've looked at CS-Script and ScriptCS and also looked here dotnet-script, but they seem not to integrate well. By that, I mean that I struggle to see an easy workflow I would use for creating, organising and running scripts. And I struggle to see that I'd remember how to use any of these if I didn't use it often.
Posted
Updated 15-Oct-18 23:58pm
Comments
Richard Deeming 16-Oct-18 10:56am    
Maybe this item in the Insider News[^] is what you're looking for? :)
Patrick Skelton 17-Oct-18 3:49am    
Yes, I saw that. It does appear to be the closest to what I had in mind. I'll give it a try when I get chance.

Thanks for the suggestion.

1 solution

This CP article might help:

Compiling C# Code at Runtime[^]

You could essentially create a CSharpScript app that loads a text file that contains C# "script" code and compile that script at runtime. You could also write pre-compiled plugins for your script runner app, and specify the DLL name on the commandline.

After doing that a couple of times, you might find that it's just easier to use powershell. :)
 
Share this answer
 
v2
Comments
Patrick Skelton 16-Oct-18 6:30am    
:)
Is it just me who has a problem with PowerShell? The syntax seems highly convoluted to me. The verb-noun bit is a good idea but it seems to go quickly downhill from there. I actually prefer the old DOS shell commands and I NEVER thought I'd say that!
#realJSOP 16-Oct-18 7:29am    
I've only used PowerShell once, and that was to unzip some files from a batch file. If it hadn't been for the security crap on our network, I wouldn't have used it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900