Computing.Net > Forums > Programming > Bat file access to remote HKCU

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Bat file access to remote HKCU

Reply to Message Icon

Name: BDewald
Date: May 24, 2007 at 20:09:55 Pacific
OS: WinXP Pro SP2
CPU/Ram: 1.6GHz 1GB
Product: Dell Latitude D800
Comment:

Is there any way to do modify the HKEY_CURRENT_USER on a mapped drive connected by USB or BartPE? I have admin access and know the user/profile name and need to modify HKCU for one profile only from a bat file...Thanx!



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: May 24, 2007 at 20:31:32 Pacific
Reply:

Not easily, no; there's just no clean way to pick the current user you actually care about. You would have to walk HKU and focus on whom you don't want.

Now if you want to modify a user's profile when they're not logged on, then that's probably far too easy to do.

All further inquires should be directed towards the Programming forum, where the people are all too eager to show off their batch file skills.


0

Response Number 2
Name: BDewald
Date: May 24, 2007 at 21:38:17 Pacific
Reply:

This was my first post here. I will redirect my request as you suggest. However, you hit the nail on the head. I will be logged on the system drive and use a .bat file to clean profile on another drive. I need to be able to connect the other drive to my PC, and run .bat file. It works except I also want to clear MRUs for specific profile. If easy, please provide sample. Otherwise I'll goto prg area. Thanx either way!


0

Response Number 3
Name: BDewald
Date: May 24, 2007 at 21:39:10 Pacific
Reply:

Wait a minute...I did post this to the programming area!


0

Response Number 4
Name: Razor2.3
Date: May 24, 2007 at 22:02:45 Pacific
Reply:

No you didn't; it was moved.

The command you're looking for is:

REG LOAD HKU\OpenUser "<path to the user's profile path>\ntuser.dat"
<do whatever REG commands you want>
REG UNLOAD HKU\OpenUser



0

Response Number 5
Name: BDewald
Date: May 24, 2007 at 22:18:00 Pacific
Reply:

Thanks. I'll give this a shot and let you know. Thank-you.


0

Related Posts

See More



Response Number 6
Name: Razor2.3
Date: May 24, 2007 at 22:27:04 Pacific
Reply:

The REG commands you want to run will probably look something like this:
for /f "delims=" %%a in ('reg query hku\OpenUser\Software /s ^| findstr /i "^HKEY.*MRU"') do reg delete %%a /f

But I do suggest backing up ntuser.dat before attempting it.


0

Response Number 7
Name: bdewald
Date: May 30, 2007 at 18:54:33 Pacific
Reply:

I tried this in response to your response above - #4:

REG LOAD HKU\OpenUser "C:\Documents and Settings\%USERNAME%\ntuser.dat"
[-HKEY_USERS\OpenUser\Software\Microsoft\Windows\CurrentVersion\Explorer \RecentDocs]
REG UNLOAD HKU\OpenUser

I received the following message after the "REG LOAD" and "REG UNLOAD" lines:

"The operation completed successfully"

I received the following message after the "HKU_USERS" line:

"The system cannot find the path specified"

Any ideas on what is wrong with my path? Thanks...



0

Response Number 8
Name: Razor2.3
Date: May 31, 2007 at 18:17:53 Pacific
Reply:

Yeah, CMD doesn't accept [-KEY] commands; it's a batch file, not a registry script. Try:
REG DELETE HKU\OpenUser\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs /va /f


0

Response Number 9
Name: BDewald
Date: June 1, 2007 at 17:02:55 Pacific
Reply:

Making progress. I received "success" messages on Lines #1, 2, and 6 below. I received "invalid parameter" mesaages on lines #3 and 4. I received "Can't find key or value" message on line #5. I have tried various combinations of parameters. I even tried a load and unload statement for each deletion.


0

Response Number 10
Name: BDewald
Date: June 1, 2007 at 17:04:12 Pacific
Reply:

I guess it would help if I include the code:

REG LOAD HKU\OpenUser "C:\Documents and Settings\%USRPROFILE%\ntuser.dat"
REG DELETE HKU\OpenUser\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs /va /f
REG DELETE HKU\OpenUser\Software\Microsoft\Internet Explorer\TypedURLs /f
REG DELETE HKU\OpenUser\Software\Microsoft\Internet Explorer\TypedURLs
REG DELETE HKU\OpenUser\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit /v LastKey /f
REG UNLOAD HKU\OpenUser


0

Response Number 11
Name: Razor2.3
Date: June 1, 2007 at 17:47:17 Pacific
Reply:

Actually, if you're running the script on the current user, then you can use HKCU instead of loading it as OpenUser.

Lines 3 and 4 are complaining because you don't have quotes around the registry path. You need them because of the space in "Internet Explorer." Also, they're the same line, repeated.

Line 5 is complaining because, well, the key doesn't exist. You'll notice it stops complaining for one run if you open and close regedit, which recreates the key.

Updated script:
REG DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs /va /f
REG DELETE "HKCU\Software\Microsoft\Internet Explorer\TypedURLs" /va /f
REG DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit /v LastKey /f

Edit: Doesn't %UserProfile% already include the C:\Documents and Settings?


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Bat file access to remote HKCU

BAT File to Increment File Name +1 www.computing.net/answers/programming/bat-file-to-increment-file-name-1/17272.html

setting excel security in bat file www.computing.net/answers/programming/setting-excel-security-in-bat-file/16235.html

ping bat file www.computing.net/answers/programming/ping-bat-file/16605.html