Potrzebuję pomocy z napisaniem kodu w C#

0

Witam, Potrzebuje pomocy z oprogramowaniem aplikacji w C#

  1. Jak zmienić tryb uruchamiania usługi systemu Windows korzystając z Process.Start("sc.exe") np. usługę Spooler Zatrzymać oraz ustawić stan uruchamiania na wyłączony
  2. Pobieranie aplikacji przy użyciu
using (WebClient webClient = new WebClient())
webClient.DownloadFile("https://kutt.it/vcppredist", @"c:\vcredist.zip");

Pojawia się błąd odnośnie bezpiecznego SSL/TLS
3) Pobieranie programu adwcleaner i uruchomienie go bez interfejsu graficznego przez cli z takimi parametrami /eula /clean /preinstalled /noreboot
4) Jak napisać kod przejęcia uprawnień (pełna kontrola) do katalogu C:\Windows\Temp dla bieżącego użytkownika
5) Wykrywanie zainstalowanej edycji Windows 10 np.Home lub pro i wywołanie slmgr.vbs /ipk XXXX-XXXX-XXXX-XXXX-XXXX

0
  1. Wpisałem w google frazę z Twojego postu Jak zmienić tryb uruchamiania usługi systemu c#. W jednym z linków znajduje się odpowiedź na pytanie 1.
  2. Wpisałem w google frazę c# webclient ssl exception. W linkach znajdziesz kilka rozwiązań na pytanie 2. Więcej z magicznej kuli nie wymyślę, bo nie podałeś jaki dokładnie błąd wyskakuje.
    Jak rozwiążesz te 2 problemy przejdziemy dalej. Jak Ci się uda wstaw kod.
    ps. Nie licz na gotowce, wykaż jakąś inicjatywę a na pewno Cię nie zostawimy na pastwę kodu
0

Błąd nr 2 rozwiązany
Błąd nr 1 moja składnia sc wygląda tak

Process.Start("sc.exe", "config [XboxGipSvc] state= disabled");

może powiecie gdzie mam błąd próbowałem różnych wariantów tej składni

0

\sc.exe
Parameters:
stop MyService
delete MyService
start MyService
create MyService

lub bezpośrednio w kodzie przy pomocy ServiceController. Poczytaj o tej klasie

0

Usługi ogarnięte (rozwiązałem to przez modyfikowanie klucza rejestru)
punkt 3 rozwiązany

Pozostał tylko punkt 4 oraz 5

0
  1. OSVersionInfo, Edition i Version
1

Pkt 4. Nie ma czegoś takiego jak nadanie uprawnień aplikacji do katalogu. Możesz nadac aplikacji uprawnienia dowolnego użytkownika, a ten użytkownik ma dostęp do katalogu. Poczytaj o UAC

0

Mam problem z usługami ktoś powie co jest źle

           RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\AarSvc", true);
            key.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key1 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\ALG", true);
            key1.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key2 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\AppHostSvc", true);
            key2.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key3 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\AppMgmt", true);
            key3.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key4 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\autotimesvc", true);
            key4.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key5 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\AxInstSV", true);
            key5.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key6 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\BITS", true);
            key6.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key7 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\CaptureService", true);
            key7.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key8 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\cbdhsvc", true);
            key8.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key9 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\CertPropSvc", true);
            key9.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key10 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\ClipSVC", true);
            key10.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key11 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\COMSysApp", true);
            key11.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key12 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\CscService", true);
            key12.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key13 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\dmwappushservice", true);
            key13.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key14 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\DoSvc", true);
            key14.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key15 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\DsSvc", true);
            key15.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key16 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\DsmSvc", true);
            key16.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key17 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\EFS", true);
            key17.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key18 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\EntAppSvc", true);
            key18.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key19 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\Fax", true);
            key19.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key20 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\fhsvc", true);
            key20.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key21 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\FontCache", true);
            key21.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key22 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\FontCache3.0.0.0", true);
            key22.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key23 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\icssvc", true);
            key23.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key24 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\InstallService", true);
            key24.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key25 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\HvHost", true);
            key25.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key26 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\KtmRm", true);
            key26.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key27 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\lfsvc", true);
            key27.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key28 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\LicenseManager", true);
            key28.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key29 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\lltdsvc", true);
            key29.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key30 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\LxpSvc", true);
            key30.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key31 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\MessagingService", true);
            key31.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key32 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\MSDTC", true);
            key32.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key33 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\MSiSCSI", true);
            key33.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key34 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\MSMQ", true);
            key34.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key35 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\NcaSvc", true);
            key35.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key36 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\NcbService", true);
            key36.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key37 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\Netlogon", true);
            key37.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key38 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\NetMsmqActivator", true);
            key38.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key39 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\NetPipeActivator", true);
            key39.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key40 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\NetTcpActivator", true);
            key40.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key41 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\NetTcpPortSharing", true);
            key41.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key42 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\NgcSvc", true);
            key42.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key43 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\OneSyncSvc", true);
            key43.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key44 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\ose", true);
            key44.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key45 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\osppsvc", true);
            key45.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key46 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\PcaSvc", true);
            key46.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key47 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\PhoneSvc", true);
            key47.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key48 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\PimIndexMaintenanceSvc", true);
            key48.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key49 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\pla", true);
            key49.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key50 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\PushToInstall", true);
            key50.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key51 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\RemoteRegistry", true);
            key51.SetValue("Start", 4, RegistryValueKind.DWord);
            RegistryKey key52 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\RetailDemo", true);
            key52.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key53 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\RpcLocator", true);
            key53.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key54 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\SCardSvr", true);
            key54.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key55 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\ScDeviceEnum", true);
            key55.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key56 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\SCPolicySvc", true);
            key56.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key57 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\SDRSVC", true);
            key57.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key58 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\seclogon", true);
            key58.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key59 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\SEMgrSvc", true);
            key59.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key60 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\SENS", true);
            key60.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key61 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\SgrmBroker", true);
            key61.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key62 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\SharedAccess", true);
            key62.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key63 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\smphost", true);
            key63.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key64 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\SmsRouter", true);
            key64.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key65 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\SNMPTRAP", true);
            key65.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key66 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\svsvc", true);
            key66.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key67 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\StorSvc", true);
            key67.SetValue("Start", 3, RegistryValueKind.DWord);
            Process.Start("sc.exe", "Start StorSvc");
            RegistryKey key68 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\swprv", true);
            key68.SetValue("Start", 3, RegistryValueKind.DWord);
            Process.Start("sc.exe", "Start swprv");
            RegistryKey key69 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\stisvc", true);
            key69.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key70 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\TabletInputService", true);
            key70.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key71 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\TrkWks", true);
            key71.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key72 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\TroubleshootingSvc", true);
            key72.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key73 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\tzautoupdate", true);
            key73.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key74 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\UevAgentService", true);
            key74.SetValue("Start", 4, RegistryValueKind.DWord);
            RegistryKey key75 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\UnistoreSvc", true);
            key75.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key76 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\UserDataSvc", true);
            key76.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key77 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\UsoSvc", true);
            key77.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key78 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\vmicguestinterface", true);
            key78.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key79 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\vmicheartbeat", true);
            key79.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key80 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\vmickvpexchange", true);
            key80.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key81 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\vmicrdv", true);
            key81.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key82 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\vmicshutdown", true);
            key82.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key83 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\vmictimesync", true);
            key83.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key84 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\vmicvmsession", true);
            key84.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key85 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\vmicvss", true);
            key85.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key86 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\w3logsvc", true);
            key86.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key87 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WaaSMedicSvc", true);
            key87.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key88 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WalletService", true);
            key88.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key89 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WAS", true);
            key89.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key90 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WarpJITSvc", true);
            key90.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key91 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\wbengine", true);
            key91.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key92 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WerSvc", true);
            key92.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key93 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WiaRpc", true);
            key93.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key94 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WinRM", true);
            key94.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key95 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\wisvc", true);
            key95.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key96 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\wlidsvc", true);
            key96.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key97 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\wmiApSrv", true);
            key97.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key98 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WMPNetworkSvc", true);
            key98.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key99 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WPDBusEnum", true);
            key99.SetValue("Start", 3, RegistryValueKind.DWord);
            Process.Start("sc.exe", "Start WPDBusEnum");
            RegistryKey key100 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WpnService", true);
            key100.SetValue("Start", 3, RegistryValueKind.DWord);
            Process.Start("sc.exe", "Start WpnService");
            RegistryKey key101 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WpnUserService", true);
            key101.SetValue("Start", 4, RegistryValueKind.DWord);
            RegistryKey key102 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\wscsvc", true);
            key102.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key103 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\WSearch", true);
            key103.SetValue("Start", 2, RegistryValueKind.DWord);
            RegistryKey key104 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\wuauserv", true);
            key104.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key105 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\XboxGipSvc", true);
            key105.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key106 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\XblAuthManager", true);
            key106.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key107 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\XblGameSave", true);
            key107.SetValue("Start", 3, RegistryValueKind.DWord);
            RegistryKey key108 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\xboxgip", true);
            key108.SetValue("Start", 3, RegistryValueKind.DWord);
       MessageBox.Show("Usługi ustawione na tryb Bezpieczny");
            Process.Start("shutdown.exe", "-r -t 10");

Gdy w ten sposób robię usługę np. Bufor Wydruku to wszystko działa poprawnie a tu wyskakuje :
Bez tytułu.jpg

0

To oznacza, że jedno z Twoich miliardów opensubkey zwróciło null a Ty próbujesz mu ustawić Value. Co ten kod ma wspólnego z usługami? Co próbujesz osiągnąć?

0

Zmodyfikować start usług na taki jak domyślnie a nie chce korzystać z importu pliku rejestru
W tym kluczu znajdują się wszystkie usługi systemu Windows

2

Któraś z twoich ścieżek w rejestrze nie daje się otworzyć i dostajesz null jako wynik OpenSubKey - a potem próbujesz na nullu zrobić jakieś rzeczy.

Ale ogólnie to robisz bardzo złe podejście, bo tworzysz sobie setkę zmiennych, a wystarczyła by jedna - i najlepiej jakaś pętla, aby skrócić trochę tego kodu. Duplikowanie kodu ogólnie jest zazwyczaj niezbyt dobrym rozwiązaniem.

Na przykład coś takiego:

var services = new List<string> { "AarSvc", "ALG", "AppHostSvc" }; // i tutaj wszystkie nazwy usług w Rejestrze

foreach (var item in services)
{
    var key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\" + item, true);
    if (key != null) // jeśli nie istnieje, to zignoruj
        key.SetValue("Start", 3, RegistryValueKind.DWord);
}

I tylko musisz sobie jakoś specjalnie obsłużyć te przypadki gdzie robisz dodatkowe operacje w rodzaju uruchamiania procesu albo ustawiasz nie na 3, ale na 2 czy tam 4 - ale tego to będzie już tylko kilka, a nie setka.

0

Jasne rozumiem dzięki za sugestię

0

@Ktos:
Niestety problem nadal występuje

0

Czy gdzieś tu jest błąd ?

var services = new List<string> { "AarSvc", "ALG", "AppHostSvc", "autotimesvc", "AxInstSV", "BITS", "CaptureService", "cbdhsvc", "CertPropSvc", "ClipSVC", "COMSysApp", "CscService", "dmwappushservice", "DoSvc", "DsSvc", "DsmSvc", "EFS", "EntAppSvc", "Fax", "fhsvc", "FontCache", "FontCache3.0.0.0", "icssvc", "InstallService", "HvHost", "KtmRm", "lfsvc", "LicenseManager", "lltdsvc", "LxpSvc", "MessagingService", "MSDTC", "MSiSCSI", "MSMQ", "NcaSvc", "NcbService", "Netlogon", "NetMsmqActivator", "NetPipeActivator", "NetTcpActivator", "NetTcpPortSharing", "NgcSvc", "OneSyncSvc", "ose", "osppsvc", "PcaSvc", "PhoneSvc", "PimIndexMaintenanceSvc", "pla", "PushToInstall", "RemoteRegistry", "RetailDemo", "RpcLocator", "SCardSvr", "ScDeviceEnum", "SCPolicySvc", "SDRSVC", "seclogon", "SEMgrSvc", "SENS", "SgrmBroker", "SharedAccess", "smphost", "SmsRouter", "SNMPTRAP", "svsvc", "StorSvc", "swprv", "stisvc", "TabletInputService", "TrkWks", "TroubleshootingSvc", "tzautoupdate", "UevAgentService", "UnistoreSvc", "UserDataSvc", "UsoSvc", "vmicguestinterface", "vmicheartbeat", "vmickvpexchange", "vmicrdv", "vmicshutdown", "vmictimesync", "vmicvmsession", "vmicvss", "w3logsvc", "WaaSMedicSvc", "WalletService", "WAS", "WarpJITSvc", "wbengine", "WerSvc", "WiaRpc", "WinRM", "wisvc", "wlidsvc", "wmiApSrv", "WMPNetworkSvc", "WPDBusEnum", "WpnService", "WpnUserService", "wscsvc", "WSearch", "wuauserv", "XboxGipSvc", "XblAuthManager", "XblGameSave", "xboxgip" }; // i tutaj wszystkie nazwy usług w Rejestrze

            foreach (var item in services)
            {
                var key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\" + item, true);
                if (key != null) // jeśli nie istnieje, to zignoruj
                    key.SetValue("Start", 4, RegistryValueKind.DWord);
            }
            MessageBox.Show("Usługi ustawione na tryb Ekstremalny");
            Process.Start("shutdown.exe", "-r -t 10");
0

@obscurity:
To druga funkcja która ma wszystko ustawić na Disable błąd jest taki sam jak wyżej do momentu gdy nie dopisałem dodatkowej usługi do kodu @Ktos wszystko działało a dopisanie usługi powoduje problem (nie ważne jaką dopiszę i tak przestaje działać) Nazwy usług zostały wyeksportowane z czystej wersji Systemu Windows

0

ale jaki błąd, w której linijce kodu? Jak odpalasz z debugera to Ci się podświetli i będziesz wiedział co jest nullem. Jak nie możesz z debuggera to chociaż skopiuj pliki .pdb i skopiuj tu treść błędu a nie rób screenshota kawałka

0

Znalazłem problematyczną usługę zaczyna funkcjonować

var services = new List<string> { "AarSvc", "ALG", "AppHostSvc", "autotimesvc", "CaptureService", "cbdhsvc", "CertPropSvc", "ClipSVC", "COMSysApp", "CscService", "dmwappushservice", "DoSvc", "DsSvc", "DsmSvc", "EFS", "EntAppSvc", "Fax", "fhsvc", "FontCache3.0.0.0", "icssvc", "InstallService", "HvHost", "KtmRm", "lfsvc", "LicenseManager", "lltdsvc", "LxpSvc", "MessagingService", "MSDTC", "MSiSCSI", "MSMQ", "NcaSvc", "NcbService", "Netlogon", "NetMsmqActivator", "NetPipeActivator", "NetTcpActivator", "NetTcpPortSharing", "NgcSvc", "ose", "osppsvc", "PhoneSvc", "PimIndexMaintenanceSvc", "pla", "PushToInstall", "RetailDemo", "RpcLocator", "SCardSvr", "ScDeviceEnum", "SCPolicySvc", "SDRSVC", "seclogon", "SEMgrSvc", "SENS", "SgrmBroker", "SharedAccess", "smphost", "SmsRouter", "SNMPTRAP", "svsvc", "StorSvc", "swprv", "TabletInputService", "TroubleshootingSvc", "tzautoupdate", "UnistoreSvc", "UserDataSvc", "UsoSvc", "vmicguestinterface", "vmicheartbeat", "vmickvpexchange", "vmicrdv", "vmicshutdown", "vmictimesync", "vmicvmsession", "vmicvss", "w3logsvc", "WaaSMedicSvc", "WalletService", "WAS", "WarpJITSvc", "wbengine", "WerSvc", "WiaRpc", "WinRM", "wisvc", "wlidsvc", "wmiApSrv", "WMPNetworkSvc", "WPDBusEnum", "WpnService", "wuauserv", "XboxGipSvc", "XblAuthManager", "XblGameSave", "xboxgip" }; // i tutaj wszystkie nazwy usług w Rejestrze

            foreach (var item in services)
            {
                var key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\" + item, true);
                if (key != null) // jeśli nie istnieje, to zignoruj
                    key.SetValue("Start", 3, RegistryValueKind.DWord);
            }
            var bezpieczne = new List<string> { "OneSyncSvc", "PcaSvc", "BITS", "stisvc", "TrkWks", "wscsvc", "WSearch" };
            foreach (var item in bezpieczne)
            {
                var key1 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\" + item, true);
                if (key1 != null)
                    key1.SetValue("Start", 2, RegistryValueKind.DWord);
            }
            MessageBox.Show("Usługi ustawione na tryb Bezpieczny");
            Process.Start("shutdown.exe", "-r -t 10");

W jaki sposób to połączyć aby funkcjonowało że część ustawia na 3 a część na 2 bo opcja wszystko na wyłączone działa już dobrze

0

@kamiloxf:

W jaki sposób to połączyć aby funkcjonowało że część ustawia na 3 a część na 2 bo opcja wszystko na wyłączone działa już dobrze

Zrób metodę która przyjmie listę usług i stan do ustawienia:

void SetServicesStartMode(IEnumerable<string> services, int state)
{
    foreach (var item in services)
    {
        using (var key = Registry.LocalMachine.OpenSubKey($@"SYSTEM\ControlSet001\Services\{item}", true))
            key?.SetValue("Start", state, RegistryValueKind.DWord);
    }
}

i potem tylko wywołuj

            SetServicesStartMode(new[] { "AarSvc", "ALG", "AppHostSvc", "autotimesvc", "CaptureService", "cbdhsvc", "CertPropSvc", "ClipSVC", "COMSysApp", "CscService", "dmwappushservice", "DoSvc", "DsSvc", "DsmSvc", "EFS", "EntAppSvc", "Fax", "fhsvc", "FontCache3.0.0.0", "icssvc", "InstallService", "HvHost", "KtmRm", "lfsvc", "LicenseManager", "lltdsvc", "LxpSvc", "MessagingService", "MSDTC", "MSiSCSI", "MSMQ", "NcaSvc", "NcbService", "Netlogon", "NetMsmqActivator", "NetPipeActivator", "NetTcpActivator", "NetTcpPortSharing", "NgcSvc", "ose", "osppsvc", "PhoneSvc", "PimIndexMaintenanceSvc", "pla", "PushToInstall", "RetailDemo", "RpcLocator", "SCardSvr", "ScDeviceEnum", "SCPolicySvc", "SDRSVC", "seclogon", "SEMgrSvc", "SENS", "SgrmBroker", "SharedAccess", "smphost", "SmsRouter", "SNMPTRAP", "svsvc", "StorSvc", "swprv", "TabletInputService", "TroubleshootingSvc", "tzautoupdate", "UnistoreSvc", "UserDataSvc", "UsoSvc", "vmicguestinterface", "vmicheartbeat", "vmickvpexchange", "vmicrdv", "vmicshutdown", "vmictimesync", "vmicvmsession", "vmicvss", "w3logsvc", "WaaSMedicSvc", "WalletService", "WAS", "WarpJITSvc", "wbengine", "WerSvc", "WiaRpc", "WinRM", "wisvc", "wlidsvc", "wmiApSrv", "WMPNetworkSvc", "WPDBusEnum", "WpnService", "wuauserv", "XboxGipSvc", "XblAuthManager", "XblGameSave", "xboxgip" }, 3);

            SetServicesStartMode(new[] { "OneSyncSvc", "PcaSvc", "BITS", "stisvc", "TrkWks", "wscsvc", "WSearch" }, 2);

            MessageBox.Show("Usługi ustawione na tryb Bezpieczny");
            Process.Start("shutdown.exe", "-r -t 10");
0

@obscurity: twój kod nie dokonuje zmian

Kod który podesłałem wcześniej wygląda że dokonuje zmiany jednak pojawia się informacja "Aplikacja próbowała dokonać operacje niedozwoloną przez zasady zabezpieczeń "
przez co nie pojawia się MsgBox oraz nie następuje restart

1

wiesz że nie musisz używać fragmentów kodu znalezionego w Internecie 1:1 tylko możesz pomyśleć i samemu coś pozmieniać?
Jeśli ten kod nie działa - nie testowałem, dodałem "using" bo OpenSubKey zwraca obiekt IDisposable i powinno się go zamknąć metodą Close. Być może zamknięcie jest niezbędne przed Dispose.
W każdym razie przedstawiłem tylko ideę jak wyekstraktować metodę i jej użyć. Pozwalam na modyfikację.

Skoro dostajesz alert zabezpieczeń to prawdopodobnie nie możesz się w ten sposób bawić rejestrem tylko musisz się dogadać z systemem. Uruchamiasz ją z uprawnieniami administratora? Zapewne powinieneś użyć ServiceController https://docs.microsoft.com/en-us/dotnet/api/system.serviceprocess.servicecontroller?view=dotnet-plat-ext-5.0 zamiast grzebać w rejestrze. Tu chyba masz gotowe rozwiązanie https://www.codeproject.com/Articles/7665/Extend-ServiceController-class-to-change-the-Start

0

Tak jest uruchamiany z Uprawnieniami administratora głównym problemem jest pewnie to że coś źle połączyłem bo w C# to jestem amatorem
ponieważ gdy jest tylko jeden var zadeklarowany to działa poprawnie bez komunikatu

0

wszystko jest dobrze połączone tylko zapewne dotknąłeś jakiejś usługi systemowej która jest chroniona. Musisz poszukać jak wyłączyć te zasady zabezpieczeń

0

Jeżeli Ci się nie uda zawsze możesz uruchomić Ubuntu z pendrive i edytować plik ini rejestru 😁

0

Nie z tego powodu chce napisać sobie program który pozwalałby na przełączanie trybu usług kliknięciem by modyfikować Rejestr z LiveCD

Zastanawiające jest tylko to że na stan= Wyłączona mogłem to zrobić bez komunikatu ale przywrócić stan domyślny jaki ma system to problem z zabezpieczeniami chyba bardziej MS powinien chronić przed wyłączeniem podobnie jak defendera

1 użytkowników online, w tym zalogowanych: 0, gości: 1