rockinsmartguy Posted January 10, 2006 Share Posted January 10, 2006 (edited) I am trying to delete this registry key through a batch file which will run through group policy. Is there going to be permission issues with this . this is what I have so far@echo offREG DELETE HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676 /fclsThis is the name of the key HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676\00000003What else I need in the batch file. Any other sugestions will help as isn't only HKLM,HKU available for running it on remote machine. Edited January 10, 2006 by rockinsmartguy Link to comment Share on other sites More sharing options...
tguy Posted January 18, 2006 Share Posted January 18, 2006 If you are worried about permissions you can use the GPO to elevate the privileges or use the 'RUNAS' function to elevate privileges while the batch file executes.You could also write a registry file and place the minus(-) sign in front of the key you want to delete and then execute it with regedit /sThat should work no problem. Link to comment Share on other sites More sharing options...
rockinsmartguy Posted January 18, 2006 Author Share Posted January 18, 2006 This is the script I have============================================================Const HKEY_CURRENT_USER = &H80000001strComputer = CreateObject("Wscript.Shell").Environment("Process")("ComputerName")'strComputer = "."Dim strKeystrKey = "HKEY_CURRENT_USER\Software"If Not RegKeyExists(strKey) Then 'WScript.Echo "Key Is NOT Present!"Else 'WScript.Echo "Key IS Present." Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\default:StdRegProv") strKeyPath = "Software\Microsoft\Windows NT" oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys For Each subkey In arrSubKeys 'Wscript.Echo strKeyPath & "\" & subkey oReg.DeleteKey HKEY_CURRENT_USER, strKeyPath & "\" & subkey Next 'Wscript.Echo strKeyPath oReg.Deletekey HKEY_CURRENT_USER, strKeyPathEnd IfFunction RegKeyExists(strName)Const NO_EXISTING_KEY = "HKEY_NO_EXISTING\Key\"Dim objWshDim strKeyPathDim strNoKeyErrorSet objWsh = WScript.CreateObject("WScript.Shell")strKeyPath = Trim(strName)If Right(strKeyPath, 1) <> "\" Then strKeyPath = strKeyPath & "\"On Error Resume Next' Get the error description by trying to read a non-existent keyobjWsh.RegRead NO_EXISTING_KEYstrNoKeyError = Err.DescriptionErr.ClearobjWsh.RegRead strKeyPath' Compare the error description with the previous determined sampleIf Replace(Err.Description, strKeyPath, NO_EXISTING_KEY) = strNoKeyError Then RegKeyExists = FalseElse RegKeyExists = TrueEnd IfErr.ClearOn Error Goto 0Set objWsh = NothingEnd Function===========================================================The script runs on a single pc but its not working through login script, any examples on how to write a a reg file and run it through a batch file. is reg file going to delete all the subkeys below as they need to be empty before the main key gets deleted. Link to comment Share on other sites More sharing options...
Takeshi Posted January 19, 2006 Share Posted January 19, 2006 It would help greatly if you could outline what you really want to achieve clearly and some details about the domain setup (assuming it's a domain). You started off with a command script and a casual mention of remote computer. Then you came up with a VB script but still asking about "how to write a a reg file and run it through a batch file". Link to comment Share on other sites More sharing options...
rockinsmartguy Posted January 19, 2006 Author Share Posted January 19, 2006 I am trying to delete a particular registry key(HKEY_CURRENT_USER\Software) in outlook for couple of hundred users in the domain. The script needs to run through group policy, I already wrote the script tested on a single pc but it's not running through login script. Link to comment Share on other sites More sharing options...
jondercik Posted January 19, 2006 Share Posted January 19, 2006 Looks like a quote problem try:REG DELETE "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676" /f Link to comment Share on other sites More sharing options...
rockinsmartguy Posted January 19, 2006 Author Share Posted January 19, 2006 I am not using the batch file, I am using the vbs mentioned in my previous posts. The script works on a single pc but when I run it through a batch file it's not working thats the problem I am having. Link to comment Share on other sites More sharing options...
Chrish Posted January 19, 2006 Share Posted January 19, 2006 If your calling it from a batch file are you using:cscript myscript.vbs ? Link to comment Share on other sites More sharing options...
rockinsmartguy Posted January 19, 2006 Author Share Posted January 19, 2006 I have to do this through a startup or shudown script through group policy, or through sms. I am not sure on how to call a script , amy sugestions will help. Link to comment Share on other sites More sharing options...
Chrish Posted January 19, 2006 Share Posted January 19, 2006 Put it on a server netlogon share then edit the GPO that is attatched to the container containing the computers under the machine section its not hard too find. 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