// ElevatedExecute Executes a shell command, requesting elevated privileges
ElevatedExecute Executes a shell command, requesting elevated privileges
// ElevatedExecute Executes a shell command requesting elevated privileges
func ElevatedExecute(binary, parameters string) error {
	var info shellExecuteInfo
	var errorCode int
	initializeExecuteInfo(&info, binary, parameters, &errorCode)
	log.Debugf("Executing %v %v with elevation", binary, parameters)
	r, _, err := shellExecuteEx.Call(uintptr(unsafe.Pointer(&info)))
	s, e := syscall.WaitForSingleObject(syscall.Handle(info.hProcess), syscall.INFINITE)
	if r == 0 && err != nil {
		return err
	}
	errorMsg := ""
	if errorCode != 0 && errorCode <= 32 {
		switch int(errorCode) {
		case errorFileNotFound:
			errorMsg = "The specified file was not found."
		case errorPathNotFound:
			errorMsg = "The specified path was not found."
		case errorBadFormat:
			errorMsg = "The .exe file is invalid (non-Win32 .exe or error in .exe image)."
		case seErrAccessDenied:
			errorMsg = "The operating system denied access to the specified file."
		case seErrAssocIncomplete:
			errorMsg = "The file name association is incomplete or invalid."
		case seErrDDEBusy:
			errorMsg = "The DDE transaction could not be completed because other DDE transactions were being processed."
		case seErrDDEFail:
			errorMsg = "The DDE transaction failed."
		case seErrDDETimeout:
			errorMsg = "The DDE transaction could not be completed because the request timed out."
		case seErrDLLNotFound:
			errorMsg = "The specified DLL was not found."
		case seErrNoAssoc:
			errorMsg = "There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable."
		case seErrOOM:
			errorMsg = "There was not enough memory to complete the operation."
		case seErrShare:
			errorMsg = "A sharing violation occurred."
		default:
			errorMsg = fmt.Sprintf("Unknown error occurred with error code %v", errorCode)
		}
		return errors.New(errorMsg)
	}
	if s == syscall.WAIT_FAILED {
		return e
	} else if s != syscall.WAIT_OBJECT_0 {
		return errors.New("Unexpected result while waiting for process to finish")
	}
	return nil
}
func ElevatedExecute ( binary , parameters string ) error { var info shellExecuteInfo var errorCode int initializeExecuteInfo ( & info , binary , parameters , & errorCode ) log . Debugf ( " " , binary , parameters ) r , _ , err := shellExecuteEx . Call ( uintptr ( unsafe . Pointer ( & info ) ) ) s , e := syscall . WaitForSingleObject ( syscall . Handle ( info . hProcess ) , syscall . INFINITE ) if r == 0 && err != nil { return err } errorMsg := " " if errorCode != 0 && errorCode <= 32 { switch int ( errorCode ) { case errorFileNotFound : errorMsg = " " case errorPathNotFound : errorMsg = " " case errorBadFormat : errorMsg = " " case seErrAccessDenied : errorMsg = " " case seErrAssocIncomplete : errorMsg = " " case seErrDDEBusy : errorMsg = " " case seErrDDEFail : errorMsg = " " case seErrDDETimeout : errorMsg = " " case seErrDLLNotFound : errorMsg = " " case seErrNoAssoc : errorMsg = " " case seErrOOM : errorMsg = " " case seErrShare : errorMsg = " " default : errorMsg = fmt . Sprintf ( " " , errorCode ) } return errors . New ( errorMsg ) } if s == syscall . WAIT_FAILED { return e } else if s != syscall . WAIT_OBJECT_0 { return errors . New ( " " ) } return nil }
ElevatedExecute Executes a shell command, requesting elevated privileges
ElevatedExecute Executes a shell command requesting elevated privileges