March 6, 200917 yr 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!
March 6, 200917 yr 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
March 6, 200917 yr 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.
March 7, 200917 yr Author 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!
March 7, 200917 yr 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>
Create an account or sign in to comment