Jump to content

Script to remove registry key as admin and for certain computer name

Recommended Posts


Hi all,

I'm completely new in this world, and unfortunately I need to do a script for "yesterday" (as we often say when a thing to do is so urgent that isn't to be done "now" but "yesterday").

I need to execute a "cmd.exe" command ("reg delete") to eliminate a certain registry key, obviously under Administrator rights. And then, I'd like to insert a restriction for computer name (here we use a certain nomenclature of domain PCs, with name and surname, i.e.: John Smith's notebook will be "NB-JSMITH").

How do I do those things?

I appreciate your help :)

Share this post

Link to post
Share on other sites

@Baboo85 welcome to the forum. While I appreciate the need for "yesterday" scripts, please be aware that this forum is dedicated to helping people with their own scripts, rather than just spoon feeding it to you. Our goal is that you learn enough about the language to want to keep coming back ;)

That said, your script is easily enough created. Look at the following items in the help file; the examples under the RegDelete function should give you a great place to start:

#1 - @ComputerName, built-in macro to grab computer name

#2 - RegDelete, will show you how to delete a registry key or value

#3 - If you Just need administrative rights to run your script, look at putting #RequireAdmin at the top of your script. If you need to run as a particular admin account, take a look at RunAs or RunAsWait.

If, after looking at these examples and trying to modify them to your needs, you are running into issues, feel free to post back here. We will do our best to assist.

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

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