mbkowns Posted April 11, 2008 Posted April 11, 2008 Is it possible to run multiple things in the same command window without having to run a batch file? I have many admins that need to get removed as part of a larger script but I would like instead of a CMD window created for each that one could be opened and execute multiple lines. RunWait("net localgroup administrators " & '"domain\siteadmin1"' & " /delete", "",@SW_HIDE) RunWait("net localgroup administrators " & '"domain\siteadmin2"' & " /delete", "",@SW_HIDE) RunWait("net localgroup administrators " & '"domain\siteadmin3"' & " /delete", "",@SW_HIDE) RunWait("net localgroup administrators " & '"domain\siteadmin12"' & " /delete", "",@SW_HIDE) RunWait("net localgroup administrators " & '"domain\siteadmin22"' & " /delete", "",@SW_HIDE) RunWait("net localgroup administrators " & '"domain\siteadmin78" & " /delete", "",@SW_HIDE) more need to be remove just an example. Let me know if that is possible. Work around now would be to fileinstall() batch file to c:\ and delete it after it is run but it would be nice if this worked without having to do that. thanks
LarryDalooza Posted April 11, 2008 Posted April 11, 2008 As the windows are hidden, I don't see a problem with multiple calls ... just make a function so that it is easier to code... is there speed or something that concerns you? DeleteDomUser("domain\siteadmin2") DeleteDomUser("domain\siteadmin3") DeleteDomUser("domain\siteadmin4") DeleteDomUser("domain\siteadmin5") DeleteDomUser("domain\siteadmin6") Func DeleteDomUser($user) RunWait("net localgroup administrators " & $user & " /delete", "",@SW_HIDE) EndFunc Lar. AutoIt has helped make me wealthy
wraithdu Posted April 11, 2008 Posted April 11, 2008 (edited) You could also try something like - #include "Constants.au3" Dim $line $pid = Run("cmd", "", "", $STDIN_CHILD + $STDOUT_CHILD) StdinWrite($pid, "dir" & @CRLF) StdinWrite($pid, "exit" & @CRLF) While 1 $line = $line & StdoutRead($pid) If @error Then ExitLoop WEnd MsgBox(0, "Stdout", $line) ProcessClose($pid) Exit Edited April 11, 2008 by wraithdu
spudw2k Posted April 11, 2008 Posted April 11, 2008 (edited) If you really want to "stack" a bunch of commands, you can use && to separate them and it will run them in sequence. For example. Open a CMD prompt and type in 'ipconfig && dir c:\ && echo "My Hostname Is" && hostname' (no single quotes) But there isn't anything wrong with Larry's idea of making a function. You could even make an array of "userids" and loop through it call the DelDomUser func. Edited April 11, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
mbkowns Posted April 11, 2008 Author Posted April 11, 2008 Thanks for the quick help. It doesn't take very long to do it even doing ones that don't exist. went with this while I was waiting like all the other ideas might change to those as well. Func _RemoveAllAdmins() For $rAdmin = 0 To 9 $zrAdmin = "0" & $rAdmin RunWait("net localgroup administrators " & '"67-nis\sitealtirisadmin' & $zrAdmin & '"' & " /delete", "", @SW_HIDE) RunWait("net localgroup administrators " & '"67-nis\sitepcadmin' & $zrAdmin & '"' & " /delete", "", @SW_HIDE) Next For $rAdmin = 10 To 100 RunWait("net localgroup administrators " & '"67-nis\sitealtirisadmin' & $rAdmin & '"' & " /delete", "", @SW_HIDE) RunWait("net localgroup administrators " & '"67-nis\sitepcadmin' & $rAdmin & '"' & " /delete", "", @SW_HIDE) Next EndFunc ;==>_RemoveAllAdmins
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