Jump to content
Sign in to follow this  
JonCross

Net LocalGroup

Recommended Posts

JonCross

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 by JonCross

Share this post


Link to post
Share on other sites
picaxe

For $i = 0 To 99
    Run(@ComSpec & " /c " & 'Net localgroup Administrators 67-nis\sitepcadmin' &  StringFormat("%.2u", $i) & ' /delete', "", @SW_HIDE)
Next

Share this post


Link to post
Share on other sites
JonCross

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.

Share this post


Link to post
Share on other sites
picaxe

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 by picaxe

Share this post


Link to post
Share on other sites
JonCross

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.

Share this post


Link to post
Share on other sites
PsaltyDS

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.

:P


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

Share this post


Link to post
Share on other sites
JonCross

Doh, Thanks. :P

Share this post


Link to post
Share on other sites
JonCross

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.

Share this post


Link to post
Share on other sites
PsaltyDS

Maybe like this:

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 00 To 99
    ProgressSet($i, $i & " percent")
    RunWait("CommandLine...")
Next
ProgressOff()

:P


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

Share this post


Link to post
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
Sign in to follow this  

×