ITAsimo456

card_restart

Apr 15th, 2020
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <Windows.h>
  4.  
  5.  
  6. #define DEVCON_EXE "\"C:\\Program Files (x86)\\Windows Kits\\10\\Tools\\x64\\devcon.exe\""
  7. #define CARD_HWID "PCI\\VEN_10EC"
  8.  
  9.  
  10.  
  11.  
  12. #define RESTART_CMD  DEVCON_EXE " restart " CARD_HWID
  13.  
  14.  
  15. int main() {
  16.     for (int i = 0; i < 7; i++) {
  17.         printf("Testing the connection...");
  18.         // Find returns 0 if it has found the string TTL in the ping output.
  19.         // ping outputs TTL if and only if the connection works.
  20.         if (!system("ping 8.8.8.8 | find \"TTL\""))
  21.             return 1;
  22.  
  23.         printf("\nRestarting the network card...\n");
  24.         system(RESTART_CMD);
  25.         printf("\nWaiting..\n");
  26.         Sleep(10000);
  27.     }
  28.  
  29.     printf("\nFailed to get the connection working.\n");
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment