Solved

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

Posted on 2014-11-12
9
539 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
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 80

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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

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 69

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 80

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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