Solved

Batch file to delete a folder in windows 7 , when the PC restarts.

Posted on 2014-11-12
9
586 Views
Last Modified: 2014-12-10
Hi

I want to delete a folder in windows 7 when this PC restarts.The folder is located in the following location .

C$\ProgramData\Microsoft\Windows\Start Menu\Programs\Technology\Textile Technology

I will create a GPO and i will apply this batch file to a GPO (Computer configuration-policies- windows settings-Scripts-shutdown)

Please post me a syntax for a batch file;
 

Any help much appreciated, thanks guys.
0
Comment
Question by:lianne143
[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
9 Comments
 

Expert Comment

by:angelfyre
ID: 40437929
Create any file name with the extension .bat

Insert the following line:

rd /s /q C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Technology\Textile Technology


This will remove the directory with the contents, in quiet mode, not asking you for confirmation.
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40437949
rmdir /s /q "C:\TestingThe BatchFile"
0
 
LVL 81

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 250 total points
ID: 40438107
another approach

rd /s /q "%programdata%\Microsoft\Windows\Start Menu\Programs\Technology\Textile Technology"
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

Author Comment

by:lianne143
ID: 40438951
Thanks David it worked like a Charm , it deleted the Textile Technology folder.

Finally I want to add another line to create a folder called "Food Technology" under the following location and want to copy a shortcut within this  Food Technology folder.

C$\ProgramData\Microsoft\Windows\Start Menu\Programs
0
 

Author Comment

by:lianne143
ID: 40438991
Thanks for your help so far.
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 250 total points
ID: 40445796
Please note that "C$\ProgramData\Microsoft\Windows\Start Menu\Programs" is not really a location - "\\MyPC\C$\ProgramData\Microsoft\Windows\Start Menu\Programs" or "C:\ProgramData\Microsoft\Windows\Start Menu\Programs" is ...

All you need to add for creating the folder is a similar md (mkdir) command for the new folder (and I strongly recommend to use the %programdata% syntax, but be aware that only works for 32bit OS, or 64bit programs on 64bit OS, else paths are different):
rd /s /q "%programdata%\Microsoft\Windows\Start Menu\Programs\Technology\Textile Technology"
md "%programdata%\Microsoft\Windows\Start Menu\Programs\Food Technology"
copy "\\server\share\shortcut.lnk" "%programdata%\Microsoft\Windows\Start Menu\Programs\Food Technology\"

Open in new window

I've used "\\server\share\shortcut.lnk" as the source of the shortcut. Change that as required.
0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 40488548
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 81

Expert Comment

by:David Johnson, CD, MVP
ID: 40488549
there is more than enough informatrion: accept qlemo's last comment ID: 40445796 and my comment (assisted) ID: 40438107
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

OfficeMate Freezes on login or does not load after login credentials are input.
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
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…

688 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