Was wondering if someone could help me Make A Batch File
Moderator: DosItHelp
Was wondering if someone could help me Make A Batch File
Was wondering if someone could help me Make A Batch File That Deletes Files
Not sure if many can help but I am in IT, and run in to a certain program error all the time. The fix is deleting 4 files in their PC.
Example:
1.Delete the UCF folder located at C:\Documents and Settings\Username\Documentum
2.Delete the Java folder located at C:\Cache
3.Delete Temp internet Files
4.Delete Cookies
Any suggestions?
Not sure if many can help but I am in IT, and run in to a certain program error all the time. The fix is deleting 4 files in their PC.
Example:
1.Delete the UCF folder located at C:\Documents and Settings\Username\Documentum
2.Delete the Java folder located at C:\Cache
3.Delete Temp internet Files
4.Delete Cookies
Any suggestions?
Re: Was wondering if someone could help me Make A Batch File
To delete folders and it's content you use
This will remove the directory and it's contents.
"Temp internet Files" for what browsers ?
And What system?
Code: Select all
RMDIR /S /Q "C:\Documents and Settings\Username\Documentum" >nul
RMDIR /S /Q "C:\Cache" >nul
This will remove the directory and it's contents.
"Temp internet Files" for what browsers ?
And What system?
Re: Was wondering if someone could help me Make A Batch File
Very nice. How do I grab the username of who is currently logged into the PC?
There could be multiple usernames.
IE 7
Windows XP
There could be multiple usernames.
IE 7
Windows XP
Re: Was wondering if someone could help me Make A Batch File
Edited:
To grap the username u use try this in your cmd window
But this location : C:\Documents and Settings\<username>\ is equal to %userprofile%
Test it and to make it exist after if finish, remove the "pause"
To grap the username u use try this in your cmd window
Code: Select all
echo %username%
But this location : C:\Documents and Settings\<username>\ is equal to %userprofile%
Code: Select all
@Echo Off
:: Remove Cash and Documentum Folders
RMDIR /S /Q "C:\Documents and Settings\%username%\Documentum\UCF" >nul
RMDIR /S /Q "C:\Cache\JAVA" >nul
:: Remove Internet Temporary Files
Del /F /S /Q "%userprofile%\Local Settings\Temporary Internet Files\*.*" >nul
Del /F /S /Q "C:\Documents and Settings\%username%\Cookies\*.*" >nul
pause
Test it and to make it exist after if finish, remove the "pause"
Last edited by abc0502 on 29 Nov 2012 15:07, edited 3 times in total.
Re: Was wondering if someone could help me Make A Batch File
That is awesome. I may have made a mistake in my first comment.
Here is the one I want to delete.
.Delete the UCF folder located at C:\Documents and Settings\Username\Documentum\UCF
Delete the Java folder located at C:\Cache\JAVA
So, I really just wanted to delete the last folder. not the whole profile and everything. Or did I read your post wrong?
Thanks for all the help.
Here is the one I want to delete.
.Delete the UCF folder located at C:\Documents and Settings\Username\Documentum\UCF
Delete the Java folder located at C:\Cache\JAVA
So, I really just wanted to delete the last folder. not the whole profile and everything. Or did I read your post wrong?
Thanks for all the help.
Re: Was wondering if someone could help me Make A Batch File
Ok, i changed the code above, it will delete the folder UFC and Java and all of it's content.
Re: Was wondering if someone could help me Make A Batch File
@Echo Off
:: Remove Cash and Documentum Folders
RMDIR /S /Q "C:\Documents and Settings\%username%\Documentum\UCF" >nul
RMDIR /S /Q "C:\Cache\JAVA" >nul
:: Remove Internet Temporary Files
Del /F /S /Q "%userprofile%\Local Settings\Temporary Internet Files\*.*" >nul
Del /F /S /Q "C:\Documents and Settings\%username%\Cookies\*.*" >nul
pause
On the Temp internet files, does it need to be like this?
Del /F /S /Q "C:\Documents and Settings\%userprofile%\Local Settings\Temporary Internet Files\*.*" >nul
Re: Was wondering if someone could help me Make A Batch File
Edited:
Corrected wrong Path "C:\Documents and Settings\%userprofile%\" to "C:\Documents and Settings\%username%\"
yes it can be but as i said
Can be used as
as this point to the folder %username% directly, both are the same
I used to do that if i'm going to process folders inside the "C:\Documents and Settings\%username%" path, so i don't write too much
Corrected wrong Path "C:\Documents and Settings\%userprofile%\" to "C:\Documents and Settings\%username%\"
yes it can be but as i said
Code: Select all
C:\Documents and Settings\%username%\
Can be used as
Code: Select all
%userprofile%
as this point to the folder %username% directly, both are the same
I used to do that if i'm going to process folders inside the "C:\Documents and Settings\%username%" path, so i don't write too much
Last edited by abc0502 on 30 Nov 2012 05:34, edited 1 time in total.
Re: Was wondering if someone could help me Make A Batch File
'
hi abc0502,
'userName' == 'runAsUserName' neq 'logonUserName'
But probably not a problem for the sake of simplicity so why mention it, I am bored
hi abc0502,
'userName' == 'runAsUserName' neq 'logonUserName'
Code: Select all
%regKeyRead_% $logonUserName, "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer", "logon User Name"
That's obviously wrong,abc0502 wrote:Can be used asCode: Select all
C:\Documents and Settings\%userprofile%\
Code: Select all
%userprofile%
Re: Was wondering if someone could help me Make A Batch File
.
If you type SET at the command prompt and hit ENTER.
You can see all the variables that are currently active on your system.
The text before the = symbol is your variable name, so...
%SystemRoot% is equal to the path 'c:\windows'
If you type SET at the command prompt and hit ENTER.
You can see all the variables that are currently active on your system.
The text before the = symbol is your variable name, so...
%SystemRoot% is equal to the path 'c:\windows'
Re: Was wondering if someone could help me Make A Batch File
@Ed Dyreen and Boombox
Sorry for that it was a typing error, i meant
Equal to
I wrote that in my 2nd post
and didn't notice that i wrote the %userprofile% till you mentioned it.
I will correct that.
Sorry for that it was a typing error, i meant
Code: Select all
C:\Documents and Settings\%username%
Equal to
Code: Select all
%userprofile%
I wrote that in my 2nd post
Code: Select all
Del /F /S /Q "%userprofile%\Local Settings\Temporary Internet Files\*.*" >nul
Del /F /S /Q "C:\Documents and Settings\%username%\Cookies\*.*" >nul
and didn't notice that i wrote the %userprofile% till you mentioned it.
I will correct that.
Re: Was wondering if someone could help me Make A Batch File
So,
Is there a way to write something that will distinguish between Windows Xp, and Windows 7? Like an IF Statement?
If using Windows XP then use below, ELSE use the Windows 7 file locations?
Is there a way to write something that will distinguish between Windows Xp, and Windows 7? Like an IF Statement?
If using Windows XP then use below, ELSE use the Windows 7 file locations?
Re: Was wondering if someone could help me Make A Batch File
Yes, but will this location will change "C:\Cache\JAVA" ?
and is this always at the main folder of the user profile "Documentum\UCF" ?
and is this always at the main folder of the user profile "Documentum\UCF" ?
Re: Was wondering if someone could help me Make A Batch File
In Windows 7 it will be like C:\Users\Username\Documentum
But, I assume the temp internet files and cookies location will change?
But, I assume the temp internet files and cookies location will change?
Re: Was wondering if someone could help me Make A Batch File
Test this, I only tested XP as I work on it now, in windows 7 i assumed the same when removing the attributes in order to delete protected files.
I will test windows 7 when i come back and update the code if needed.
BTW, when running on 7 try running using Admin rights, and don't forget I DIDN'T TEST IT ON 7
and this "2>nul" to prevent errors to be displayed when there is no files in the cookies folder to delete
Code: Select all
@Echo Off
:: Check if OS is XP
ver | find "XP" > nul
if %ERRORLEVEL% == 0 (
:: Delete Temporary Internet Files
PUSHD "%userprofile%\Local Settings\Temporary Internet Files"
For /F "delims=" %%A in ('Dir /B /A:D "*.*"') Do (
ATTRIB -S -H -A "%%A"
RMDIR /S /Q "%%A" 2>nul
ATTRIB +S +H +A "%%A"
)
POPD
:: Delete Cookies
Del /F /Q "%userprofile%\Cookies\*.*" 2>nul
)
echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 (
:: Delete Temporary Internet Files [ Two Temp location in windows 7 ]
PUSHD "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files"
For /F "delims=" %%A in ('Dir /B /A:D "*.*"') Do (
ATTRIB -S -H -A "%%A"
RMDIR /S /Q "%%A" 2>nul
ATTRIB +S +H +A "%%A"
)
POPD
PUSHD "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low"
For /F "delims=" %%A in ('Dir /B /A:D "*.*"') Do (
ATTRIB -S -H -A "%%A"
RMDIR /S /Q "%%A" 2>nul
ATTRIB +S +H +A "%%A"
)
POPD
:: Delete Cookies
Del /F /Q "%userprofile%\AppData\Roaming\Microsoft\Windows\Cookies\*.*" 2>nul
)
:: Deleting Other Folders [ They should be in general in the same location ]
RMDIR /S /Q "%userprofile%\Documentum\UCF" >nul
RMDIR /S /Q "C:\Cache\JAVA" >nul
Pause
Exit /B
I will test windows 7 when i come back and update the code if needed.
BTW, when running on 7 try running using Admin rights, and don't forget I DIDN'T TEST IT ON 7
and this "2>nul" to prevent errors to be displayed when there is no files in the cookies folder to delete