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

Hello experts,
I have a bunch of csv files located in C:\csv
I need to make sure that column I & M have the YYYYMMDD value. The rest of values will remain the same.
The idea is to have script  which reads the various files  in C:\csv, generates revised version of files as specified in previous point (YYYYMMDD value for column I & M)  in C:\out .
Columns involved by the change I & M should be related to a variable.
I attached dummy file.
If you have questions, please contact me.
Thank you in advance for your help.
0
CompTIA Cloud+
LVL 13
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Hello experts,
I have the following modules attached which I used in my personal Add-in.
I have a mapping table to follow up the various sub procedures.
I would like to set up a script in order to.
Generate a csv by .bas in a yyyyymmdd_hhmm folder and report in column A the sub procedure name and in column B the name of .bas file name information should be reported in ascending order
I attached .bas files.
Example:
Sub procedure name 1;Bas name
Sub procedure name 2;Bas name
Sub procedure name 3;Bas name

If you have questions, please contact me.
g2bRangesFormulas.bas
g1aStringsFormulas.bas
0
Hello experts,
I have A C:\Folder which contains multiple subfolders such as conf, lib, input, out, logs exports, etc.
I would like to launch robocopy command and exclude files of specific subfolders such as logs and out. The difficult part is that I need to exclude files of specific subfolders but keep the folder empty.
My attempt is.
 Robocopy C\Folder C:\Destionation /e /xf *.* 

Open in new window

The problem with this is that I exclude all files.
What I need is to exclude all files of specific folders and keep the folder involved empty.
If you have questions please contact me.
Thank you very much for your help.
0
Hello experts,
I have the following command
Del C:\folder \*.csv* C:\folder2\*log.* /q /s 

Open in new window

I would like to exclude of the delete operation a specific file with the following name mapping.csv
If you have questions, please contact me.
Thank you.
0
After using the used Ideapad S10-3 a few times, it kept
updating Win 7 updates with message:
"Failure configuring Windows updates
    Reverting Changes
  Do not turn off yr computer"

When I boot up in "Safe Mode", got the above message
too & sometimes it will go thru into "Safe Mode" windows,
just that I can't locate in Control Panel "System & Security"
but only "System" : don't see any option to disable
Windows auto-update.

Is there any way to disable it at command prompt or
where did I miss?
0
Hello experts,
I have various csv files in a specific folder I would like to:
-Replace the value 05 by 06 in column C
-Script should have SourceString TargetString.
I attached dummy file.
Windows batch, Powershell, VBscript and MS VBA approaches are more than welcome.
If you have questions, please contact me.
Thank you.
Dummy-file.csv
0
Is there a way to execute Powershell 'as administrator' from command line?  When I open a command window on the Server and select 'Run As Administrator' then run my main script that then calls this script it works great.  If I try and schedule the main script in Task Scheduler this part doesn't run.  Thus was thinking a permissions issue.  Not really sure as nothing writes to my log file......

@echo off

if not exist %ARCHIVEDIR%\PBCS\Backups\%Timestamp% mkdir %ARCHIVEDIR%\PBCS\Backups\%Timestamp%

setlocal
set Source=%FILEDIR%\Backup_Data\%AppName%\%AppName%_FY*_Export_SUI.txt
set Target=%ARCHIVEDIR%\PBCS\Backups\%Timestamp%\%AppName%_Data.zip
powershell.exe -Command "Get-ChildItem '%Source%' | Compress-Archive -DestinationPath '%Target%' -Force"


exit /b

Open in new window

1
Hello,
I am tried to copy folder structure from folder a to folder b exlcuding all files.
I don't understand why files are copied with the following command:
robocopy folder a folder b /e xf *.*

Open in new window

Thank you
1
I'll need a command/script that will list out what's installed in
the corporate's PCs & save outputs to a shared folder.

"wmic product show ..."  won't even show Chrome, Firefox, plug-in
while 'psinfo -accepteula -s' shows Chrome, FFox but not plug-ins
(eg: Zoom, Webex, browsers' plug-ins) & Java 8 Upd ...

"program features" will show plug-ins, Java, Chrome, FFox etc
but it's in GUI so can its output be extracted out by script?
0
Hello experts,
I am trying to list in 3 commands:
-All full path subfolders (immediate subfolders) on a folder
-All full path files on a folder
-All full path files and (immediate subfolders) on a folder

Drill down not required.
command should output a list.txt in %cd% folder

I tried  for second requirement this:
for /d %%a in ("%CD%\*") do echo %%~fa

Open in new window

but it doesn't work.

Batch and Powershell approaches are more than welcome.

Thank you in advance for your help.
0
Fundamentals of JavaScript
LVL 13
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Hello experts,
I am looking for a .bat that covers the following actions:
1.      execute “robocopy /e Source folder Destination folder” based on a csv file.
2.      csv file should be located in the same folder of .bat
3.      csv delimiter:“;”
4.      log file to generate with the various success and fail robocopy actions
I attached dummy csv file.
If you have questions, please contact me. Thank you very much for your help.
0
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
JavaScript Best Practices
LVL 13
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

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

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.