.Net core windows service self update

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Onaylı Üye
Katılım
8 Eki 2017
Mesajlar
134
Tepki puanı
12
Ödüller
5
8 HİZMET YILI
Merhabalar, .net core ile bir windows hizmeti yazdım. Bu hizmet güncelleme geldiği zaman dosyaları bir dizine indirip bir adet .bat dosyası oluşturup içerisinde ise şu kodları yazıyor;
Batch:
@echo off

net stop "My update service"

xcopy "C:\source" "C:\MyService"

net start "My update service"

pause

dosya işlemleri bittikten sonra şu kodu çalıştırıyorum;
C#:
using (Process myProcess = new Process())
{
    myProcess.StartInfo.UseShellExecute = true;
    myProcess.StartInfo.FileName = @"C:\update.bat";
    myProcess.StartInfo.CreateNoWindow = true;
    myProcess.StartInfo.Verb = "runas";
    myProcess.Start();
}

Fakat burada şu hata ortaya çıkıyor, windows hizmeti yönetici olarak çalıştıramıyor ve update.bat dosyası çalışmıyor.
UAC bypass yaparak bu sorunu çözüyordum fakat yamalar ile o açık kapatılmış sanırım artık çalışmıyor.

Bu sorunu nasıl çözebilirim? Windows hizmeti içerisinden bir process'i yönetici olarak çalıştıracağım.
İyi forumlar.
 
Onaylı Üye
Katılım
8 Eki 2017
Mesajlar
134
Tepki puanı
12
Ödüller
5
8 HİZMET YILI
Hello, I wrote a windows service with .net core. When the update comes, this service downloads the files to a directory, creates a .bat file and writes the following codes in it;
Batch:
@echo off

net stop "My update service"

xcopy "C:\source" "C:\MyService"

net start "My update service"

pause

After the file operations are finished, I run the following code;

C#:
using (Process myProcess = new Process())
{
    myProcess.StartInfo.UseShellExecute = true;
    myProcess.StartInfo.FileName = @"C:\update.bat";
    myProcess.StartInfo.CreateNoWindow = true;
    myProcess.StartInfo.Verb = "runas";
    myProcess.Start();
}

But here the following error appears, windows cannot run the service as administrator and the update.bat file does not work.
I was solving this problem by bypassing the UAC, but I guess it was turned off with patches, it doesn't work anymore.

How can I solve this problem? I will run a process as administrator from within the windows service.
Good forums.
 
Onaylı Üye
Katılım
7 Ocak 2023
Mesajlar
62
Tepki puanı
9
Ödüller
1
Yaş
34
3 HİZMET YILI
Merhabalar, .net core ile bir windows hizmeti yazdım. Bu hizmet güncelleme geldiği zaman dosyaları bir dizine indirip bir adet .bat dosyası oluşturup içerisinde ise şu kodları yazıyor;
Batch:
@echo off

net stop "My update service"

xcopy "C:\source" "C:\MyService"

net start "My update service"

pause

dosya işlemleri bittikten sonra şu kodu çalıştırıyorum;
C#:
using (Process myProcess = new Process())
{
    myProcess.StartInfo.UseShellExecute = true;
    myProcess.StartInfo.FileName = @"C:\update.bat";
    myProcess.StartInfo.CreateNoWindow = true;
    myProcess.StartInfo.Verb = "runas";
    myProcess.Start();
}

Fakat burada şu hata ortaya çıkıyor, windows hizmeti yönetici olarak çalıştıramıyor ve update.bat dosyası çalışmıyor.
UAC bypass yaparak bu sorunu çözüyordum fakat yamalar ile o açık kapatılmış sanırım artık çalışmıyor.

Bu sorunu nasıl çözebilirim? Windows hizmeti içerisinden bir process'i yönetici olarak çalıştıracağım.
İyi forumlar.
top you script
 
Just KinG
Seçkin Üye
Katılım
1 Tem 2022
Mesajlar
569
Tepki puanı
51
Ödüller
4
Sosyal
3 HİZMET YILI
explain more i cannot understand sorry
 
Ultra Üye
Katılım
16 Kas 2022
Mesajlar
1,510
Çözümler
1
Tepki puanı
65
Ödüller
5
3 HİZMET YILI
Merhabalar, .net core ile bir windows hizmeti yazdım. Bu hizmet güncelleme geldiği zaman dosyaları bir dizine indirip bir adet .bat dosyası oluşturup içerisinde ise şu kodları yazıyor;
Batch:
@echo off

net stop "My update service"

xcopy "C:\source" "C:\MyService"

net start "My update service"

pause

dosya işlemleri bittikten sonra şu kodu çalıştırıyorum;
C#:
using (Process myProcess = new Process())
{
    myProcess.StartInfo.UseShellExecute = true;
    myProcess.StartInfo.FileName = @"C:\update.bat";
    myProcess.StartInfo.CreateNoWindow = true;
    myProcess.StartInfo.Verb = "runas";
    myProcess.Start();
}

Fakat burada şu hata ortaya çıkıyor, windows hizmeti yönetici olarak çalıştıramıyor ve update.bat dosyası çalışmıyor.
UAC bypass yaparak bu sorunu çözüyordum fakat yamalar ile o açık kapatılmış sanırım artık çalışmıyor.

Bu sorunu nasıl çözebilirim? Windows hizmeti içerisinden bir process'i yönetici olarak çalıştıracağım.
İyi forumlar.
this works for windows 11? im interested
 
Onaylı Üye
Katılım
8 Ocak 2022
Mesajlar
53
Tepki puanı
0
Ödüller
2
Yaş
49
4 HİZMET YILI
bence direk format kesin çözüm vakit kaybı çözümü aramak windows çok karışık :(
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst