batch-file

How to get the name of calling bat script

此生再无相见时 提交于 2020-02-24 17:27:06
问题 I need to have my 2.bat script behaviour depending on the name of calling script. Scenario: 2.bat is invoked from many other external scripts, which I am not entitled to change. Only 2.bat is under my thumb. 1.bat : ... call 2.bat 2.bat : ...here place something extracting "1.bat"... 回答1: As you cant change the calling bat there will be almost impossible to get its name if it is triggered through the cmd console (may be a memory dump could help?) as then the ProcessId will hold information

MS Batch: Check if drive is in use

☆樱花仙子☆ 提交于 2020-02-24 09:07:26
问题 I need to check if a drive (Z:) is in use (e.g. in use by an application, opened). My Batch File looks like this: Mount Z: wait 15 minutes check if drive Z: is in use IF NOT: unmount Z: ELSE: wait 15 minutes repeat.. Is there any Command for this? Thanks! 回答1: Use the IF EXIST or IF NOT EXIST combination: :FindDrive if exist Z:\nul goto Mounted timeout /T 5 goto FindDrive :Mounted NUL is the a 'virtual' file that exists in every folder. So if c:\anypath\nul exists, the drive exists. 回答2:

Batch Scripting Backing up files in USB

你说的曾经没有我的故事 提交于 2020-02-23 04:43:08
问题 Iv got my code to show a list of USb devices connected to my laptop and i can select the USB as well but when i try to back up a folder into the USB what i get instead is a folder named f in the folder i was trying to save. This is the code i have for selectong a USB device for /f "delims=" %%a in ('wmic logicaldisk where drivetype^=2 get deviceid ^| find ":"') do set "$List=!$List! %%a" :USB echo Avaiable Drive ==^> !$List! set /p "$Drive=Enter the letter of the Backup drive : " echo !$List!

Run a bat file from javascript

送分小仙女□ 提交于 2020-02-20 09:19:09
问题 I'm trying to run a bat file using javascript. I've tried using powershell but it didn't seem to work properly. Here is the code I tried: var oShell = WScript.CreateObject("WScript.Shell"); oShell.Exec("D:"); oShell.Exec("cd dir"); oShell.Exec("start user.bat"); I've also tried that: var oShell = WScript.CreateObject("WScript.Shell"); oShell.Exec("start D:\dir\user.bat"); Sometimes it runs, sometimes I get those errors "Expected hexadecimal digit", "Access is denied". I'm really confused. All

Run a bat file from javascript

若如初见. 提交于 2020-02-20 09:18:12
问题 I'm trying to run a bat file using javascript. I've tried using powershell but it didn't seem to work properly. Here is the code I tried: var oShell = WScript.CreateObject("WScript.Shell"); oShell.Exec("D:"); oShell.Exec("cd dir"); oShell.Exec("start user.bat"); I've also tried that: var oShell = WScript.CreateObject("WScript.Shell"); oShell.Exec("start D:\dir\user.bat"); Sometimes it runs, sometimes I get those errors "Expected hexadecimal digit", "Access is denied". I'm really confused. All

Task Scheduler - Access non-local drives while running task not logged in

假装没事ソ 提交于 2020-02-18 05:33:31
问题 I had a task in win scheduler that runs every minute. The task runs a .bat file which SVN updates a series of folders then executes a perl script (which in turn will run off several others). The output/'log' of the perl script (tagged by date/time) is sent to a shared drive, not local to the machine the task runs on. The whole task works flawlessly until sending the log to the shared drive. Since the task needs to run every minute I figured it would be best to use the setting 'Run whether

Task Scheduler - Access non-local drives while running task not logged in

痴心易碎 提交于 2020-02-18 05:33:12
问题 I had a task in win scheduler that runs every minute. The task runs a .bat file which SVN updates a series of folders then executes a perl script (which in turn will run off several others). The output/'log' of the perl script (tagged by date/time) is sent to a shared drive, not local to the machine the task runs on. The whole task works flawlessly until sending the log to the shared drive. Since the task needs to run every minute I figured it would be best to use the setting 'Run whether

Reading an INI file and setting them as global variables in batch

梦想的初衷 提交于 2020-02-16 06:30:12
问题 I have a batch file that does a bunch f things already and been trying to expand it to get some data from an ini file. The ini file for example looks like this [Settings1] Text=Text Text1=Text Text2=Text [Settings2] Text=Text Text1=Text Text2=Text I have figured out a way to get the section I require with the following batch @echo off setlocal EnableDelayedExpansion set "file=settings.ini" set "section=[Settings1]" set flag=0 for /f "usebackq delims=" %%# in ("%file%") do ( set line=%%# :

batch menu outlines and design [duplicate]

荒凉一梦 提交于 2020-02-16 05:19:31
问题 This question already has answers here : Using box-drawing Unicode characters in batch files (3 answers) Closed 21 days ago . a while ago i were googling to find out how I could make a batch menu with a more "professional look" instead of using symbols such as: |=====| |-----| |_____| to make outlines around a menu in batch. but I had no luck. today i randomly found this article: https://web.archive.org/web/20151204182221/https://http-server.carleton.ca/~dmcfet/menu.html and it explains that

Using a text file as input to a Powershell script

会有一股神秘感。 提交于 2020-02-14 21:06:47
问题 My group is moving to a new network where we can't directly copy from our computer in Network A to the new machine in Network B. After years on this machine in Network A, I've got project files interspersed all over the disk. I need to build a script to copy the folders and files to a backup disk. No problem there, but the network tech guy requires the total byte count to be known before copying. In CMD I've used dir /AD /S /B > C:\Users\r6540\Desktop\UserFiles.txt from C:\ to generate a huge