Jump to content

Archived

This topic is now archived and is closed to further replies.

H@L0_F00

[Version 1] [snippet]admin Cmd In Vista/win7

Recommended Posts

I haven't seen this posted anywhere, so I figured I'd share what I have. It doesn't use Psychosis' PsyDuck code because I want to get a feel for the stuff before I go and start using pre-coded functions and stuff (so I have somewhat of an understanding of the underlying stuff).

Anyways, this code will get you a command prompt as Administrator through the Start -> search bar

void AdminCMD(void);
void OpenStartMenu(void);
void UACRunAsAdmin(void);

void AdminCMD(void){
  OpenStartMenu();
  /*Type "cmd.exe" in search bar.*/
  usb_keyboard_press(KEY_C, 0);
  usb_keyboard_press(KEY_M, 0);
  usb_keyboard_press(KEY_D, 0);
  usb_keyboard_press(KEY_PERIOD, 0);
  usb_keyboard_press(KEY_E, 0);
  usb_keyboard_press(KEY_X, 0);
  usb_keyboard_press(KEY_E, 0);
  UACRunAsAdmin();
}


/*Run highlighted program as Administrator
*by invoking and accepting the UAC prompt.*/
void UACRunAsAdmin(void){
  /*Press CTRL+SHIFT+ENTER for UAC prompt*/
  _delay_ms(50);
  keyboard_modifier_keys = KEY_CTRL | KEY_SHIFT;
  keyboard_keys[0] = KEY_ENTER;
  usb_keyboard_send();
  _delay_ms(50);
  keyboard_modifier_keys = 0;
  keyboard_keys[0] = 0;
  usb_keyboard_send();
  _delay_ms(800); /*Time for UAC to appear*/
  /*Accept UAC prompt*/
  usb_keyboard_press(KEY_LEFT, 0);
  _delay_ms(50);
  usb_keyboard_press(KEY_ENTER, 0);
  _delay_ms(50);
}

/*Open Start Menu using CTRL+ESC instead
*of the Windows logo (KEY_GUI) because
*that key can be completely disable, while
*CTRL+ESC still works.*/
void OpenStartMenu(void){
  keyboard_modifier_keys = KEY_CTRL;
  keyboard_keys[0] = KEY_ESC;
  usb_keyboard_send();
  _delay_ms(50);
  keyboard_modifier_keys = 0;
  keyboard_keys[0] = 0;
  usb_keyboard_send();
  _delay_ms(50);
}

Share this post


Link to post
Share on other sites

For me I have to do "cmd.exe", not just "cmd". Visual Studio installation did some wierd things to my start menu search.

Share this post


Link to post
Share on other sites
For me I have to do "cmd.exe", not just "cmd". Visual Studio installation did some wierd things to my start menu search.

What're you talking about, it DOES types "cmd.exe"... ;) haha

Fixed.

Thanks.

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...