The .bat file is located in C:\Temp in a domain network. It will be ran via shortcut on user desktop. Using this setup, on my system and on one other system (laptop Win 7 Pro and Desktop Win 7 Pro), it works. Different users. I have admin account, and test profile call joe user (juser) no admin rights. Does what it is intended to do. Tried on additional users desktops under their profile and it fails. Does not find the files. I added pauses after each command to decipher and found the errors. Verified files are indeed there. Able to browse to location and actually see the files.
Can someone help point out what I am not seeing?
Again it works on my system, a default user with no admin rights systems for testing purposes, but fails on others.
#echo off
title This will delete you cookies!
echo This will program will close all Chrome Windows and clear cookies. Make sure all data is saved before pressing any key.
pause
echo Are you sure you are ready?
pause
echo Absolutely sure?
pause
taskkill /IM Chrome.exe /F
cd %USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\
del Cookies
del Cookies-journal
del Current Session
…perhaps:
TaskKill /F /IM Chrome.exe /T 2>Nul
CD/D "%LOCALAPPDATA%\Google\Chrome\User Data\Default"
Del/A/F Cookies Cookies-journal "Current Session"
Assuming cookies, cookies-journal etc. are directories, you need rd /s /q "cookies" etc.
rd removes a directory, /s means "and subdirectories" /q "quietly" and the quotes need to surround the target directory-name where the directory-name "contains spaces" (and are harmless otherwise)
Related
I have a .bat that needs to run as admin although this creates problems with parts of the .bat when %userprofile% is used it will navigate to system32 rather than the userprofile that the .bat is run on.
I don't have any need to navigate to system32 with the .bat so if there was a way to correct this from the start of the .bat so following commands could be run as the currently logged in user.
You have two choices:
cd /d "%userprofile%"
or
pushd "%userprofile%"
I found the issue seems to be how the .bat is being used (through LogMeIn) for some reason it was going to system32 even using the pushd /d "%userprofile%" command I found a workaround that works with logmein is the following
pushd "%~dp0"
cd..
cd..
cd..
cd..
I am trying to run a batch file nightly to delete files in a certain directory that are older than 15 days. I am getting "Access is denied" even if I paste the command into an elevated (admin) command prompt window. This is on a Windows 7 PC. Here is the command that I found online to delete files over a certain age:
forfiles /p "C:\ProgramData\WEBSERVER\Download\X549D95" /d -15 /c "cmd /c del #path"
The user I am logged in as is a local administrator and has full control to the files in that folder. The PC is not a member of the domain so should not have group policies doing anything weird on it.
Maybe I have to do something to make this part of the command run as an administrator: "cmd /c del #path"? If so, how do I do that? I cannot find a switch for "cmd" to do that.
First of all, I am not a coder or developer and I apologize for any ignorance from this moment forward.
I am trying to make a simple batch file that will open multiple programs and uwp apps. For example, at the start of my work day I need several programs and apps to get up and running such as edge, skype, outlook16, onenote (uwp app not program), etc.
I can get normal windows programs that use .exe to do this but I am having difficulty finding out how to do the same with windows UWP.
Any help would be appreciated.
It is a bit tricky with UWP apps, but you can definitely make it.
Put the live tiles of the UWP apps you want a shortcut to in the start menu. And then drag and drop the tile itself on the Desktop. This will create a shortcut to that app. Now you can manually launch the shortcut via the batch file, or even more easily - copy the created shortcuts into the Startup folder:
C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
You can open this folder even faster by hitting Windows + R and typing shell:startup.
Other option for launching the apps would be to use their associated URI protocol. OneNote has onenote-cmd: or onenote:, Edge has microsoft-edge: (or you can use any website URL if it is your default browser). There are more URI schemes, a short list is available here for example.
I do not know about UWP, but these may be.
I wrote this answer because it was high on my search and most answer I found had little examples.
And this provides a few more ideas for programs that run in the taskbar(in the background).
Here is my "Work Start.bat" batch file sitting on my desktop:
rem Work Start Batch Job from Desktop
rem Launchs All Work Apps
#echo off
rem start "Start VS Code" "C:\Users\yourname\AppData\Local\Programs\Microsoft VS Code\code.exe"
start "Start OneDrive" "C:\Users\yourname\AppData\Local\Microsoft\OneDrive\OneDrive.exe"
start "Start Google Sync" "C:\Program Files\Google\Drive\GoogleDriveSync.exe"
start "Start Clipboard" "C:\Program Files\Beyond Compare 4\BCClipboard.exe"
start "Start Cisco AnyConnect" "C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe"
start outlook
start chrome
start firefox
start skype
start "Start Teams" "C:\Users\yourname\AppData\Local\Microsoft\Teams\current\Teams.exe" /MIN
start Slack
start Zoom
sleep 10
taskkill /IM "explorer.exe"
taskkill /IM "teams.exe"
taskkill /IM "skype.exe"
taskkill /IM "slack.exe"
taskkill /IM "zoom.exe"
taskkill /IM "cmd.exe"
#echo on
Some Apps would not start with a simple "start app" command, so I used the full path.
For some reason some were found in my user appdata folder and not in program files, I do not understand this behaviour of program storage, it makes no sense.
I used a time delay so that the apps could fully start before I sent them to the background using taskkill command
I killed explorer.exe because OneDrive opens explorer
I killed cmd.exe because it opened and stayed opened due to badly behaving apps.
The rest I killed so that they would just move to the background.
Here is my "Work End.bat" batch file to forceably close everything:
rem Work End Batch Job from Desktop
rem Forcibly Closes All Work Apps
#echo off
taskkill /f /IM outlook.exe
taskkill /f /IM OneDrive.exe
taskkill /f /IM GoogleDriveSync.exe
taskkill /f /IM BCClipboard.exe
taskkill /f /IM "vpnui.exe"
taskkill /f /IM "chrome.exe"
taskkill /f /IM "firefox.exe"
taskkill /IM "explorer.exe"
taskkill /f /IM "teams.exe"
taskkill /f /IM "skype.exe"
taskkill /f /IM "slack.exe"
taskkill /f /IM "zoom.exe"
#echo on
I do have to ensure I have saved all my work, and that files are no longer syncing.
Possibly I will need a batch file that kills everything except file sync.
The good thing about forceably killing Chrome and firefox is they ask to be restored on next start, so I can continue where I left off, assuming I saved everything.
If I don't forceably kill these they stay in the background, if I close using the Cross they do not offer me to start from where I left off.
I could then start my gaming files, in another batch file but this would be similar to the first file.
Now I can turn off the default "Start Up" Apps and use this "Work Start.bat" , because the Start Up Apps annoy me when I start my pc for gaming.
KB3114409 KB2825678 windows update patch files you may know that has caused many user to only be able to launch outlook in safe mode. that means i can not find anybody in outlook, anyway it is no good patch to me.
so i made batch file for our staff that is for uninstalling windows patch about KB3114409 KB2825678. it seems to be looking those file and uninstall. but if i have a look in installed update console, there is still remain those two.
i execute this batch file in administrator mode as well, but still same in.
#echo off
Wusa /KB:3114409 /Uninstall
Wusa /KB:2825678 /Uninstall
exit
i made it like that, but i still have those patches...
i use win7 64bit and using user mode, not administrator mode.
please any idea..?
Not sure if you really have everything on one line or if your post just turned out that way. This is what I use:
#echo off
start "" /b /wait wusa.exe /uninstall /kb:3114409 /quiet /norestart
start "" /b /wait wusa.exe /uninstall /kb:2825678 /quiet /norestart
To put all commands on one line you would need to separate them with &
but that makes it a bit harder to read. Also see WUSA /?
Its better to use MSIEXEC to remove this patch since its an "Office patch" and not for Windows.
Tutorial and script approach described at: http://blog.jocha.se/tech/uninstall-outlook-kb3114409
I have created a batch file with the following line:
forfiles /p L:\percepsrvr\SQL /s /m *.bak /d -4 /c "cmd /c del /q #PATH "
This deletes any files older than 3 days and works when I run the batch file.
However, when I try to run this batch file as part of a scheduled task the line of code fails to execute. I think it might be because of the mapped network drive (L:) but don't know for sure.
I have the scheduled task running as myself to make sure it has the same permissions as when I run it manually. The scheduled task is running on a Win2008r2 server box and L:\ is on a Win2003 SP2 server box.
Anyone know what might be keeping this from working properly or how to debug a scheduled task?
TIA
Brian
In case anyone comes across this post I found a solution as follows:
ROBOCOPY "D:\Backup Data\percepsrvr\SQL" "\\belgrade\v$\percepsrvr\SQL"
ROBOCOPY "\\belgrade\v$\percepsrvr\SQL" "\\belgrade\v$\percepsrvr\SQL\Old" *.* /move /minage:10
DEL "\\belgrade\v$\percepsrvr\SQL\Old\*.*" /Q
Basically, move the files to delete to another directory and then delete that directory (which can be done with RoboCopy).