Solved

Windows 7 Batch script help?

Posted on 2014-07-24
12
762 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

OfficeMate Freezes on login or does not load after login credentials are input.
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

863 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

28 Experts available now in Live!

Get 1:1 Help Now