batch-file

Why does my batch script fail to execute when run as administrator?

折月煮酒 提交于 2020-01-07 06:26:29
问题 I am trying to create a windows batch script that will allow me to deploy preparation updates for Windows 7 64 bit but the script will not launch properly. I have all of the files inside of the same folder and I am attempting to extract the files then install them through dism when I launch it normally the files extract but dism does not launch correctly, when I run as administrator the files will not extract and dism exits with code 2. What am I doing wrong? expand -F:* .\Windows6.1

How to get path relative to the working directory?

坚强是说给别人听的谎言 提交于 2020-01-07 04:59:06
问题 I have a script that recursively loops through all .txt files in the working directory and subdirectories and does something with that files. Now I would like to exclude all files in certain subdirectories that are listed in a exclude.txt file: @ECHO OFF SETLOCAL EnableDelayedExpansion for /r %%f in (*.txt) do ( CALL:processFile %%f %%~df%%~pf ) GOTO:EOF :processFile SET file_=%~1 SET path_=%~2 <- %%~df%%~pf is the full path :( find "!path_!" exclude.txt IF !ERRORLEVEL! EQU 1 ( REM do

How to schedule running a bat file not using Windows Task Scheduler?

陌路散爱 提交于 2020-01-07 04:57:07
问题 I have a batch (*.bat) file that triggers a Python script and this script takes about 25 minutes to complete interactivly (through command prompt manuallly). This batch file needs to run in the morning on a daily basis. When I tried to set it as a Scheduled Task on Windows Task Scheduler and ran it there, it took nearly double the time than it did interactively. Even if I set the Priority settings from the default 7 to 4 (higher priority) in the xml, it didn't make any differnce. Changing the

Valid batch file variable names?

北城以北 提交于 2020-01-07 04:44:09
问题 I have the following problem with batch files. I simplify the problem below. Running the following batch file, foo.bat, returns word in standard out (in this case, command prompt window) instead of hey . foo.bat @SET 1word="hey" @ECHO %1word% However, executing echo %1word% from the command line returns hey . Is there a reason this should/might be the case? Are numbers not allowed to prefix environment variable names? 回答1: You can create and use environment variables with names that begin

Controlling codepages in a cmd window when running batch scripts

痞子三分冷 提交于 2020-01-07 04:17:47
问题 I have problems controlling character code pages in a Windows cmd window, or rather in DOS scripts (.bat files) I use for certain tasks on my Windows 7 office computer. Here is the problem: One of my scripts is used to open certain files in their respective programmes, e.g. C:\Stuff\Büroeinrichtung\MyFile.xlsx The crucial thing here is the u-umlaut (ü) in the directory name. In my script I use Start "" "C:\Stuff\Büroeinrichtung\MyFile.xlsx" to start Excel and open the file. This works as long

Bat file - Net use from remote desktop not work well in some cases

ぐ巨炮叔叔 提交于 2020-01-07 04:16:13
问题 I try to run .bat file from remote desktop. I do it by run the next command: net use m: \\the-ip-of-the-remote-computer mypassword /myuser // Execution works well then, I try to xcopy from the remote desktop to my computer. So I write this: net use t: \\the-ip-of-the-remote-desktop mypassword /myuser xcopy \\the-ip-of-the-remote-computer my-libary But in some cases, this command is not execute well. I also try this, and it doesn't work: net use m: \\the-ip-of-the-remote-desktop mypassword

batch to extract part of text file containing a keyword between two strings

做~自己de王妃 提交于 2020-01-07 04:07:08
问题 Say, i have a text file test.txt as below: ee eee aaaaa aaaaa bbbb 546 iiiii fffffff qq aaaaa qqq aaaaa bbbb 123 iiiii fffffff suppose numbers which are marked bold is called as ID then i need part of file between the first aaaaa which appears just before ID-123 and first fffffff which appears after the ID-123 i.e Output: aaaaa bbbb 123 iiiii fffffff Can it be done using batch? 回答1: EDIT : I modified the program below in order to fulfill these additional requirements: 1- Extract all sections

Batch file to copy files from folders&sub folders using a file list only if file size greater than

此生再无相见时 提交于 2020-01-07 03:59:12
问题 We have images of our warehouse stock within our database. We will pull a list of the file names for those images into a .txt file. The content of the file-list.txt will be for example: 060128412948.jpg 068912475982.jpg etc. We have 3 images for each stock 2 of them are low resolution and 1 of it is a high resolution image. I need the script to only copy the high resolution image for each stock from the folders/sub-folders into a mother directory. This is what I have so far but this only

Batch File to Delete File

会有一股神秘感。 提交于 2020-01-07 03:51:41
问题 Can someone please help me to make a batch file to delete files beginning with the name Stock Level which are .csv files stored in C:\Windows\Temp folder. I would like to test it first to see what it proposes to delete before I make it live so if someone can show may what I need to delete to make it live as well. Thanks very much in advance for your help. Roy 回答1: As a batch file, @echo off setlocal for %%a in ("c:\windows\temp\stock level*.csv") do echo(del "%%a" should generate your list by

Replicate Behavior of a Batch File in a Custom Action

旧时模样 提交于 2020-01-07 03:40:55
问题 I'm creating a wix installer at work, and I need to be able to replicate the behavior of this batch file in a custom action: start /d "C:\Program Files (x86)\Remindex" INSTSRV.EXE RemindexNP "C:\Program Files (x86)\Remindex\SRVANY.EXE" I am trying to create a service using a normal windows application, which SRVANY.EXE can do. This batch file runs fine normally, but I can't seem to get a custom action to do the same thing. I have tried this: <CustomAction Id="RunNP" FileKey="FILE