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

Hello All,

Great Day...


Could you please help me to zip files present in a folder using batch Script in windows.

We have winzip installed in our machine.

I have created one bat file with below command .

@echo off
wzzip "OutPutFile Path\Filename""Input folder path"

Open in new window



But it is not getting zipped.

Any help regarding this would be highly appreciated.

Thanks in Advance..
0
Free Tool: Site Down Detector
LVL 9
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Hello,
Can you please help with a batch or VB Script,
I need to remove from all file names in a a folder (with sub Folders)
.[mail@xxx.bz].gryphon

Example
db.opt.[mail@xxx.bz].gryphon
dbver.[mail@xxx.bz].gryphon
palrtres.frm.[mail@xxx.bz].gryphon

Should be
db.opt
dbver
palrtres.frm

Your help is greatly appreciated.
0
Hi All,

Greetings...

According to my work, I need to zip files present in a folder using batch script without using any 3rd party software.

I tried with below code ,but getting the error.error also attached below.

Any help regarding this would be highly appreciated.
'Get command-line arguments.
Set objArgs = WScript.Arguments
Set FS = CreateObject("Scripting.FileSystemObject")
InputFolder = FS.GetAbsolutePathName(objArgs(0))
ZipFile = FS.GetAbsolutePathName(objArgs(1))

'Create empty ZIP file.
CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)

Set objShell = CreateObject("Shell.Application")

Set source = objShell.NameSpace(InputFolder).Items

objShell.NameSpace(ZipFile).CopyHere(source)

'Required!
wScript.Sleep 2000

Open in new window


This code is present in zip.vbs file. We have to zip the files into Outputfile.zip file.
in command prompt  , I have entered below command

C:\Users\abc>Cscript zip.vbs input path  output path\OutputFile.zip

While executing this ,I got below error. " Path not found error" for both the input and output file path.

It will be helpful if anyone corrects me the mistake which I made in this script.
2
I have thousands of folders that I need to relocate to other folders based on a portion of the folder name. The folders look like this:

M:\Blah Blah\Blahty\Blah Blah\Projects Dept # Added\GG001128 - 4137
M:\Blah Blah\Blahty\Blah Blah\Projects Dept # Added\GG004057 - 4137
M:\Blah Blah\Blahty\Blah Blah\Projects Dept # Added\GG001242 - 7567
M:\Blah Blah\Blahty\Blah Blah\Projects Dept # Added\GG001732 - 4166X
M:\Blah Blah\Blahty\Blah Blah\Projects Dept # Added\GG001944 - 7005X
M:\Blah Blah\Blahty\Blah Blah\Projects Dept # Added\GG001946 - 7005X

Based on the last 4 or 5 characters of the folder name (if 5, will contain a trailing X), I need to relocate the folders to:

M:\Blah Blah\Blahty\Blah Blah\CUMC\4137 - NBD Nobody Has A Clue
M:\Blah Blah\Blahty\Blah Blah\CUMC\4166X - DER Dooby Doo
M:\Blah Blah\Blahty\Blah Blah\CUMC\7567 - AAC Animal Care
M:\Blah Blah\Blahty\Blah Blah\CUMC\7005X - ARK Noah

Spent a couple hours googling to no joy, and have a deadline at work I have to meet, so I'll greatly appreciate any help provided.
0
Hi we have job that copies file to a destination, So is there a way that I can be notified after all the files are downloaded completely ? Is there a feature in SQL, SSIS or Batch script that can identify and send a message or raise a flag once all the files are downloaded.
0
Hi,

I need a FOR command that will list the following list with ' as a delimiter.

SET List=a'b'c
FOR ...

Expected output
a
b
c

Thanks for your help,
Rene
0
I'm writing a vbscript wherein auotamically create a folder that rename as date/time stamp. I create vbscript wherein the telnet output file save as .text then save on the folder that automatically created. This is my script on the telnet output file.

Option Explicit

On Error Resume Next

Dim WshShell

set WshShell=CreateObject("WScript.Shell")

WshShell.run "cmd.exe"

WScript.Sleep 1000

'Send commands to the window as needed - IP and commands need to be customized

'Step 1 - Telnet to remote IP'

WshShell.SendKeys "192.168.1.1 -f C:\log.txt"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000


'Step 2 - Issue Commands with pauses'

WshShell.SendKeys ("password")

WScript.Sleep 1000

WshShell.SendKeys ("{Enter}")

WScript.Sleep 500
WshShell.SendKeys ("Enable")
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500

WshShell.SendKeys ("password")
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500

WshShell.SendKeys ("terminal length 0")
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500

WshShell.SendKeys ("show mac address-table vlan 13")
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000

WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500

WshShell.SendKeys ("{Enter}")
WScript.Sleep 500

Open in new window

0
I need a batch script to create a row in a spread sheet for every document it finds within a folder and all sub folders. The information I would need it to write to each row is (each item is a column) shown below. If the filename ends _Vnnn (where nnn = a number) this number should be extracted and written to a revision number column.

The file name
The file type (e.g.pdf)
The modified date
The file path of the folder (h:\top folder\next folder etc)
Revision Number

Would anyone be kind enough to help me with this please.
Buzzsaw-example.xlsx
0
Hello,
In the past, I have been able to store a user's username, password and server in "Manage Credentials" under User Accounts in the Control Panel. Then when I run a simple batch file to map the network drives to the server, the batch file completes perfectly.

I have tried exactly the same procedure but the batch file is asking me for user's username.

Why isn't the batch file recognizing the stored Windows credentials and completing the map drives command?
0
Note: file will be created in a directory with system date and time.
the file name will be like system_date+time(differ_based on the time)+.xml file
0
New feature and membership benefit!
LVL 9
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

I have a batch file that installs two fonts for all users when they login that I can't get to execute using the reg key:

HKLM Software\Microsoft\Windows\CurrentVersion\RunOnce

value: cmd.exe
value type: REG_SZ
value data: \\path\to\batch_file.bat

The batch file works fine run on it's own. It's just the sending to all users I'm having an issue with. I also tried the "immediate task" method with no results as well in this article:

https://serverfault.com/questions/442842/using-a-gpo-to-run-a-batch-file-once
0
hi team

we require a script which will copy the reg file to remote servers and add it in registry.

we are implementing wsus. we don't want to use the GP. so we would like to add the reg key in our servers. please help to provide a nice script.
0
Hello -

I am looking to deploy a application within SCCM 2012 and the application is a .exe and vendor says it doesn't have any installers to accommodate any management installation platforms.  I'd like to know how I can use a batch file to run exe and silently without any user interaction. I can push out from SCCM and place package in Software Center to be deployed , however there is a popup that needs software license agreement to be checked. I do not want users to have to do this and I want it silently installed. Is there any way to accomplish this with .exe?

Thanks,

nimdatx
0
according to my work,I have number of pdf files present in one folder .I need to merge all the files into a single pdf  file  based on last modified time stamp. Means first modified pdf file as first and then the rest.
I tried with the below code.

@echo off
setlocal enableextensions disabledelayedexpansion

set "root=%cd%"

>"output.pdf" (
    for /f "tokens=1,2,*" %%a in ('
        robocopy "%root%\." "%root%\." *.pdf /l /s /is /ts /ndl /njh /njs /nc /ns
        ^| sort
    ') do (
     echo( %%~nc
     for /f "tokens=1-3 delims=/" %%d in ("%%a") do echo %%f/%%e/%%d
     type "%%~fc"
    )
)




But it is producing output pdf which contains only one file which is  modified lastly.
Could you please help me to solve the issue.
Thanks in Advance..
0
Hi experts,
Have a schedule job which I would like to execute at 2am with crontab expression (command).

Question is How can I write it to execute only once please?

I know it defeats the purpose, but how to come up with the cmd pls

Eg. If I schedule it for tomorrow 2am, it should execute at 2 and it should never re-execute

Thanks in advance
0
Hello All,

Below script works fine and gets the output, I am planing to run this script against 50 Machines the output should have hostname/computername column. Thanks for help  

Import-module servermanager ; Get-WindowsFeature | where-object {$_.Installed -eq $True} | Select-Object name, d
isplayname, installstate

Open in new window

0
I have a exclude file for my command it looks like this:
Z:\folder1b\file1.cfg
C:\Users\Admin\Documents\Folder1\file1.cfg

Open in new window


I have it like that to stop these two seperate CFG files from merging, ect.
Problem is, it seems to copy it regardless. I've even tried quotes.
Thanks.
0
Hello

I need help in developing a DOS batch script that will retry the job again if it fails, it should retry up to 5 times, before an actual alert message is written to a log file

Thanks
0
Every month  we wud like to sftp over  Win 7 n Win 10 patches (.msi  .msu, ??)  to about 20 remote PCs that are located in our supplier/service providers premises as these PCs are npt part of our corporate's AD/domain n we cant Rdp/remote to them for security reason.

Can anyone provide a batch or cmd scripts tt will scan for the presence of msi or msu (or any extensions tt MS patches may come in) in a folder (say c:\MSpat )  n will execute them in silent mode (ie dont need us to input/intervene) but dont reboot after patching.  Ideally, output logs ( >>) or error ( 2>>) to 2 separate logs.  Housekeep away the patch files
0
On Demand Webinar: Networking for the Cloud Era
LVL 9
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

I have a folder A on 10 window machines located on  C drive folder temp which contains .cmd file for execution , I want to execute that .cmd file on all 10 windows machines from one machine using batch file. which should run in highest permission with run as administrator & UAC should not block when script executed.

Thanks in advance
0
HI,

I need to create a batch file to do four specific things:
1) Open cmd prompt
2) Change directory to C:\Utility
3) Run a CPAU command
4) close the cmd prompt window when complete

Currently I have a batch file with these commands to get started:

open cmd.exe
cd C:\Utility

but cmd prompt just flashes up for a second and disappears.

Please help with the above commands

Thank you
0
Hi My Fellow Scripting Peeps whom I admire because you guys know your Sh1t =)

I would like to have a simple script that i can run every time i need to help friends & colleagues
to backup their data before attempting repairs or formatting.

My reason for a progress bar or progress percentage is so that I have more or less an idea
of how long the process will take or how long before it is finished.

oh by the way... This will be my very first run with robocopy but i have used xcopy and xxcopy in the past.

XXCOPY has a dim future and XCOPY is not as robust as robustcopy(robocopy)

I hope i got all the info you need.
0
I had this question after viewing I need a batch file to search and delete registry subkeys.

How can I delete all keys under HKCU\Software\Microsoft\Internet Explorer\MenuExt that contain a given word in the key name?
0
This is my command line:
@echo off
FOR %%f IN (P*) DO type %%f >> combiness.txt & echo. >> combiness.txt

Open in new window

To put all files starting with P in a combiness.txt file, it worked on my old computer but i recently got a new one and its not working like I had hoped.
0
I have a user who puts the date he wants me to change the to reflect the update in the file name.

Example:  BMS Update 7.21.2017.xlsx

Is there a way to capture this Date in the file name so I can use it in my batch routine?  Maybe like store it in a set variable so I can use it in my batch file.       Set FileDate=FileDate

I cant use file modify date because the modify date and the date in the file name are different.
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.