Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 898
  • Last Modified:

Windows 7 Batch script help?

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
garryshape
Asked:
garryshape
  • 7
  • 5
1 Solution
 
Gerwin Jansen, EE MVETopic Advisor Commented:
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
 
garryshapeAuthor Commented:
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
 
Gerwin Jansen, EE MVETopic Advisor Commented:
>> 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
garryshapeAuthor Commented:
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
 
garryshapeAuthor Commented:
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
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Ok, were you able to copy the default desktop.ini file?
0
 
garryshapeAuthor Commented:
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
 
garryshapeAuthor Commented:
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
 
Gerwin Jansen, EE MVETopic Advisor Commented:
>> Will that mess anything up?
That is a good question, I wouldn't know for sure...
0
 
garryshapeAuthor Commented:
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
 
garryshapeAuthor Commented:
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
 
Gerwin Jansen, EE MVETopic Advisor Commented:
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.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now