Robdarftw Posted August 6, 2014 Share Posted August 6, 2014 I am trying to run a script to change the currently logged on user from an administrator in the local group to a Standard User in Windows 7. What I need to know is what can I use as a variable to target the currently logged on user to apply this script to. This is my command im trying to run(in elevated command): net localgroup users "UserName" /add net localgroup administrators "UsernName" /delete What can I use instead of each individual "username" and having to change the command for every single computer, is there a way to make a command to say "set the currently logged on user to add to the local group "users" and delete the local group "Administrators". I will be remotely administering this script to all the computers on the network, so instead of going to each computer and doing this manually, it would be very helpful. Thanks very much. Link to comment Share on other sites More sharing options...
November Posted August 6, 2014 Share Posted August 6, 2014 (edited) Hi there, Maybe @username check Macro Reference - System Info in helpfile. But i think that a logoff is mandatory to apply new windows rights. Cheers Edited August 6, 2014 by November Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
Robdarftw Posted August 6, 2014 Author Share Posted August 6, 2014 I'm a noob to this, could you help with a batch file for this? My remote tool will push a batch file to each machine, but it needs to be told exactly what to do. Would I need to include a command to open Command Prompt in Elevated command, then run that line? And if so, how do I do that? Thanks! Link to comment Share on other sites More sharing options...
November Posted August 6, 2014 Share Posted August 6, 2014 Well i can try to help you, with the script code, but i am no expert in windows group. Can't you do that with global policies? Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 6, 2014 Moderators Share Posted August 6, 2014 Upon creation, the user is already part of the Local Users group To remove from Admin Group you would do this: $oGroup = ObjGet("WinNT://" & @ComputerName & "/Administrators,group") $oUser = ObjGet("WinNT://" & @ComputerName & "/Hades,user") $oGroup.Remove($oUser.ADSPath) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Robdarftw Posted August 6, 2014 Author Share Posted August 6, 2014 JLogan- I opened a notepad, put in your code and saved it as a .bat file and ran it. I saw the command prompt wiz by but, I checked my user account settings and the user did not get changed. Ideas? Also, with the group policy, Were running a server 2003 for our DC, so not sure about making a group policy, also this is only affecting the user account on the local group level, not domain level. Thanks! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 6, 2014 Moderators Share Posted August 6, 2014 You are in an AutoIt forum. Why would you expect us to help you create batch files?! What I gave you was AutoIt code. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Robdarftw Posted August 6, 2014 Author Share Posted August 6, 2014 To be fair, I did post that I needed to create a batch file. Thanks anyways :-) I'm a noob to this, could you help with a batch file for this? My remote tool will push a batch file to each machine, but it needs to be told exactly what to do. Would I need to include a command to open Command Prompt in Elevated command, then run that line? And if so, how do I do that? Thanks! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 6, 2014 Moderators Share Posted August 6, 2014 My question would remain the same, why post for a batch file in an AutoIt forum (much akin to posting for Java code in a C# forum)? Hopefully the code I provided will work for you, and will be a good launching point for you to learn more about the language. If you take some time to become familiar with AutoIt, you will find there isn't much you can't do with it. Country73 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Robdarftw Posted August 12, 2014 Author Share Posted August 12, 2014 I honestly have never heard of this, I thought it was an IT forum. Sorry for the confusion. I'm not much of a programmer, so I really wouldn't know where to start. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 12, 2014 Moderators Share Posted August 12, 2014 Well a belated welcome to the forum, we focus on the AutoIt language. And we have all been on Day 1 before, that is why so many volunteer their time and efforts to assist. If you take the time to learn the language, though, regardless of your role in IT, you will find there isn't much you cannot accomplish with AutoIt. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
MikahS Posted August 12, 2014 Share Posted August 12, 2014 @Robdarftw JLogan is very correct. We would love to help you find a solution, using the AutoIt language, as we've all been there. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Gianni Posted August 12, 2014 Share Posted August 12, 2014 (edited) though, You could use the %username% environment variable in the barch file instead of plain "UserName" text Edited August 12, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... 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