Go Premium for a chance to win a PS4. Enter to Win

x

Windows Batch

11K

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

I have two files say Report.csv Reference.csv

I want to write a Script will reference the Report-ID in the report file names and cross-reference with Reference file data to determine the folder location to move the report.

For eg: Name of Report.csv - R00001.csv

Data in Reference.csv as below:
ReportID      CompanyName
R-00001          BB Trust
R-00002          AA Trust
R-00003          ZZ Trust
R-00004          Canada Inc.

Here in the above, we could see that file name of Report.csv & the first cell value in the Reference.csv is same.

After lookup, the R00001.csv file needs to be moved to BB Trust folder

Likewise, for each of the Report file, same procedure needs to be followed

Please have a look over on the below BATCH script and correct the bugs.
Rep.txt
0
Important Lessons on Recovering from Petya
LVL 11
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Hi,

I need to copy thousands of image files from multiple folders on our server (within 1 main folder) to a new folder and rename it accordingly. All the details are in a text file (saved as tab delimited from an excel sheet) with the following format (excerpt from the actual file) :

\\192.168.1.118\PICTURE\0-PKG\0-PVCBAG\0001-403.GIF      \\192.168.1.118\Picture\B2B-IT\162869_1.jpg
\\192.168.1.118\PICTURE\0-PKG\0-PVCBAG\0001-501-B.JPG      \\192.168.1.118\Picture\B2B-IT\162871_1.jpg
\\192.168.1.118\PICTURE\0-PKG\0-PVCBAG\0002-050.JPG      \\192.168.1.118\Picture\B2B-IT\162878_1.jpg
\\192.168.1.118\PICTURE\0-PKG\0-PVCBAG\0003-116.JPG      \\192.168.1.118\Picture\B2B-IT\162926_1.jpg
\\192.168.1.118\PICTURE\0-PKG\0-B1\0003-114-B1.JPG      \\192.168.1.118\Picture\B2B-IT\162927_1.jpg
\\192.168.1.118\PICTURE\0-PKG\0-PVCBAG\0003-116.JPG      \\192.168.1.118\Picture\B2B-IT\162928_1.jpg
\\192.168.1.118\PICTURE\0-PKG\0-B1\0003-114-B1.JPG      \\192.168.1.118\Picture\B2B-IT\162929_1.jpg
\\192.168.1.118\PICTURE\0-PKG\0-B1\0003-114-B2.JPG      \\192.168.1.118\Picture\B2B-IT\162929_2.jpg

I have mapped the \\192.168.1.118\PICTURE\ folder as P-drive on my PC (from which I hope to run the script) if that is any help. To make it easier to understand, let me give an example here.

For first line line : \\192.168.1.118\PICTURE\0-PKG\0-PVCBAG\0001-403.GIF      \\192.168.1.118\Picture\B2B-IT\162869_1.jpg
The script would need to copy  \\192.168.1.118\PICTURE\0-PKG\0-PVCBAG\0001-403.GIF to folder …
0
I have a batch file with several xcopy commands that I have been using for years. All of a sudden the xcopy commands have stopped working giving me an Access Denied message for every file that xcopy tries to copy to the local computer. An example of an xcopy command:

C:\Windows\System32\xcopy.exe "\\Motion\Users\Nelson\Documents\My ElephantDrive\Everywhere\Patent Records" "C:\Users\User\Documents\My ElephantDrive\Everywhere\Patent Records" /D /S /Y /C  /EXCLUDE:C:\xcopyexclude.lst

I have turned off my virus protection (Bitdefender) and checked the permissions for the folders (there has been no change and I added full control for everyone just to be sure).  I can copy the files xcopy is trying to copy with Windows Explorer with no trouble.  The batch file is in my desktop. Any ideas what may be causing this behavior?
0
I am trying to convert a .bat file to a VBScript file for convenience.  I have been able to convert all parts, except the following:

Echo DateTime=%DATE%, %TIME% > "networklocation\System.log"
Echo USERDOMAIN=%USERDOMAIN%\%USERDNSDOMAIN% >> "networklocation\System.log"
Echo COMPUTERNAME=%COMPUTERNAME% >> "networklocation\System.log"
Echo USERNAME=%USERNAME% >> "networklocation\System.log"
ipconfig >> "networklocation\System.log"
systeminfo | find /I "tImE" >> "networklocation\System.log"

Open in new window


I understand that this is appending the data to a log file, but I don't know how to write the "Echo", "ipconfig", and "systeminfo" commands in VBScript.  Any help is appreciated.
0
I found the following vbscript below that can extract the Windows Product key from a Windows 7 machines. This works well for me as I do NOT wish to use a 3rd party tool for this purpose. My problem is that I need the output of the vbscript (which is displayed in a message box), echo'ed from the batch file. Just to clarify, the main file will be a batch file which then calls this vbscript and echo's the Product Key from the batch file (The reason I need to do this from a batch file is because this portion of the batch file is part of a much larger portion of the same batch file that get executed from a Remote Management System when then extracts system details from the machines and populate UDF fields).

Source of vbscript
https://gist.github.com/eyecatchup/d577a2628666a0ad1375

Actual VB code
' VBS Script to get the Windows(R) 7 Product Key from a PC's registry.
'
' Save the VBScript as "getWin7Key.vbs" somewhere on your Windows7 PC.
' Now, when you double-click the local script file an alertbox pops up
' displaying the product key stored in the machine's Windows registry.

Set WshShell = WScript.CreateObject("WScript.Shell")

KeyPath = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"
MsgBox ExtractKey(WshShell.RegRead(KeyPath))

Function ExtractKey(KeyInput)
    Const KeyOffset = 52
    i = 28
    CharWhitelist = "BCDFGHJKMPQRTVWXY2346789"
    Do
        Cur = 0
        x = 14
        Do
            Cur = Cur * 256
            Cur = 

Open in new window

0
Hi Experts,
We have multipal windows system in network, in BOD process we need to copy some files in every systems manually, its a time taking process for me. Please suggest any bat (automatic) process to short out this trouble. Every systems having user name & password.
0
I have a folder full of text files.
I need these text files names and contents written into a new text file sorted by text files date modified.

Please and thanks
0
I need someone  who are doing very well with batch scripts
then i will explain short and clear
thank you!
0
I cannot for the life of me get a bat file to run through GPO. I have stored the file on the file server in a public share, in netlogon on the DC, in the actual script folder within the policy object, ran with various switches. I have also used another bat file to call the actual bat file. The bat file will run fine manually, but not when logging on. This is a script provided by the software company used for installing one component. Any tips?
0
I will try to explain this the best I can from the information a user gave me.

So apparently he has a macro on Excel 2016 that runs which fixes a raw .xlsx file by formatting it to the end users specifications. So to break it down a program outputs a .xlsx in raw format then he opens the raw .xlsx file on his computer and runs the macro to fix the formatting.

The question we have is can we automate this process in task scheduler or something similar to run the macro on the raw .xlsx file on someone's computer or a server? Most likely the user will not have Excel open because this will occur around 5 am when no one is working.

(Program outputs .xlsx  to network drive > user's computer or server runs the automated macro to the format data > end user is able to use the output.)

Thanks for helping!

- Excel 2016
- Windows 10 Pro x64 or Windows Server 2012 R2
0
Free Tool: IP Lookup
LVL 11
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

We have an internal process that downloads a text file from our vendor. The format of the information of this file is as follows – followed by a comma.

Name of data file = TEST.IDX

Field names contained in TEST.IDX:

ID Number = 5 numbers
Loan Type = 2 Characters      
Full Name= varies up to 60 Characters
SSN = 9 numbers
App Number = 4 numbers
Collateral Code = 3 numbers
Loan Type = 4 numbers
Document name = Varies up to 60 characters
Internal  ID = 1 number
Date = 10 characters
Download Path = varies up to 100 characters

The issue is that the file TEST.IDX  - could contain a data line for the document name  called { Full Name + Credit Report }  –  that does not contain data in the COLLATERAL CODE field. The script would need to parse through the data file – TEST.IDX and then look for the data line that contains the document name { Full Name + Credit Report }. Once found it looks for a matching ID number listed in the TEST.IDX file. Once found – it would need to find the COLLATERAL CODE field. The collateral code that is found – would need to be copied onto the Collateral Code Filed for the data line that contains the document name  { Full Name + Credit Report }.

For Example. The second line below – contains the Credit Report document name called “ JOHNATHAN WILLIAMS Credit Report”.  The 6th Field in that line – does not contain a  COLLATERAL CODE. It is listed as zero. The script would look for the ID Number “55555” and look at the 6th field to find the …
0
I need a batch file to run the following from the command prompt:  wmic computersystem get model,name,manufacturer,systemtype

This batch file is for Windows 7 to get details for inventory that I am gathering.  Thanks
0
Converting ANSI to UTF8 through Command, For one Field value, Space is getting converted to Carriage return, What I am missing. Please help experts.

<Command Used>
PowerShell -Command "Get-Content 'ANSI_File' | Set-Content -Encoding UTF8 'UTF8_File'"

<Example>
Field Value (ANSI) (Space was there before %s)
abcdefghijk: %s|(abcdefgh)|(ijklmnop)

Field Value (UTF-8) (Converted to Carriage Return before %s)
abcdefghijk:  %s|(abcdefgh)|(ijklmnop)
0
Converted SRC file from ANSI to UTF-8 through a batch script, but some Latin characters sets are getting loaded with some other Latin characters. Experts PLEASE HELP

Example:-
ANSI file :- Srihas Rüpock
UTF-8 File :- Srihas Rⁿpock

Command Using to convert ANSI file to UTF file through command prompt is:-

powershell -ExecutionPolicy Bypass -NoLogo -NoProfile -Command "Get-Content 'srcfile.txt' -Encoding Oem | Out-File 'tgtfile.txt' -Encoding UTF8"
0
I'm wanting to create a batch file that will check for the existence of a device name like 'PowerMIC%' before running a program.  I'm able to run the command  " wmic path CIM_LogicalDevice where "Name like 'PowerMIC%'" get /value " which shows lots of data if the device is present or " No Instance(s) Available. " if the mic isn't plugged into the USB port ....

Any thoughts on easily doing this .....   I'm not very proficient at batch files  .....

Joel
0
Hello folks,
i have created the following script to remove profiles from PCs, however what change would i make to skip the administrator profile?

$CLIENT = Get-Content "c:\Temp\computers.txt"
 
foreach($PC in $CLIENT){
    # Testing PC connectivity
    if(Test-Connection $PC -Count 1 -Quiet){
        # Gathering users from c:\users
        foreach($PCuser in (Get-ChildItem "\\$pc\c$\users" -Directory)){
            # delete  recursively
            RD "\\$PC\c$\Users\$($pcuser.name)\Desktop\*.*"
            RD "\\$PC\c$\Users\$($pcuser.name)\Downloads\*.*"
            RD "\\$PC\c$\Users\$($pcuser.name)\Documents\*.*"
            RD "\\$PC\c$\Users\$($pcuser.name)\Music\*.*"
            RD "\\$PC\c$\Users\$($pcuser.name)\Pictures\*.*"
            RD "\\$PC\c$\Users\$($pcuser.name)\Videos\*.*"
        }
    }else{
        Write-Warning "$PC is offline"
    }
} 

Open in new window


or if anybody has a a batch that'd be great too

Thanks for looking
0
Hello all,  
Running a vbs script with FTP commands and this error popped up. -2147023741

Just did a rerun and all went fine,   scanned the web for the error and nothing showed up.  
Any ideas on what it could of been?  
Thanks
0
Source file is "ANSI" in a srcfiles folder, need to get this converted to "UTF8" through Windows batch script. Experts Please help.
I cant use any tool for it. Please help
0
I need to be able to write a batch file that will stop a service.  I know the ip addresses but I don't know how to write this into a batch file.  I need to be able to start and stop this service weekly on all computers and where it is a workgroup, I cannot do so through a gpo.  Workstations are XP

I have started this:

@ECHO OFF

::disable SEP Client Service

::Run Program

call "C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\12.1.XXXX.XXX\Bin"

smc -stop

::Run Program

call "C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\12.1.XXXX.XXX\Bin"

::enable SEP Client Service

smc -start
0
Free Tool: Subnet Calculator
LVL 11
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

here the link:https://github.com/quarkslab/quarkspwdump
and here the usage:
quarks-pwdump.exe <options>
	Options : 
	-dhl  --dump-hash-local
	-dhdc --dump-hash-domain-cached
	-dhd  --dump-hash-domain (NTDS_FILE must be specified)
	-db   --dump-bitlocker (NTDS_FILE must be specified)
	-nt   --ntds-file FILE
	-hist --with-history (optional)
	-t    --output-type JOHN/LC (optional, if no=>JOHN)
	-o    --output FILE (optional, if no=>stdout)
	Example: quarks-pwdump.exe --dump-hash-domain --with-history

Open in new window



i can't see anywere ''quarks-pwdump.exe''
0
batch file to change registry: Maximum number of logged in users using remote desktop?
i want to change this from registry:

Windows Key + R >> Type MMC.exe >> then Control + M >> Select Group Policy Object >> then Add >> then finish >> then OK

Double click on Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Connections. Limit Number of Connections = 999999. Restrict Remote Desktop Services users to a single Remote Desktop Services session = DISABLED.

Open in new window



in soemthing like this:
something like this: REG ADD "HKLM\SYSTEM\etc.....
0
I currently have a very simple batch file that I use to do a 'gpupdate' on my 45 XenApp servers.  What I have is...

for /f %%i in (\\server\software\Batches\XEN##.txt) do \\server\software\Batches\PsExec.exe \\%%i gpupdate

and then in the XEN##.txt file I have a list of my 45 servers.

This works great, however it can only do it sequentially, i.e. it takes more than 30 seconds to finish the gpupdate on XEN01, and only then will it begin the gpupdate on XEN02, so of course it takes almost 30 mins to finish doing all of them.

Is there a way to restructure the above so that the gpupdate command runs simultaneuosly on all the 45 servers?

Thanks.
0
Hello,

As the title says. Just trying to run a VBScript to change the tab in an IE window every 10 seconds. My code is:

Set WshShell = WScript.CreateObject("WScript.Shell")

i = 0

Do While i = 0
      WshShell.AppActivate "Internet Explorer"
      Wscript.Sleep 10
      WshShell.SendKeys "^{TAB}"
        Wscript.Sleep 1000
Loop


Not sure whats wrong but it just won't run correctly.
0
I need to pass two parameters to a batch script at execution. Could someone please advise of the syntax. Fields I need to pass

Folder String : This will be a folder name e.g.  c:\MyFolder

File String: This will be a filename e.g. Myfile.csv
0
I need a batch file that will run

sc query SAVService| find "RUNNING"

if it returns  anything other than running I need the batch file to

netsh interface set interface "Local Area Connection" DISABLED

It will run as a scheduled task every 15 min on the machine.

If the service returns that SAVService is running the next time it executes it sets the Local area connection to enabled.
0

Windows Batch

11K

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.