Questions tagged [batch]

A batch file is the name given to a type of script file, a text file containing a series of commands to be executed by the command interpreter under MS-DOS and Microsoft Windows.

This was the first extension used by Microsoft for batch files. This extension runs with MS-DOS and all versions of Windows, under COMMAND.COM or cmd.exe, which execute its commands, normally line-by-line.

339 questions
2
votes
3 answers

How to put DayOfWeek value into file name?

I would like to use the numerical part of the output of "wmic path win32_localtime get dayofweek" to number backup files. Something along the lines of: FOR /F "tokens=2 delims=\n" %%DoW IN ('wmic path win32_localtime get dayofweek') DO (echo…
aelfinn
  • 21
  • 2
  • 2
2
votes
3 answers

How to work with batch script dialog?

I am working on a batch script to remap a network drive in windows xp. I have found it to work out well for the most part with: net use G: /delete net use G: \\file\share However, if there are any connections to the drive, it will prompt: There…
MattUebel
  • 927
  • 4
  • 13
  • 32
2
votes
2 answers

using xcopy or copy to back up files?

I have a local drive that contains a directory per user: c:\user1\ c:\user2\ c:\user3\ and I have a remote drive (via a share) that contains the same directory tree: f:\user1\ f:\user2\ f:\user3\ inside each directory can be any number of files but…
Mr Aleph
  • 231
  • 1
  • 5
  • 10
2
votes
1 answer

SQL, pl/sql, sqlplus: how to return a variable to DOS batch file?

I have a DOS batch file which invokes sqlplus, which executes some basic SQL contained in another .sql file, and I want the last part of it to return a value back to the dos batch file. However, while there are many examples via Google on how to do…
weiji
  • 268
  • 1
  • 3
  • 10
2
votes
2 answers

Executing batch file from sql server job

I want to create backup job on sql server. And i want to execute batch file in job. I just wonder the part of executing batch file from sql job. Do you have any idea? Any help would appreciated. use MyDb go BACKUP DATABASE MyDb TO DISK =…
uzay95
  • 161
  • 1
  • 5
2
votes
5 answers

How do I redirect/save the console to a file and keep it visible on the screen?

I want to save a program's output (stdout) to a file but still be able to see the output on the screen in realtime. I need a solutions for both Linux and Windows.
sorin
  • 8,016
  • 24
  • 79
  • 103
2
votes
2 answers

Execute a remote command on a Mac from Windows

What's the easiest way to execute a single command on a Mac from a remote Windows machine, via batch? I would like something that works without a preset configuration (like SSH credentials) on either machines, as I need to apply this on several…
ripper234
  • 5,890
  • 9
  • 41
  • 49
2
votes
1 answer

Getting full windows version on Batch or Powershell. (Like "Microsoft Windows [Version 10.0.18363.900]" On Windows Server 2016

I have this issue. Using just command "ver" in batch I get: Microsoft Windows [Version 10.0.18363.900] I need the last sub-build version (900) for an script to determine if windows is on latest patch level (or close to it, after checking the main…
DefToneR
  • 527
  • 6
  • 14
2
votes
1 answer

How to secure the SQL credentials in a batch file (PowerShell inside) to run a script using sqlcmd

My goal is to create a batch file which performs a SQL (express) DB backup every time it's executed. But I don't want to store a clear password in that batch. Using PowerShell, I successfully created a secure txt file which stores the plain text…
2
votes
6 answers

PHP vs Batch file for mysql cronjob?

My server details: OS: Windows Server 2003 IIS6 Plesk 8.xx installed (currently using Plesk to set the cronjob) I need your advice. I have 2 methods: Method 1: Using php + mysqldump, create databases backup files into gzip, and then send email with…
mysqllearner
1
vote
1 answer

Windows batch file scripting: how to get directory named with latest date (yyyy-mm-dd format)?

I have a directory with many subdirectories. Each subdirectory is named with the yyyy-mm-dd format. I'm writing a Windows batch file and I need to grab the directory name with the most recent date and put that string into a variable. The last…
slantalpha
  • 305
  • 1
  • 5
  • 17
1
vote
1 answer

how to use logical operators and tasklist

I m using logical operators and tasklist command in a single sentence but it is not working. My batch script: tasklist \fi"memusage gt 18000" && \fi"memusage lt 19000" Can anyone help me out?
Akash
  • 11
  • 2
1
vote
1 answer

Deleting $RECYCLE.BIN from userprofile via logoff script

I've got a RDS solution which utilizes User Profile Disks. There is a bug with UPD's which means that every now and then permissions on the users individual Recycle Bin's get mixed up and the user is then unable to delete items (they can still shift…
1
vote
0 answers

Q: How Robycopy deals with pointers to directories (short-cuts)

For example, in the statement below robocopy %src% %target% copy:DATSO the parameter %src% may be a pointer to a directory. In my case, Robocopy FAILED TO COPY the content the pointer is pointing to. In case above %src% is a shortcut to directory…
Uri L
  • 11
  • 3
1
vote
1 answer

Send a SecureString Password from CMD file to Powershell

I have a CMD file from which I have to run a Powershell script passing in username and password: i.e: PowerShell -File "%1" -Computer "%2" -Username "%3" -Password "%4". Is there anyway to send a SecureString password from the CMD to the powershell…
Jay Bhardwaj
  • 65
  • 2
  • 6