sooli Posted March 6, 2009 Posted March 6, 2009 I would like a simple batch file that will add an administrator to a machine using my input.I have a batch file that adds specific users - and i currently go into the batch file every time and add the new user that i am currently installing.I would like the batch file to ask me what the new user id is - then take my input and add it to the admins list.Thanks!
gunsmokingman Posted March 6, 2009 Posted March 6, 2009 Try this, but be aware there is no error caching on this.@Echo OffCLSMode 62, 9Color 9aTitle User IDSet /P ID=Type In Your User ID :CLSEcho.Echo User ID = %ID%pause
kingsc Posted March 6, 2009 Posted March 6, 2009 Is this in a domain environment? Are you a domain admin? If so, did you know you can go into your own computer management and then Action > Connect to Another Computer?You can then just grant them local admin access easily.If you have to do this alot.... I know our system admin pushed out a script that executes upon login to do this. I can see if I can post it if you want.
sooli Posted March 7, 2009 Author Posted March 7, 2009 Is this in a domain environment? Are you a domain admin? If so, did you know you can go into your own computer management and then Action > Connect to Another Computer?You can then just grant them local admin access easily.If you have to do this alot.... I know our system admin pushed out a script that executes upon login to do this. I can see if I can post it if you want.Yes this is in a domain environment - I set up new computers for new users about 8 a day, sometimes more. (I do have domain admin rights but these machines are still in their boxes till i get there and not on the domain - so I cannot access them before I arrive.)My current batch is as follows:net localgroup "Administrators" /add "ms_dlg_odin css"net localgroup "Administrators" /add "ms_dlg_msfc its"net localgroup "Administrators" /add solivasnet localgroup "Administrators" /add ndc\solivasnet localgroup "Administrators" /add ndc\tlaughinThe last command is where I modify it every time - i would like for the batch file to prompt me for the user name, and then insert it where it says ndc\tlaughin. I am new to this Batch File Creation - and I don't want to mess anything up.As long as i have the userid - i don't need any error checking - other than maybe a failed notice - if the user name is not on the domain, I always check to make sure the names took anyway so I really don't even need that.Thanks!
gunsmokingman Posted March 7, 2009 Posted March 7, 2009 Here I made this HTA so you can get the user input and run your commands.Save As UserName.hta <TITLE>Submit User Name</TITLE> <HTA:APPLICATION ID='UNSubmit' Scroll='No' SCROLLFLAT ='No' SingleInstance='Yes' SysMenu='Yes' ShowInTaskBar='No' MaximizeButton='No' MinimizeButton='No' Border='Thin' BORDERSTYLE ='complex' INNERBORDER ='No' Caption='Yes' WindowState='Normal' APPLICATIONNAME='SubmitUN' Icon='%SystemRoot%\explorer.exe'> <STYLE Type="text/css"> Body { Font-Size:8.05pt; Font-Weight:Bold; Font-Family:Arial,Tahoma,Comic Sans MS,Segoe Ui; Color:#001254; BackGround-Color:Transparent; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='#fdf7f1',endColorStr='#d1cbc5'); Margin-Top:5; Margin-Bottom:5; Margin-Left:4; Margin-Right:4; Padding-Top:5; Padding-Bottom:5; Padding-Left:4; Padding-Right:4; Text-Align:Center; Vertical-Align:Top; Border-left: 1px Ridge; Border-right: 1px Groove #bcb8b4; Border-top: 1px Ridge; Border-Bottom: 1px Groove #bcb8b4; } BUTTON { Width:51PT; Height:15PT; Cursor:Hand; Font-Size:7.95pt; Font-Weight:Bold; filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='#FEFDFC',endColorStr='#D7D9D7'); Margin-Top:1; Margin-Bottom:1; Margin-Left:3; Margin-Right:3; Padding-Top:1; Padding-Bottom:1; Border-left: 1px Ridge; Border-right: 1px Groove #bcb8b4; Border-top: 1px Ridge; Border-Bottom: 1px Groove #bcb8b4; } .TxBox { Height:15PT; Font-Size:7.95pt; Font-Weight:Bold; Font-Family:Arial,Tahoma,Comic Sans MS,Segoe Ui; Color:#1e1e1e; filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='#FEFDFC',endColorStr='#D7D9D7'); Margin-Top:1; Margin-Bottom:1; Margin-Left:3; Margin-Right:3; Padding-Top:1; Padding-Bottom:1; Border-left: 1px Ridge; Border-right: 1px Groove #bcb8b4; Border-top: 1px Ridge; Border-Bottom: 1px Groove #bcb8b4; } </STYLE> <script language="VBScript">'-> Resize Window Dim Wth :Wth = int(461) Dim Hht :Hht = int(105) window.ResizeTo Wth, Hht MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2))'-> Btn01 Function Function UNAction() If TB1.value = "" Then alert("Error No User Name") Else '-> Code For What You Want To Do Dim Act :Set Act = Createobject("Wscript.Shell") Dim Net :Net = "net localgroup" Dim Adm :Adm = "Administrators" Act.Run(Net & Chr(34) & Adm & Chr(34) & " /add" & Chr(34) & "ms_dlg_odin css" & Chr(34)),0,True Act.Run(Net & Chr(34) & Adm & Chr(34) & " /add" & Chr(34) & "ms_dlg_msfc its" & Chr(34)),0,True Act.Run(Net & Chr(34) & Adm & Chr(34) & " /add solivas"),0,True Act.Run(Net & Chr(34) & Adm & Chr(34) & " /add ndc\solivas"),0,True Act.Run(Net & Chr(34) & Adm & Chr(34) & " /add ndc\" & TB1.value),0,True window.close() End If End Function </SCRIPT><BODY><TABLE Width='100%'> Type in your User Name. <INPUT Type='TextBox' Name='TB1' Class='TxBox' SIZE='26' MAXLENGTH='26'> <BUTTON ID='Bttn1' OnClick='UNAction()'>Submit</BUTTON> </TABLE></BODY>
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