Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows 7 Batch script help?

Posted on 2014-07-24
12
Medium Priority
?
836 Views
Last Modified: 2014-07-31
Can someone help me try to make a batch/.cmd that does the following?

1. Deletes all items in this folder:
C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

2. Deletes this folder:
C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

3. Deletes the line "[LocalizedFileNames]" and everything below it, from the file:
C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Desktop.ini.

Typically this .ini will contain a section in the desktop.ini that contains "[LocalizedFileNames]" and then a line or two below it that has "Internet Explorer.lnk" lines, trying to get those deleted.

4. Delete "StubPath" and "LocalizedName" from the key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{89820200-ECBD-11cf-8B85-00AA005B4383}", or any item in this key that contains the value "@C:\Windows\System32\ie4uinit.exe,-2000" and/or "C:\Windows\System32\ie4uinit.exe -BaseSettings"


The first 2 I think I can do with the del command but I'm having trouble with 3 and 4. Not sure if it can be done in a reg script or just exported as reg and imported...


The overall goal of this is to Remove Internet Explorer Pinned and Start menu shortcuts for All Users and new-users, because it doesn't appear to be possible with Group Policy. These are the areas I found to resolve it
0
Comment
Question by:garryshape
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 2000 total points
ID: 40218156
For the 3rd one: can you provide a sample of that Desktop.ini file and what you want removed?

One and two can be done with one rmdir command:
rmdir /s /q "C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"

Open in new window

And number 4: would be easiest to just delete that {898... } key first and then load the key abain with default values, that way you don't have to search for 'any item'.

You delete that key by putting this in a .reg file:
Windows Registry Editor Version 5.00

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{89820200-ECBD-11cf-8B85-00AA005B4383}]

Open in new window

and calling that with: regedit /s delete_key.reg

To create the default .reg file, edit the registry the way you want it to look, export it as default_values.reg and import it: regedit /s default_values.reg
0
 

Author Comment

by:garryshape
ID: 40218165
Ahhh ok got it, yeah let me try it!
Here's the INI file


[.ShellClassInfo]
LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21782
[LocalizedFileNames]
Internet Explorer.lnk=@%windir%\System32\ie4uinit.exe,-734
Internet Explorer (64-bit).lnk=@%windir%\System32\ie4uinit.exe,-735



So deleteing the parts bold'd would be the goal.
Then again wondering if like you said, it'd just be easier to delete the file then copy over one without the information.
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40218206
>> Then again wondering if like you said, it'd just be easier to delete the file then copy over one without the information.
If you have or can create a default file: yes do that. It's the easiest, like re-creating the default reg key.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:garryshape
ID: 40219573
Well the problem is now I can't edit the "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\desktop.ini" file.

If I try from a command I get permission denied. If I try to overwrite with another one with xcopy, also Access denied.

I tried running "attrib -S _H" against the desktop.ini file and I still get Access denied

Or if I try to copy another desktop.ini to overwrite this desktop.ini, I get "access denied".
I can't delete it either at least from a command prompt. I have full access but "System" is the owner
0
 

Author Comment

by:garryshape
ID: 40219998
Ah ok here we go, I think this will work so far no errors. I had to change -S and -H to -s -h (lower case):

cmd /c attrib -h -s "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\desktop.ini"
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40220550
Ok, were you able to copy the default desktop.ini file?
0
 

Author Comment

by:garryshape
ID: 40227750
Well at this point, there's still a blank icon pinned to the task bar for Internet Explorer. Even though I delete the registry pointed, and the actual .lnk file in the DefaultUser folder, it still shows up for any new user that logs in.
To remove, I have to click the pinned shortcut, and click "yes" at the prompt to remove the invalid pinned shortcut.

So this makes me wonder, if I have to delete the .lnk first, reboot and then delete the registry, or vice versa, or if there's a special order of trying to get rid of it.

I had it removed for all new users at one point, just can't recall what else I did differently.
0
 

Author Comment

by:garryshape
ID: 40227871
Ok, I got rid of the icon by doing the following in addition to what I've done so far.
I loaded the hive of C:\Users\DefaultUser\NTUser.dat then deleted the key "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband".
Will that mess anything up?
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40229329
>> Will that mess anything up?
That is a good question, I wouldn't know for sure...
0
 

Author Comment

by:garryshape
ID: 40229352
It doesn't appear to. It just makes it to where the pinned items I removed originally via the Registry and File system do not appear. We don't want those icons being pinned anyways since we're using Citrix to alternatively deliver those applications.
It does appear I can pin things manually as the user, reboot, and they remain there.
I was reading up on the Taskband thing and apparently there's encryption throughout the registry where Microsoft interestingly uses rot 13 encryption and some administrators have gone to very complex measures to fine-tune and customize the pinned items and other user shortcuts.
0
 

Author Comment

by:garryshape
ID: 40230634
I'm going to accept the batch advice it really helps.
Just something I'm having to work with, which is tedious, is HP's moronic built-in OEM stuff. They have multiple xml files for sysprep so it keeps overriding stuff.. really crazy
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40232611
Thanks :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question