Windows Batch

12K

Solutions

11K

Contributors

Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.

Share tech news, updates, or what's on your mind.

Sign up to Post

Trying to use ROBOCOPY in a batch program to copy files from C:\folder to C:\Windows\syswow64 and I am gettting an access denied. Using /COPYALL /s as a switch.

Tried running the CMD also with administrator rights and the same thing. Please advise.
0
If I issue 'wmic product get name,vendor,version', it won't list out Chrome, Firefox,
certain apps (from app vendors) though these softwares (chrome, Ffox, apps) are
listed when I go to Control Panel's  "Programs & Features".

What's the command (exclude PowerShell pls) that could list out what's shown in
"Programs & Features"?  
When I do  "dir c:\Program Files" or "dir c:\Program Files (x86)", somehow
Chrome or certain apps seen in "Programs & Features" are not necessarily
there.

Also, need a similar command of what's listed in "View Installed Updates".

I'm on Win7, Win10 & Win2012/2016.    

Needed something other than WSUS to list patches installed on the Windows
endpoints (as colleague says WSUS has issue with this & we got audit finding).
0
Hello,

What is the best way to deploy PowerPoint template throw GPO for whole domain users.


I have 3 files for use :
.cmd
.msi
.cab

the cmd file containe:

@ECHO off
SETLOCAL
SET TSManager=TSManager.exe

TASKLIST /FI "IMAGENAME EQ %TSManager%" 2>NUL | FIND /I /N "%TSManager%">NUL
IF "%ERRORLEVEL%"=="0" GOTO TaskSequenceDeployment

:ApplicationDeployment
MSIEXEC /I "%~dps0PowerPointTemplate.msi" /L*v "%temp%\PowerPointTemplate_1.0.0_Eng.log" ALLUSERS=1 REBOOT=ReallySuppress /qb-!
SET RETURNCODE=%errorlevel%
EXIT %RETURNCODE%

:TaskSequenceDeployment
MSIEXEC /I "%~dps0PowerPointTemplate.msi" /L*v "%temp%\PowerPointTemplate_1.0.0_Eng.log" ALLUSERS=1 REBOOT=ReallySuppress /qn
SET RETURNCODE=%errorlevel%
EXIT %RETURNCODE%

Thanks
0
Hello experts,
I need to run telnet through cmd to check the access of url related to 6000 till 6100 port.
I am looking for a .bat that:
1-Read the various IP reported in a txt file with port:
Example:
url 6000
url 6001
Export the result for each line export result (in the same file).
File should be located at %cd% folder.
If you have questions, please contact me.
Thank you.
0
Hello experts,
I have the following code which allows me to send single file to a website.
I would like to modify as following:
1-Add a for each loop and place the various names in another list.txt file. Script should loop the various names reported in the the list.txt and send files.
If you have questions, please contact me.
Thank you in advance for your help.

@echo off

rem Set curl path.
set CURL="curl/curl"

cd "%cd%"

rem Set site url.
set SITE_URL=

rem Set login.
set LOGIN=

rem Set password.
set PASSWORD=

rem Set service number.
Set SERVICE_NUMBER =

rem Set action url.
set ACTION_URL=%SITE_URL%/sendFile/%SERVICE_NUMBER%

rem Set input file path and name.
set PARAM_PROXY=

set FILE="file=@toto.csv"

rem Import the file.
curl -v -k %ACTION_URL% -u %LOGIN%:%PASSWORD% -F %FILE%

pause

Open in new window

0
START "" "C:\Program Files (x86)\JAM Software\TreeSize Free\TreeSizeFree.exe"
MSG * "Please select the drive to analyse space
This is a new line
This is a new line"

I need to insert a line break in this windows message file after space and new lines
I have tried ^ and \n
0
Hello experts,
I have the following batch file to export files.
I would like to
-Set reference folder instead of using cd command
-Add a for in loop in order to: loop the various files in a directory instead of reporting file name.
ie@filename.csv
If you have questions, please contact me.
Thank you.

@echo off

rem Set curl path.
set CURL="curl/curl"

cd "C:\Temp"

rem Set site url.
set SITE_URL=

rem Set login.
set LOGIN=

rem Set password.
set PASSWORD=

rem Set action url.
set ACTION_URL=%SITE_URL%/sendFile/51

rem Set input file path and name.
set PARAM_PROXY=

set FILE="file=@filename.csv"

rem Import the file.
curl -v -k %ACTION_URL% -u %LOGIN%:%PASSWORD% -F %FILE%

pause

Open in new window

0
Hello Experts

At the moment we are running a batch file on every computer to empty the downloads folder every week, but it deletes only the files but not the folders.
could you be able to help me by creating a new batch file that clears all the contents of the downloads folder for all the user's profiles on the PCs?
we would like to know as well if we can add this on the group policy and it can deploy to all the users in the company.

Here is the one we are using which we are running from a scheduled task list.

forfiles /p "C:\Users\PofileName\Downloads" /s /m *.* /c "cmd /c Del @path" /D -0

Thank you very much.
0
i have a batch script that i have running as a logon script via AD user. i need a way to exclude this command from running on certain servers. is there a way of doing this. Please see below

---Script commands-----
mkdir "%USERPROFILE%\OneDrive - Tenant"
mkdir "%USERPROFILE%\OneDrive - Tenant\Favorites"
mkdir "%USERPROFILE%\OneDrive - Tenant\My Pictures"
mkdir "%USERPROFILE%\OneDrive - Tenant\My Videos"
mkdir "%USERPROFILE%\OneDrive - Tenant\My Music"
subst h: "%USERPROFILE%\OneDrive - Tenant"

exit
-------------
2019-05-08_17-02-32.jpg
1
I am looking for a batch, VB or Powershell script that can parse a file name for a date, and then delete that file if the Date is older than 90 days. Files will be in subfolders, so the script would need to be able to drill down into the subfolders.
Here example of file names:

2019-01-02T080219~queue~520118152~+520118152~311242d8-10ea-49ae-869c-81a43434d40b.WAV
2018-05-10T112639~call~1004~605191811~c97043a6-2bfe-44c8-bde4-b0c3596ede60.WAV
2018-05-02T144725~call~1005~151981173112~a272d339-d85e-4742-a6d0-a988ba6594ea.WAV
2018-10-23T144526~call~2411~18189199~6774130d-a249-4c18-8700-8c629bdf3841.WAV
1
I recently started messing with SharePoint Foundation 2013 here at work.  I started copying some folders/files over and almost immediately ran into an issue with folders/files throwing errors due to there being illegal characters in the folder/file names.

I'm now looking for a way to rename any and all folders/files that contain an ampersand in the name.

I'm hoping someone here could help me with creating a script for this.  I'm thinking it would need to consist of 2 "parts" due to some folder/file names having a space before/after the ampersand and other folder/file names having no space before/after the ampersand.

Essentially, I'm looking to have a script created that can do the following on a Windows Server OS:
- search a folder and all sub-folders for any and all folders and filenames containing space&space <-- example file/folder name Alligators & Crocodiles
- rename these folders/files spaceandspace <-- example file/folder name Alligators and Crocodiles

- search the same series of folders for any and all folders and files containing no space&no space <-- example file/folder name Up&Down
- rename these folders/files spaceandspace <-- example file/folder name Up and Down

I'd appreciate any help you could provide me with.
1
Hello experts,

I am looking for a batch, powershell or vbscript to cover the following requirement:

-Loop a reported folder with drill down
-Check the various files and folder
-Replace SourceString by TargetString
-SourceString and TargetString should be reported as parameter

-Example:
BaseDir= C:\Test
SourceString= “_”
TargetString “-“

-Various files and folders which contains source string “_” should be replaced by target  “-“.

If you have questions, please contact me.
Thank you.
1
Hello experts,

I am looking for a batch, powershell or vbscript to cover the following requirement:

Loop a reported folder (no drill down needed):
-Rename the various files with reported folder name and add a numbering based on modified date from oldest to newest
-Example:
BaseDir= “C:\toto” contains filea.csv filea.xls fileb.csv
Expected result is the following:
toto-1.csv, toto-2.xls, toto-3.csv

If you have questions, please contact me.
Thank you.
0
Hello experts,
I have the following command which allows me to remove files based on extension and date provided at:
29144863
I was wondering the quickest way to report multiple folders and use the same commands:
Such as:
Arrayfolders= C:\Folder1 C:\Folder2 C:\Folder3
ForFiles /p "%ArrayFolders%" /d -30 /c "cmd /c if @isdir == FALSE if /i @ext == \"txt\" del @file"

Open in new window

Thank you very much for your help.
0
Hello experts,
I have the following procedure to remove files. I was wondering how to add extension attribute to remove files based on date and specific extension.
If you have questions please contact me.
Thank you.
WITHOUT SUBFOLDERS
ForFiles /p "C:\FolderName" /d -30 /c "cmd /c if @isdir == FALSE del @file"
WITH SUBFOLDERS:
ForFiles /p "C:\FolderName" /d -30 /c /s "cmd /c if @isdir == FALSE del @file"

Open in new window

0
We are using the BCP command to export data from a 2012 r2 sql database to a CSV file.   There seems to be a end of line character on the last line of data that is causing issues [] .   Is there a way to remove this?  

Command:

          set @body = 'bcp ' + db_name() + '.dbo.##ENSORDERPROD out ' + @outfile + ' -c -t, -T -S EINCUtility05'
                        exec master..xp_cmdshell @body
0
Hi,

I have java maven build project. I need to connect to a linux box and transfer few files from the local machine to a folder to linux and run the commands.

Please help me which maven dependency i can use and connect to the linux box. This is for writing cucumber automated tests using java.
0
Hello experts,
I am looking for a windows batch which will call java API with the following requirements:
1.      Check if yearly folder exists (2019) if not create it. Inside this folder check if monthly folder exists (2019-05) if not create it. The root folder which contains those folders to defined as LogFolder
2.      Check in csv folder location if there are csv files if not go to exit else copy the various files in folders related to previous step. Csv in which are csv files to check to defined as InputFolder
3.      Generate author file as a csv file and list file name; author. Method for this file should be append without cleaning previous lines and files should be generated in LogFolder. For this step I already have the procedure reported in the following question 29144240
setlocal EnableDelayedExpansion

set BaseDir=%Cd%
set OutFile=%BaseDir%"\owner.txt

(
    for /f "tokens=*" %%A in ('dir /q "%BaseDir%\*.csv" ^| findstr /b /r /c:"[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]"') do (
        set Line=%%~A
        echo.!Line:~62!,!Line:~39,23!
    )
)>"%OutFile%"
Exit

Open in new window

4.      Continue and call the java api:

If you have questions, please contact me.
0
Windows Server 2016 - Need to zip up all *.txt files in a directory.  Client doesn't want to install 7zip.  So was thinking Powershell but I have never used it or know how to use it.

My current scripts are .bat

Can I run PShell within a .bat?


I found this example, but not sure how to actually execute it.   Can I use my variables I set in my .bat?  

Very confused.
0
Hello experts,
I have multiple CSV files in a folder.
I am looking for a powershell or a Windows batch to list in a result.csv the file name in column a and the author (who create the file) of the file in column a.
Thank you in advance.
0
Hello,

We are currently running SCCM 2012 and our systems with clients installed are primarily Windows 10 thought there are a few Windows 7 systems until we get rid of legacy applications.

I have a batch file that searches a file for "APS".  If it finds it the batch needs to immediately exit because we do not want APS software removed.

If APS is not found the script drops to an Uninstall section.

Here is the problem I'm having.  When the script finds APS and exits, I need that to show up as a success in SCCM.  To do that I'm using "Exit /b 0" but I'm still getting the following error message:

There was a problem applying changes to the software. You can try again.  Blah blah.  0x87D00324(-2016410844)

REM Find AFC or APS / If found Error Level = 0
find /n "APS" c:\mps\chkdcases\CountCheckedOutCases.txt
if %errorlevel%==0 Exit /b 0 Else GoTo Uninstall

Open in new window

0
Greetings experts,

I have this cmd code and what it does is that it searches my computer and deletes every file which is 0 bytes in file size.

for /r %F in (*) do if %~zF==0 del "%F"

Open in new window


I need help editing it such that it only looks at the user's download folder and only deletes mp3 files.

Any help is much appreciated! :)
0
Good Day,
Can you please help,
I'm searching for a script (batch, Vbs, PowerShell), to login to a remote ftp, (User Name & Pwd)
delete ,bak files older than XXX days.

I Don't have access to run any scripts on the remote ftp server.
I need to run the script from my computer.

Your help is greatly appreciated.
0
I have a the following dir structure

..\area\year\month\PDFFILE

not all areas have the same years inside
not all years have the same months (some months have no data so no month dir is created for those)
if there is a month directory it means it contains a pdf inside it


sample dir:

ford\2018
ford\2019\Jan\chart.pdf
ford\2019\Feb\chart.pdf
chevy\2017
chevy\2018
chevy\2019
chevy\2019\Jan\chart.pdf
toyota\
.
.
I need a script batch,vb or powershell or python whatever
that will help me create the following HTML TABLE


                   2019
     ford   chevy   toyota
Jan   x       x
Feb   x
Mar

The X should be an html link to the PDF, but I can do this with search / replace for the X so the main objective is to generate the table code.

I cannot change the directory structure
If you have a solution using csv file with excel and pivot tables it is also acceptable (so i can then use some text manipulating functions to get my desired html)

I have tried with some dir to html utils but they are very
limited and I end up with many tables that then I have to manually stitch together

Please Help
1
Hello experts,
I have the txt attached.
I am trying to extract value between label for the various lines:
eg:

<item id="l_BevelTextGallery" imageMso="BevelTextGallery" label="BevelTextGallery"/>
<item id="l__3DMaterialMixed" imageMso="_3DMaterialMixed" label="_3DMaterialMixed"/>

The result should be:
BrevelTextGallery
_3DMaterialMixed

I suppose that I can do that with findstr.
How should I set up the command?
Thank you very much for your help.
icons-labels.txt
1

Windows Batch

12K

Solutions

11K

Contributors

Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.