Click here for a screen shot of the GUI in this script.


Addextender("WWWNT34I.DLL")
Addextender("wwipg34i.dll")

AdminFormat=`WWWDLGED,5.0`
AdminCaption=`Set Local Admin`
AdminX=79
AdminY=98
AdminWidth=238
AdminHeight=213
AdminNumControls=11
Admin01=`36,156,64,DEFAULT,PUSHBUTTON,DEFAULT,"Add User",1`
Admin02=`140,170,64,DEFAULT,PUSHBUTTON,DEFAULT,"Exit",2`
Admin03=`118,38,88,DEFAULT,EDITBOX,name,""`
Admin04=`20,38,94,DEFAULT,STATICTEXT,DEFAULT,"Enter the user ID to set as local admin:"`
Admin05=`120,88,88,DEFAULT,EDITBOX,Machine,""`
Admin06=`36,88,64,DEFAULT,STATICTEXT,DEFAULT,"Enter the machine name:"`
Admin07=`36,74,64,DEFAULT,RADIOBUTTON,swtch,"Single machine",3`
Admin08=`36,126,132,DEFAULT,RADIOBUTTON,swtch,"Use list of machines ( locate on root of C drive)",4`
Admin09=`26,62,190,DEFAULT,STATICTEXT,DEFAULT,"______________________________________________________________"`
Admin10=`26,106,190,DEFAULT,STATICTEXT,DEFAULT,"______________________________________________________________"`
Admin11=`36,184,64,DEFAULT,PUSHBUTTON,DEFAULT,"Remove User",6`
ButtonPushed=Dialog("Admin")
rmv_sw=""
If ButtonPushed==2 then exit
If ButtonPushed==6 then rmv_sw=6

If swtch==4
H="C:\netmember.txt"
old = FileOpen(H, "READ")
while @TRUE
x = FileRead(old)
If x == "*EOF*"
Run( "notepad.exe","c:\Admin_Set.txt ")
Break
endif
Errormode(@off)
host=strcat(x,".affymetrix.com")
tst=ipPing (host,5)
If tst==@TRUE
If rmv_sw ==6
gosub UNSET
else
gosub SET
endif
else
If rmv_sw ==6
gosub RMV_FAIL
else
gosub FAIL
endif
endif

endwhile
ErrorMOde(@ON)
Else
host=strcat(machine,".affymetrix.com")
tst=ipPing(host,5)
If tst==@TRUE
x="%machine%"
If rmv_sw ==6
gosub UNSET
else
gosub SET
Endif
else
If rmv_sw ==6
gosub RMV_FAIL
else
gosub FAIL
endif
endif
Run( "notepad.exe","c:\Admin_Set.txt ")
Endif
exit

:SUCCESS
set= FileOpen("c:\Admin_Set.txt", "APPEND")
FileWrite(set, "%x% User %name% added as local admin.")
FileClose(set)
return

:RMV_SUCCESS
set= FileOpen("c:\Admin_Set.txt", "APPEND")
FileWrite(set, "%x% User %name% removed from local admin.")
FileClose(set)
return

:FAIL
set= FileOpen("c:\Admin_Set.txt", "APPEND")
FileWrite(set, "%x% ***FAILURE*** User %name% not added as local admin.")
FileClose(set)
return

:RMV_FAIL
set= FileOpen("c:\Admin_Set.txt", "APPEND")
FileWrite(set, "%x% ***FAILURE*** User %name% not removed from local admin.")
FileClose(set)
return

:EXIST
set= FileOpen("c:\Admin_Set.txt", "APPEND")
FileWrite(set, "%x% **** User %name% already is local admin.")
FileClose(set)
return

:RMV_EXIST
set= FileOpen("c:\Admin_Set.txt", "APPEND")
FileWrite(set, "%x% **** User %name% does not exist in local administrators group.")
FileClose(set)
return

:SET
rslt=""
x=strcat("\\",x)
exst=wntMemberGet(x, "Administrators", name, @localGROUP)
If exst==@TRUE
gosub EXIST
else
rslt=wntMemberSet(x, "Administrators", name,@localGROUP)
If rslt==@TRUE then gosub SUCCESS
If rslt==@FALSE then gosub FAIL
endif
return

:UNSET
rslt=""
x=strcat("\\",x)
exst=wntMemberGet(x, "Administrators", name, @localGROUP)

If exst==@TRUE
rmv=wntMemberDel(x, "Administrators",name, @localGROUP)
If rmv==@TRUE then gosub RMV_SUCCESS
If rmv==@FALSE then gosub RMV_FAIL
else
gosub RMV_EXIST
endif
return