sandman Posted August 12, 2007 Posted August 12, 2007 (edited) This is a little snippet that I just made. I got the idea from the implementation of something like apt-get called win-get, which was a pretty good idea. Now this is nowhere near as good, but it's somewhere. The bad (and maybe good) thing is that when you use the command, it opens it in a new window. Compile to su.exe and put in "C:\WINDOWS" or whatever for your OS. ; SU ; Become a super-user through CMD!! The 'su' command, kinda, for Windows. #AutoIt3Wrapper_outfile=su.exe Opt("RunErrorsFatal", 0) If $cmdline[1] = "" Then Exit Else $input = InputBox("Su", "Please enter the password for " & $cmdline[1] & ".") RunAsSet($cmdline[1], @ComputerName, $input) Run("cmd") If @error Then MsgBox(0, "Su", "Invalid username or password.") EndIf To use, for example:C:\> su AdministratorAn input box will pop up, asking you for the password. I wish I could make the prompt occur inside the CMD window, but I've no idea how. Obviously I have to put a second parameter there.. because I don't think Windows has a user similar to root by default. This can be used for installing things with administrative levels while on a limited account... or just switching into another account quickly. Happy su'ing! :) (!) (!) (!) (!) Edited August 12, 2007 by sandman [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]
sandman Posted August 13, 2007 Author Posted August 13, 2007 Any comments?? [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]
sandman Posted August 15, 2007 Author Posted August 15, 2007 Hello? Please? [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]
MadBoy Posted August 15, 2007 Posted August 15, 2007 Hello? Please?Comment hungry? It looks nice. My little company: Evotec (PL version: Evotec)
Michel Claveau Posted August 15, 2007 Posted August 15, 2007 Hi! An alternate way is to use the windows command RunAs (help: runas /?) But RunAs is not develop with AutoIt...
bluebearr Posted August 15, 2007 Posted August 15, 2007 Yeah, I would use runas if my intention was to get a command prompt:CODEC:\> runas /user:MyAdmin cmdEnter the password for MyAdmin:This will open the command window as a separate process. The first thing I usually do is run "color 4f" as my first command, just so I can easily tell that this is a "special" command prompt.You might want to also check out MakeMeAdmin. I have long wanted to make an AutoIt version of MakeMeAdmin, but haven't gotten a Round Tuit. BlueBearrOddly enough, this is what I do for fun.
BigDod Posted August 15, 2007 Posted August 15, 2007 but haven't gotten a Round Tuit. Here ya go expandcollapse popup#include <GUIConstants.au3> Opt("GUICoordMode", 1) $Form1 = GUICreate("AForm1", 400, 400, -1, -1, BitOR($WS_SYSMENU,$WS_POPUPWINDOW,$WS_BORDER), 0) GUISetBkColor(0xC0DCC0) GUICtrlCreateLabel("A Round Tuit !", 50, 40, 300, 50, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1,0xff0000) GUICtrlCreateLabel("At Long Last, we have a" & @CRLF & "sufficient quantity for each of you" & @CRLF & "to have your own. Guard it with your life." & @CRLF & "These tuits are hard to come by, especially" & @CRLF & "the round ones. This is an idespensable item." & @CRLF & "It will help you become a more efficient worker." & @CRLF & "For years we have heard people say" & @CRLF & """I'll do it as soon as I get a Round Tuit""" & @CRLF & " Now that you have a round tuit of your" & @CRLF & "very own, many things that have been" & @CRLF & "needing to be accomplished" & @CRLF & "will get done", 50, 100, 300, 250, $SS_CENTER) GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1,0xff0000) _GuiRoundCorners($Form1, 0, 0, 400, 400) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3) Dim $pos, $ret, $ret2 $pos = WinGetPos($h_win) $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3) If $ret[0] Then $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1) If $ret2[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf EndFunc;==>_GuiRoundCorners Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother
bluebearr Posted August 15, 2007 Posted August 15, 2007 A Round Tuit !Pretty. And pretty sweet. BlueBearrOddly enough, this is what I do for fun.
sandman Posted August 18, 2007 Author Posted August 18, 2007 I made this because I thought RunAs was a bit too long. And now, since I am a cross-OS guy, I only have to remember one command Also, I've been trying to make a 'sudo' command also, but I've been a bit idle in the programming sense. [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now