Jump to content

Admin_Popup.au3


jftuga
 Share

Recommended Posts

I just wrote this script and thought other system admins may be interested in this idea. All of our end-user XP systems are locked down tight with group policies. You can not access the C: drive, change the background, run a command prompt, install software, open the control panel, etc, etc. If we (the admins) want to do something to the machine, we have to log the current user out, log in as Administrator, do what we need to do, log out, and then have the end-user log in again. This is acceptable for some situations. However, when one of us wants to find out the computer name & IP address or get a cmd.exe prompt, it becomes a big hassle.

This is the reason I wrote Admin_Popup.au3. I compiled this to an executable which loads a system startup. There are 2 hot keys, which are intentionally hard to press as not to be accessed inadvertently:

1) ctrl alt ~

shows user information, machine name, ip address, os version, etc.

2) shift ctrl alt tab

prompts you for an Administrator password, and then runs the cmd.exe shell

I have copied / pasted the code as well as attached it.

-John

#cs

Admin_Popup
Show computer information or launch shell when hotkey is pressed
-John Taylor
May-24-2005

#ce

#include <GUICONSTANTS.au3>
#notrayicon
Opt ("GUIOnEventMode", 1)
Opt ("MustDeclareVars", 1)
Opt ("RunErrorsFatal", 0 )

Dim $Info_Title="System Info"
Dim $Shell_Title="Run Shell"
Dim $UsernameID
Dim $PasswordID
Dim $Shell_Win
Dim $_In_Shell = 0

HotKeySet("^!~", "OnInfo")        ; control alt ~
HotKeySet("+^!{TAB}", "OnShell")    ; shift control alt tab
while 1
    sleep(1000)
wend


func OnShell()
    Dim $SubmitID
    $_In_Shell = 1

    $Shell_Win = GUICreate($Shell_Title, 270, 150)
    GUISetState ()

    GUICtrlCreateLabel ("Username:", 10, 30 )
    $UsernameID = GUICtrlCreateInput ("Administrator", 65, 30, 120)

    GUICtrlCreateLabel ("Password:", 10, 60 )
    $PasswordID = GUICtrlCreateInput ("", 65, 60, 120, -1, $ES_PASSWORD)

    $SubmitID = GUICtrlCreateButton("Submit", 10, 90)
    GUICtrlSetOnEvent($SubmitID,"onsubmit")

    GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit")
    ControlFocus($Shell_Title, "", $PasswordID)

    while 1 = $_In_Shell 
        sleep(1000)
    wend

endfunc

Func onsubmit()
    Dim $u, $p
    $u = GUICtrlRead($UsernameID)
    $p = GUICtrlRead($PasswordID)
    RunAsSet( $u, "", $p, 1 )
    Run(@ComSpec, "C:\") 
    OnExit()
endfunc

Func OnExit()
    $_In_Shell = 0
;MsgBox(0,"Debug","starting OnExit()")
    GUIDelete( $Shell_Win )
endfunc

func OnInfo()

    Dim $data[15]
    Dim $i = 0
    Dim $output = ""

    $data[1] = "Computer name: " & @ComputerName
    $data[2] = "User name:" & @UserName
    $data[3] = "---------------------------------------"
    $data[4] = "1st IP: " & @IPAddress1
    $data[5] = "2nd IP: " & @IPAddress2
    $data[6] = "---------------------------------------"
    $data[7] = "OS: " & @OSVersion & "  " & @OSServicePack

    for $i = 1 to 7
        $output = $output & $data[$i] & @CR
    next
    
    MsgBox(0,$Info_Title, $output, 7)
endfunc

; end of script

Admin_Popup.au3

Link to comment
Share on other sites

Useful script/utility.. Beats having to open a command prompt and typing ipconfig /all. This could be added to a nice simple suite of hot-keyed utils..

Just a thought..

Cheers.. :(

<{POST_SNAPBACK}>

Great idea. Maybe I can add in the Netmask, Gateway and DNS Servers.

-John

Link to comment
Share on other sites

Great idea.  Maybe I can add in the Netmask, Gateway and DNS Servers.

-John

<{POST_SNAPBACK}>

jftuga, check out this post referencing a PC-info.au3 by Wb-Freekill.

http://www.autoitscript.com/forum/index.ph...=30entry82101

He is not updating it anymore as said in the thread. But if you could add this into your script as well would be !!!! GREAT !!!!

What do you think?

Cheers..

Link to comment
Share on other sites

  • 3 years later...

busysignal,

I will take a look at it.

-John

I tried using it but get the following errors. This will be useful for something I'm working on.

Admin_Popup.au3(14,26) : ERROR: Opt() called with illegal argument 1: "RunErrorsFatal"

Opt ("RunErrorsFatal", 0 )

~~~~~~~~~~~~~~~~~~~~~~~~~^

Admin_Popup.au3(41,69) : WARNING: $ES_PASSWORD: possibly used before declaration.

$PasswordID = GUICtrlCreateInput ("", 65, 60, 120, -1, $ES_PASSWORD)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Admin_Popup.au3(41,69) : ERROR: $ES_PASSWORD: undeclared global variable.

$PasswordID = GUICtrlCreateInput ("", 65, 60, 120, -1, $ES_PASSWORD)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Admin_Popup.au3(59,26) : ERROR: RunAsSet(): undefined function.

RunAsSet( $u, "", $p, 1 )

~~~~~~~~~~~~~~~~~~~~~~~~^

Admin_Popup.au3 - 3 error(s), 1 warning(s)

Link to comment
Share on other sites

I tried using it but get the following errors. This will be useful for something I'm working on.

Admin_Popup.au3(14,26) : ERROR: Opt() called with illegal argument 1: "RunErrorsFatal"
Opt ("RunErrorsFatal", 0 )
~~~~~~~~~~~~~~~~~~~~~~~~~^
Admin_Popup.au3(41,69) : WARNING: $ES_PASSWORD: possibly used before declaration.
    $PasswordID = GUICtrlCreateInput ("", 65, 60, 120, -1, $ES_PASSWORD)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Admin_Popup.au3(41,69) : ERROR: $ES_PASSWORD: undeclared global variable.
    $PasswordID = GUICtrlCreateInput ("", 65, 60, 120, -1, $ES_PASSWORD)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Admin_Popup.au3(59,26) : ERROR: RunAsSet(): undefined function.
    RunAsSet( $u, "", $p, 1 )
    ~~~~~~~~~~~~~~~~~~~~~~~~^

Admin_Popup.au3 - 3 error(s), 1 warning(s)
There have been changes made to the language since this was first posted (note that the post is from 2005). I didn't dig too deeply, but here's the code with a couple quick modifications to allow it to function with AutoIt v3.3.0.0 (not thoroughly tested, but I leave the rest to you for implementation for your usage):

CODE
#cs

Admin_Popup

Show computer information or launch shell when hotkey is pressed

-John Taylor

May-24-2005 - code modifications added to allow functionality with AutoIt v3.3.0.0 on 05 FEB 2009

#ce

#include <GUIConstantsEx.au3>

#include <EditConstants.au3>

#include <ButtonConstants.au3>

#NoTrayIcon

Opt("GUIOnEventMode", 1)

Opt("MustDeclareVars", 1)

;Opt ("RunErrorsFatal", 0 ) - parameter no longer valid as of release 3.2.12.0

Dim $Info_Title = "System Info"

Dim $Shell_Title = "Run Shell"

Dim $UsernameID

Dim $PasswordID

Dim $Shell_Win

Dim $_In_Shell = 0

HotKeySet("^!~", "OnInfo") ; control alt ~

HotKeySet("+^!{TAB}", "OnShell") ; shift control alt tab

While 1

Sleep(1000)

WEnd

Func OnShell()

Dim $SubmitID

$_In_Shell = 1

$Shell_Win = GUICreate($Shell_Title, 270, 150)

GUISetState()

GUICtrlCreateLabel("Username:", 10, 30)

$UsernameID = GUICtrlCreateInput("Administrator", 65, 30, 120)

GUICtrlCreateLabel("Password:", 10, 60)

$PasswordID = GUICtrlCreateInput("", 65, 60, 120, -1, $ES_PASSWORD)

$SubmitID = GUICtrlCreateButton("Submit", 10, 90,50,20,$BS_DEFPUSHBUTTON )

GUICtrlSetOnEvent($SubmitID, "onsubmit")

GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")

ControlFocus($Shell_Title, "", $PasswordID)

While 1 = $_In_Shell

Sleep(1000)

WEnd

EndFunc ;==>OnShell

Func onsubmit()

Dim $u, $p

$u = GUICtrlRead($UsernameID)

$p = GUICtrlRead($PasswordID)

RunAs($u,"",$p,1,@ComSpec,"C:\")

If @error Then

MsgBox(16,"Error","Unable to launch Command Prompt. Please verify the credentials used.")

EndIf

;RunAsSet($u, "", $p, 1)

;Run(@ComSpec, "C:\")

OnExit()

EndFunc ;==>onsubmit

Func OnExit()

$_In_Shell = 0

;MsgBox(0,"Debug","starting OnExit()")

GUIDelete($Shell_Win)

EndFunc ;==>OnExit

Func OnInfo()

Dim $data[15]

Dim $i = 0

Dim $output = ""

$data[1] = "Computer name: " & @ComputerName

$data[2] = "User name:" & @UserName

$data[3] = "---------------------------------------"

$data[4] = "1st IP: " & @IPAddress1

$data[5] = "2nd IP: " & @IPAddress2

$data[6] = "---------------------------------------"

$data[7] = "OS: " & @OSVersion & " " & @OSServicePack

For $i = 1 To 7

$output = $output & $data[$i] & @CR

Next

MsgBox(0, $Info_Title, $output, 7)

EndFunc ;==>OnInfo

; end of script

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...