Solved

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

Posted on 2014-11-12
9
503 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 78

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
 

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
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:lianne143
ID: 40438991
Thanks for your help so far.
0
 
LVL 68

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 78

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

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

Title # Comments Views Activity
windows update wont update on hp laptop???? 7 79
DIal UP Interface 3 30
Class object 2 26
File and print server with Ubuntu? 7 23
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

919 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

24 Experts available now in Live!

Get 1:1 Help Now