Jump to content
Sign in to follow this  
Robdarftw

Currently logged on user from Administrator to Standard User

Recommended Posts

Robdarftw

 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.

Share this post


Link to post
Share on other sites
November

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 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]

Share this post


Link to post
Share on other sites
Robdarftw

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!

Share this post


Link to post
Share on other sites
November

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]

Share this post


Link to post
Share on other sites
JLogan3o13

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)

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Robdarftw

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!

Share this post


Link to post
Share on other sites
JLogan3o13

You are in an AutoIt forum. Why would you expect us to help you create batch files?! What I gave you was AutoIt code.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Robdarftw

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!

Share this post


Link to post
Share on other sites
JLogan3o13

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.

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Robdarftw

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.

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
MikahS

@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 ~ getENVvars
My 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

 

Share this post


Link to post
Share on other sites
Chimp

though, You could use the %username% environment variable in the barch file instead of plain "UserName" text

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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  

×