Solved

Windows 7 Batch script help?

Posted on 2014-07-24
12
743 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
  • 7
  • 5
12 Comments
 
LVL 37

Accepted Solution

by:
Gerwin Jansen earned 500 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 37

Expert Comment

by:Gerwin Jansen
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
 

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 37

Expert Comment

by:Gerwin Jansen
ID: 40220550
Ok, were you able to copy the default desktop.ini file?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 37

Expert Comment

by:Gerwin Jansen
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 37

Expert Comment

by:Gerwin Jansen
ID: 40232611
Thanks :)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now