Click here to Skip to main content
15,746,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need daily save some data to archive (Json), on windows server. I can create .cmd file and it work with scheduler task, but i dont want open browser on server. How can run .cs or .vb file via .cmd file without open browser? (what could be global.asax or iis solution instead)

What I have tried:

i wrote this, into .cmd file. But it opening browser too.
start "" https://localhost:59815/JsonAdd.aspx
Updated 1-Jun-21 9:46am

Why are you trying to do this with a web application?

Just write a small console app to do the work and run that from the Windows Scheduler.
Share this answer
gacar 1-Jun-21 16:36pm    
Yes good idea but i have many dependencies in code. And i havent any experience about console applications. My code is below: is this code can write as console app?

Using dh = New IronEntities()
Dim IronKayit As List(Of insaat_Ironi) = dh.insaat_Ironi.Where(Function(x) > 0).ToList
Dim IronKayitDic As New Dictionary(Of String, Integer)
Dim dmkalinStr As String = ""
Dim dmkalin As New InsaatIroniKalinArsiv
For Each itm In IronKayit
IronKayitDic.Add(itm.bolge, itm.kalin)
dmkalinStr = dmkalinStr & ""
Select Case itm.bolge
Case "İstanbul"
dmkalin.İstanbul = itm.kalin
dmkalin.tarih = itm.tarih_tr
Case "İzmir"
dmkalin.İzmir = itm.kalin
Case "Payas"
dmkalin.Payas = itm.kalin
Case "Karabük"
dmkalin.Karabük = itm.kalin
End Select

Dim filePath = Server.MapPath("~/Content/Chart/insaat_Iron/TestKalinTum.json")
Dim jsonData = System.IO.File.ReadAllText(filePath)
Dim jsonSettings = New JsonSerializerSettings()
Dim dateConverter = New IsoDateTimeConverter With {
.DateTimeFormat = "yyyy'.'MM'.'dd"

Dim jss As New JavaScriptSerializer()
Dim dict = jss.Deserialize(Of List(Of InsaatIronKalinArsiv))(jsonData)
Dim jsonKalin As String = JsonConvert.SerializeObject(dict, jsonSettings.Converters(0))
System.IO.File.WriteAllText(filePath, jsonKalin)
End Using
Dave Kreskowiak 1-Jun-21 17:48pm    
You could, but I get the feeling you didn't break your Entity Framework code out into its own project.

Another method would be to expose a web method from your web site to do the maintenance task and call that from the command line using a variety of methods.

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