JonCross Posted November 9, 2007 Share Posted November 9, 2007 (edited) I am writing a script that will remove all of the default users in the Administrators group on my computer. The problem is that there are well over 100 users the advantage (i hope is that they are all similar). The users look like Domain\sitepcadminXX and where the XX is represents a number from 00 - 99. My office is 89 and only needs to have Domain\sitepcadmin89 so I want to remove the rest. My code started to look like: Run(@ComSpec & " /c " & 'Net localgroup Administrators 67-nis\sitepcadmin00' '/delete', "", @SW_HIDE) But then I didnt want to have to create the same string over and over 100 times. Is there a wild card feature (*) that can be used in the place of 00? Suggestions? Thanks, Jon Cross Edited November 10, 2007 by JonCross Link to comment Share on other sites More sharing options...
picaxe Posted November 10, 2007 Share Posted November 10, 2007 For $i = 0 To 99 Run(@ComSpec & " /c " & 'Net localgroup Administrators 67-nis\sitepcadmin' & StringFormat("%.2u", $i) & ' /delete', "", @SW_HIDE) Next Link to comment Share on other sites More sharing options...
JonCross Posted November 10, 2007 Author Share Posted November 10, 2007 For $i = 0 To 99 Run(@ComSpec & " /c " & 'Net localgroup Administrators 67-nis\sitepcadmin' & StringFormat("%.2u", $i) & ' /delete', "", @SW_HIDE) Next Ok, So I am not at work any more I created some test users user1, user2, user3. I tried the code: For $i = 0 To 9 Run(@ComSpec & " /c " & 'Net LocalGroup Administrators user'&StringFormat("%.2u",$i)&' /delete', "", @SW_HIDE) Next Exit it runs with no errors but the users are still in the group. Link to comment Share on other sites More sharing options...
picaxe Posted November 10, 2007 Share Posted November 10, 2007 (edited) Ok, So I am not at work any more I created some test users user1, user2, user3. I tried the code: For $i = 0 To 9 Run(@ComSpec & " /c " & 'Net LocalGroup Administrators user' &StringFormat("%.2u",$i) & ' /delete', "", @SW_HIDE) Next ExitoÝ÷ Ûú®¢×¢·¦¢÷®±êô¶¬z¿n²)à¶Å©©ç(u殶sdf÷"b33c¶ÒFò¢'Vâ6öÕ7V2fײgV÷C²ö2gV÷C²fײb33´æWBÆö6Äw&÷WFÖæ7G&F÷'2W6W"b33²fײ7G&ætf÷&ÖBgV÷C²RãRgV÷C²Âb33c¶fײb33²öFVÆWFRb33²ÂgV÷C²gV÷C²Â5uôDR¤æW@¤WoÝ÷ ØçÜ¢êì{^éîêÚ¶)à¢yr²)àçb+ljëh×6For $i = 0 To 9 Run(@ComSpec & " /c " & 'Net LocalGroup Administrators user' & $i & ' /delete', "", @SW_HIDE) Next ExitoÝ÷ ØZ+¶¨®("©r¢ë!¢é]¦ºi¹rºÇºuا²×vѺv®¶sdf÷"b33c¶ÒFò¢'VåvB6öÕ7V2fײgV÷C²ö2gV÷C²fײb33´æWBÆö6Æw&÷WFÖæ7G&F÷'2crÖæ2b3#·6FW6FÖâb33²fײ7G&ætf÷&ÖBgV÷C²Rã'RgV÷C²Âb33c¶fײb33²öFVÆWFRb33²ÂgV÷C²gV÷C²Â5uôDR¤æW Edited November 10, 2007 by picaxe Link to comment Share on other sites More sharing options...
JonCross Posted November 13, 2007 Author Share Posted November 13, 2007 OK, so that part is done. I am having a problem with another part. The Entire Script:;~ MsgBox (0, "RUSD Account Setup", "This application will insure that the Local Account Configuration.", 10) ;~ _NetUser('installer', '*************') ;~ Func _NetUser($name, $password = '', $groupname = 'Administrators') ;~ Local $key ;~ If Not FileExists(EnvGet('AllUsersProfile') & '\..\' & $name) Then ;~ RunWait(@ComSpec & ' /c ' & _ ;~ 'Net User ' & $name & ' ' & $password & ' /add /passwordchg:NO &&' & _ ;~ 'Net LocalGroup ' & $groupname & ' ' & $name & ' /add &' & _ ;~ 'Net Accounts /MaxPwAge:UnLimited', '', @SW_HIDE) ;~ EndIf ;~ EndFunc ;~ MsgBox (0, "Step 1...", "Installer Account installed", 10) ;~ Run(@ComSpec & " /c " & 'Net User setup /delete', "", @SW_HIDE) ;~ MsgBox (0, "Step 2...", "Setup Account Deleted", 10) ;~ For $i = 00 To 99 ;~ RunWait(@ComSpec & " /c " & 'Net localgroup Administrators 67-nis\sitepcadmin' & StringFormat("%.2u", $i) & ' /delete', "", @SW_HIDE) ;~ Next ;~ MsgBox (0, "Step 3...", "All SitePCAdminXX Account Removed", 10) $SiteID = Inputbox("Site ID" , "Please Enter Site 2 digit Number.", "", " M2") _NetLocalGroup('67-nis\SitePCAdmin'&$SiteID) _NetLocalGroup('67-nis\SiteAltirisAdmin'&$SiteID) _NetLocalGroup('67-nis\SitePCAdmin67') _NetLocalGroup('67-nis\SiteAltirisAdmin67') Func _NetLocalGroup($AdminName = '') RunWait(@ComSpec & " /c " & "Net LocalGroup Administrators "& $AdminName &" /add &", @SW_HIDE) EndFunc ;~ MsgBox (0, "Step 4...", "SitePCAdmin"&$SiteID &" and SiteAltirisAdmin"&$SiteID &" are Installed.", 10) The Error that I get when I run the selected portion is: C:\Documents and Settings\jcross.67-NIS\My Documents\AutoIT\Local Administrators Group\AdministratorGroup.au3 (25) : ==> Unable to execute the external program.: RunWait(@ComSpec & " /c " & "Net LocalGroup Administrators "& $AdminName &" /add &", @SW_HIDE) The directory name is invalid. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 13, 2007 Share Posted November 13, 2007 The Error that I get when I run the selected portion is:C:\Documents and Settings\jcross.67-NIS\My Documents\AutoIT\Local Administrators Group\AdministratorGroup.au3 (25) : ==> Unable to execute the external program.: RunWait(@ComSpec & " /c " & "Net LocalGroup Administrators "& $AdminName &" /add &", @SW_HIDE) The directory name is invalid.You have @SW_HIDE where the temp directory belongs. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JonCross Posted November 13, 2007 Author Share Posted November 13, 2007 Doh, Thanks. Link to comment Share on other sites More sharing options...
JonCross Posted November 13, 2007 Author Share Posted November 13, 2007 Ok, last thing. This one I have no Idea about. In this portion of the Code: For $i = 00 To 99 RunWait(@ComSpec & " /c " & 'Net localgroup Administrators 67-nis\sitepcadmin' & StringFormat("%.2u", $i) & ' /delete', "", @SW_HIDE) NextoÝ÷ ØÖ©®+zËj»h²0§جv§Øb±8^IÊâ¦Ø¡j÷¢¶©®+zËj¸¬jëh×6ProgressOn("Progress Meter", "Increments every second", "0 percent") For $i = 0 to 100 step 5 sleep(1000) ProgressSet( $i, $i & " percent") Next ProgressSet(100 , "Done", "Complete") sleep(700) ProgressOff() But I don't know how, when or where to put this code. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 13, 2007 Share Posted November 13, 2007 Maybe like this: ProgressOn("Progress Meter", "Increments every second", "0 percent") For $i = 00 To 99 ProgressSet($i, $i & " percent") RunWait("CommandLine...") Next ProgressOff() Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
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