We help IT Professionals succeed at work.

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.

Hi all,

How would I get the below batch file to report outcome to a text file

echo off
net use P: /delete /yes
taskkill /F /IM explorer.exe & start explorer
TIMEOUT 15
net use P: \\(servername)\personnel\%username% /persistent:yes
0
I have a WinSCP batch file that I am trying to utilize for uploading a file.  The batch when run does open, but logs in only and does not upload the file or exit even from the script.  Just keeps the window open.  Any help would be greatly appreciated.  Attaching file.
71142Orders.txt
0
Hello experts,

I have multiple svg files in SourceFolder, I am looking for an script to save them to TargetFolder with a new extension .jpg

Requirements:
-Be able to report as parameter SourceExtension, TargetExtension, SourceFolder, TargetFolder, LogFile.
-Log the various that have been save to new extension.

If you have questions, please contact me.
0
Hello experts,

I have the following SVG file.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path d="M230 798c12 0 21-10 21-21 0-12-9-22-21-22h-32c-5 0-9-2-12-6s-4-8-4-15V232c-1-10 6-18 14-19h28c6 0 11-3 16-8 4-4 6-10 5-16-1-10 6-18 14-19h57c10 1 17 10 16 19-1 6 1 12 5 17 4 4 10 7 16 7l25-1c10 2 17 10 16 22v11c0 11 10 21 21 21 12 0 22-10 22-21v-9c3-33-22-62-57-66h-8c-7-23-27-40-54-43h-61c-25 3-45 20-52 43h-12c-33 4-57 33-53 64v498c-2 16 3 31 13 44 10 12 24 20 43 22h34zm379 100c22 0 43-9 59-26 15-21 23-46 21-70V440h112c22 1 43-5 63-21 29-28 29-75-2-105-18-14-40-20-61-19H413c-22-1-43 5-62 19-15 14-24 34-23 53-1 20 8 40 24 55 18 13 39 19 60 18h115v361c-2 25 6 50 23 72 15 16 36 25 58 25h1zM410 397c-12 1-23-2-31-8-5-5-8-13-8-22 0-8 3-16 7-19 9-7 21-11 34-10h391c12-1 24 2 31 8 12 12 12 31 2 41-9 7-21 11-33 10H647v407c1 15-4 30-12 40-7 7-16 12-26 12-11-1-21-5-27-11-9-12-13-26-12-43V397H410zm-52 401l25-1c32-3 57-33 54-63V489c0-12-10-22-22-22-11 0-21 10-21 22v247c1 9-6 18-14 19h-22c-12 0-21 9-21 21s9 22 21 22z"/></svg>

Open in new window

I have multiple SVG files with the same structure.
The idea is to read all SVG files located in specific folder and generate new version in another folder with the following structure:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
<path style="fill: #888" d="M230 798c12 0 21-10 21-21 0-12-9-22-21-22h-32c-5 0-9-2-12-6s-4-8-4-15V232c-1-10 6-18 14-19h28c6 0 11-3 16-8 4-4 6-10 5-16-1-10 6-18 14-19h57c10 1 17 10 16 19-1 6 1 12 5 17 4 4 10 7 16 7l25-1c10 2 17 10 16 22v11c0 11 10 21 21 21 12 0 22-10 22-21v-9c3-33-22-62-57-66h-8c-7-23-27-40-54-43h-61c-25 3-45 20-52 43h-12c-33 4-57 33-53 64v498c-2 16 3 31 13 44 10 12 24 20 43 22h34zm379 100c22 0 43-9 59-26 15-21 23-46 21-70V440h112c22 1 43-5 63-21 29-28 29-75-2-105-18-14-40-20-61-19H413c-22-1-43 5-62 19-15 14-24 34-23 53-1 20 8 40 24 55 18 13 39 19 60 18h115v361c-2 25 6 50 23 72 15 16 36 25 58 25h1zM410 397c-12 1-23-2-31-8-5-5-8-13-8-22 0-8 3-16 7-19 9-7 21-11 34-10h391c12-1 24 2 31 8 12 12 12 31 2 41-9 7-21 11-33 10H647v407c1 15-4 30-12 40-7 7-16 12-26 12-11-1-21-5-27-11-9-12-13-26-12-43V397H410zm-52 401l25-1c32-3 57-33 54-63V489c0-12-10-22-22-22-11 0-21 10-21 22v247c1 9-6 18-14 19h-22c-12 0-21 9-21 21s9 22 21 22z"/>
</svg>

Open in new window

1.The script should add
style="fill: #888" between : path and d=
2.In the script I should be able to put the StringToAdd, FirstStringInBetween and the LastStringInBetween as parameter. If you have questions, please contact me.
Example:
StringToAdd='style="fill: #888"'
FirstStringInBetween='path'
LastStringInBetween='d='
Thank you for your help.
0
we have two different types of meetings we hold each week in zoom.  the links to both those meetings are static and don’t change.  is it possible to send everyone a batch file that will automatically install two shortcut links on their windows desktops?
0
Hello experts,

The following script allows me to copy files from subfolders to single folder.
Rem ======================================================================
Rem Author: 
Rem Creation date: 2019/09/13 22:04:38
Rem Description: copy files from subfolders to single folders and remove duplicated
Rem ======================================================================


@echo off
setlocal EnableDelayedExpansion

rem Define from and to folders

set CurrentDir=%~dp0
set BaseDir=%CurrentDir%Base
set DestDir=%CurrentDir%Dest

rem Exit of base folder does not exist
if not exist "%BaseDir%" (
    echo *ERROR* Input folder "%BaseDir%" does not exist.
    exit /b
)

rem Create dest dir if needed
if not exist "%DestDir%" (
    echo *ERROR* Input folder "%BaseDir%" does not exist.
    exit /b
)

rem Find all files in base, get sortable modified date, write to temp file
(
    for /r "%BaseDir%" %%a in (*.*) do (
        call :GetLastModified "%%~a"
        echo !LastModified!,%%~a
    )
) > "%TEMP%\temp.txt"

rem Sort by modified date, newest first, copy onlu newest file to dest
for /f "usebackq tokens=1,2 delims=," %%A in (`sort /r "%TEMP%\temp.txt"`) do (
    if exist "%DestDir%\%%~nxB" (
        call :GetLastModified "%DestDir%\%%~nxB"
        if "!LastModified!" LEQ "%%~A" (
            echo COPY newer file: "%%~B"
            copy /y "%%~B" "%DestDir%">NUL
        ) else (
            echo SKIP older file: "%%~B"
        )
    ) else (
        echo COPY new file:

Open in new window

0
I have a set of ~100 folders that are all named sequentially, ie CPL-XXXX. Within each folder is a standard set of folders, and I would like to make a copy of the contents of some of these folders to another location so that I have a compiled set.

For example
root\CPL-XXXX\1 Client Drawings   <-- Copy *.PDFs in this folder to root\CPL-MASTER\1 Client Drawings

root\CP1-XXXX\2 CSV-DXFs <-- Copy *.CSVs in this folder to root\CPL-MASTER\2 CSV-DXFs

Would it be reasonable to run this with a batch file or powershell?

If you need any other details please let me know!
0
I had built a batch file to get result on stand alone server as per below and i getting result as per expected.

How may i run the same command for remote server from a text file

@echo off
cd\
bcdedit | find "Nointegritychecks"
pause
0
Hello experts,

I was wondering if there is a way in Powershell & Windows batch to get the full path of active document displayed other than Windows office document such as png and pdf files?

Thank you in advance for your help.
0
Hi all,

I created a batch script and was wondering if someone could let me know if there are any syntax errors before I deploy this out.   Currently we have a customer that needs to have a directory purged nightly.   Reason is when the come in the next day their application still shows previous days data which mixes up with their current data the next day.   Here is the batch script I wrote.  Appreciate the help as always.

echo deleting file

del "D:\CZM-HFA2i\EM\Data_Export\Processed *.*" /s /f /q
del "D:\CZM-HFA2i\NM\Data_Export\Processed *.*" /s /f /q
del "D:\CZM-HFA2i\OP\Data_Export\Processed *.*" /s /f /q
del "D:\CZM-HFA2i\WM\Data_Export\Processed *.*" /s /f /q


echo Done!
0
hi
i have an application that can work in ONLINE mode and OFFLINE mode
When application starts, it read a config.xml where it find parameters to start offline or online
My goal is make two small batch file for my user so it can change to OFFLINE and ONLINE without make complex change on xml file
something like put 3 file in directory C:\application:
Config.xml (really used)
ConfigONLINE.xml
ConfigOFFLINE.xml

ONLINE and OFFLINE is only a copy oh the same file with different parameters

My problem is not make mistake with file in use, so batch file has to rename and manage file in the right way!
Checking some condition in order to understand if now is ONLINE or OFFLINE
Example -> two batch rename other with _NOUSED, and two batch when start check if any files are named with _NOUSED in order to understand which is used!

Please help! Thanks!
M
0
I would like to use a script to effectively copy data from one computer to a server, create a zip file, and password protected.
What would you suggest?
0
Hello Experts,
I am required to execute a batch script which starts or stops a service on Windows Server 2012 machine. I however do not want the UAC window asking for admin privileges to pop-up, as I am actually invoking the batch execute from another application in an automated fashion. While I do have admin rights on the machine, it restricts me from accessing the registry or the Task Scheduler.

Can I please know if there is a way out?
1
I would like to modify the attached Script so that a Title is added at the top of the output.xlsx file.
The Titel should be:  "Report"

Thank you.
CSV-to-Excel.ps1
0
Hi,

Firstly thank you for taking a look at my problem.

What I need to do, is to somehow create a script, that will look at contents of a text file and change it from a layout of a pipe delimitered file to a csv file.

ie

1|2|3|4 would change to
1,2,3,4.


Would anyone have any ideas on how to accomplish this?
0
C:\Folder\Output.txt

The text always has values next to the group of words below.  (Some numberic values have been entered to show an example:

Total Stnd PU: 19
Total C PU: 12
Total Extra Stnd PU: 2
Total Extra C PU: 2
Total P:


I would like to run a script against this Output.txt so that the script looks far numeric values at the end of each of:

Total Stnd PU:

Total C PU:

Total Extra Stnd:

Total Extra C Pu:

I would like the script to look to the right of these words and add all the values and then put the value after the words:

Total P:  

So after the script runs, the file should be resaved and it should look like this;


Total Stnd PU: 19
Total C PU: 12
Total Extra Stnd PU: 2
Total Extra C PU: 2
Total P: 35

Thanks in advance for your assistance.
0
Trying to call an OdiOSCommand from Command line.

I have the script working and it successfully calls the ODI scenario.  The issue I have is trying to call it from another server.  It tries to execute from the server that it is launched.   There is a job run on another server, when it completes then I want it to call my ODI scenario.


Any ideas? It's on the same network.   I don't think this is necessarily an ODI issue but more a windows batch job thing.

.Bat contents

\\ODIServer01\e$\app\Middleware\OracleDIAgent\user_projects\domains\OracleDIAgent\bin\startscen.cmd -INSTANCE=OracleDIAgent2 MAP_STG_PEOPLE 001 UAT 005


When I run it from my desktop or the other server, it tries to look for the startscen.cmd  on the local computer.
0
Trying without success to create a bat file to copy a file creating a backuip version.

 If possible I'd like the copy of the file created with the data and time stamp at the time of creation.

For example: Original File name 'GRBDQDb01_2013.accdb'  Copied file name 'GRBDQDb01_2013_20200221_1100.accdb'

If that isn't possible I'd like the copied file to create anew version rather than overwrite an existing file of the same name.

For example: Original File name 'GRBDQDb01_2013.accdb'  Copied file name 'GRBDQDb01_2013_X.accdb', where X is the number of version that exist.

The file I want to copy is named 'GRBDQDb01_2013.accdb'.

It is in directory 'I:\My Documents\Access_Databases\GRBLaw\GRBDelinq'

This is what I have so far but it doesn't copy the file, let alone stamp it with the data and time or create anew version.

C:
cd I:\My Documents\Access_Databases\GRBLaw\GRBDelinq
copy I:\My Documents\Access_Databases\GRBLaw\GRBDelinq\GRBDQDb01_2013.accdb I:\My Documents\Access_Databases\GRBLaw\GRBDelinq\GRBDQDb01_2013_PreCompress.accdb 

Open in new window

0
I would like to modify this script or even have another script run on the output if needed, so that any data in the output file which are "numbers stored as text"
will be converted to "numbers"... and the file resaved.
CSV-to-Excel-Copy.ps1
0
I would like to modify the attached Script so that I have control over renaming the column headers, perhaps making them Shorter, or
having them over one another as follows:

For example instead of:

Sight # /Control

Perhaps...

Sight#/
Control

or just simply

Cnt#



In other words I would like to rename so that I can shorten the headers of the columns to allow more readable space on the page..
And for other columns of choise as well.

Is this possible?
Thanks again.
source.in
0
Modify Powershell script so as to add a line at the bottom which says:

Total Lines:  

This should total the amount of line in the Source.in excluding the line with the Column Headers.

Additionally,  I would like to rearrange some of the columns in the Output, for example I would like the "Tot PC Qty" column to output first.
I may change the order of some of the columns later.
Thanks in advance.
Script4.ps1
source.in
0
I would like to modify the script so that under the Ref# it also lists the following


Ref:#  
Date:
Tantmt #:


For the Date:  It should pulls from the Date showing in the Data but only month day and year.
The Tantmt# data will always be the same as well, so this should up only once in the header.

Additionally in the output, except for the header, the Ref# / Imp # column should be omitted, the Date and Tantmt# column should also be omitted.
But should remain in the header.
Script2.ps1
Source.in
0
I would like to modify the attached script, so that it omits the following columns from the Source.in file so that they are not showing in the Ouput file.

Sight # /Control
Out From
Out To
L By
Notes

Thanks very much..
Script2.ps1
Source.in
0
Currently the output of the following script produces this..

Ref#:  1009

Item:                 Full P:          Part P:
10-1000          2                  0
11-1111          1                  0

I would like to modify the attached script so that each line is displayed in it's entirety with all columns,
however
at the very bottom one last line is added to the output file so that it reads:

Totals:    

And then totals all of the following columns..

Tot PC Qty
Code 1 Qty
Code 2 Qty
Code 3 Qty
Full P
Part P
Stnd PU
C PU
Extra C PU
Extra Stnd PU
Script.ps1
Source.in
0
I would like to modify the attached Powershell script to product the DesiredOutput, as attached.

I have included the Script.ps1, the Source.in file, as well as the current Output.out file and the DesiredOutput.out file.

Looking forward to some assistance.  Many thanks,
Script.ps1
Source.in
Output.out
DesiredOutput.out
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.