batch-file

How to make my user input as a variable to make a folder

微笑、不失礼 提交于 2020-01-17 05:40:21
问题 (c)ToTheMaker I found this code here and I'm going to use it but the only problems is I want it to have a user input that will create the folders For example: "Enter number of folders:" The value which the user will input will be used as a variable that will create the folders. How am I going to do that? @ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION SET groupsize=10 SET n=1 SET nf=0 FOR %%f IN (*.txt) DO ( IF !n!==1 ( SET /A nf+=1 MD Cake_!nf! ) MOVE /Y "%%f" Cake_!nf! IF !n!==!groupsize! ( SET n

reg query remote computer not working

自古美人都是妖i 提交于 2020-01-17 05:24:27
问题 I have the following problem. At work I'm working on a domain and i'm writing a batch script that, among other things, queries remotely windows registry from other machines in the domain. There, things work ok. That is, a query like: reg query \\MACHINE1\HKLM\SYSTEM works just fine. However while doing some testing at home I just can't access windows registry in computer A from computer B. The same command in my small 2 PC network result in: ERROR: Cannot find network path Or something

My bat file can't run correctly, why?

做~自己de王妃 提交于 2020-01-17 05:23:28
问题 Create a new file test.bat, the content is as follows: echo aa; and execute it in the dos command line, test.bat there are no output in the window. But when I tested it in another computer, it outputs aa When I double click the bat file, it always disappeared suddenly even I add a "pause" clause line in the test.bat file. Both the systems are Window XP. Can sb tell me where is the problem, please? I have checked all the things Mofi suggested, but the problem remains. Now, I divscover when

Batch Script How to Set Variabes inside another variable

谁说我不能喝 提交于 2020-01-17 05:03:25
问题 i want to do something like this 1.bat var1=The bot now At %PlaceName% 2.bat SET PlaceName=Hotan Echo %var1% it should be like: The bot now At Hotan but it is shown like: The bot now At %PlaceName% 回答1: 1.bat @echo off setlocal set "var1=The bot now At !PlaceName!" call 2.bat 2.bat @echo off setlocal EnableDelayedExpansion SET PlaceName=Hotan Echo %var1% Another way: 1.bat @echo off setlocal set "var1=The bot now At %%PlaceName%%" call 2.bat 2.bat @echo off setlocal SET PlaceName=Hotan call

Inputting a variable into a text file, using a batch file

♀尐吖头ヾ 提交于 2020-01-17 04:56:08
问题 So I'm trying to make it so that the user sets a password, and that password is loaded into a text file to be extracted for later use. The problem is, instead of typing the variable that the user inputs in the text file, it types 'ECHO is off' (or ECHO is on, if it's on). Here is what I have written. cls set/p pass = Please enter your password: > "p.txt" (@echo %pass%) echo Password created! Thanks in advance! EDIT: Thanks to MC ND, I have the solution! set /p "pass= Please enter your

Run exe from current directory in batch

时光怂恿深爱的人放手 提交于 2020-01-17 04:15:21
问题 I'm trying to run 2 *.exe files from whatever directory the batch file is located in. Commands: @echo off :A cls Echo programs start %1myprogram.exe start %1myprogram1.exe exit This works perfect when I open my batch file simply by double clicking it, but it doesn't work when I run the batch file as administrator. I need to do this as the two exe's have to have administrator privileges. I suspect this error occurs because it runs the batch file as if it were in the SYSTEM32 folder. Is this

Trim extra pipes off end of text file in Windows

隐身守侯 提交于 2020-01-17 03:07:14
问题 So basically I have a process that outputs a text file that is pipe delimited, looks something like this: |abc123|1*|004|**gobbligook|001|%|2014-01-01||||||||||||| This is just an example, and I'm not sure if the answer involves regular expressions. If it does i will put the actual line. Anyways ISSUE So for this example the import process that accepts this file is looking for 8 pipes, but there are 20, if it sees any more pipes after the 8 it's looking for the import process fails. Question

Convert Batch file to Linux Shell script

爱⌒轻易说出口 提交于 2020-01-17 03:02:26
问题 How to convert following batch file code to Linux shell script? @echo off set TOOL_PATH="C:\Tool" set JAVA_HOME="C:\Program Files\Java\jdk1.6.0_05" echo $: Starting Tool %JAVA_HOME%\bin\java -jar %TOOL_PATH%\Updater.jar -config %TOOL_PATH%\config\config.properties Thanks in advance! 回答1: #!/bin/sh TOOL_PATH=/tool JAVA_HOME=/opt/java/jdk1.6.0_05 echo "Starting Tool" $JAVA_HOME/bin/java -jar $TOOL_PATH/Updater.jar -config $TOOL_PATH/config/config.properties But you may have to change the actual

Renaming file extension in batch

旧街凉风 提交于 2020-01-17 02:37:11
问题 I've got a few files like this: I'm wanting to change them all to *.gz This is the code I've written to try to change the file extensions: ren *.dat.gz.gz.gz.gz *.gz But this doesn't do anything. Thanks. 回答1: ren ????????.dat.gz.* ????????.gz or, if the .dat part is needed ren ????????.dat.gz.* ????????.dat.gz 回答2: Try this: @echo off setlocal enabledelayedexpansion for %%a in (*.gz) do ( set "file=%%a" set "file=!file:.gz.gz.gz=!" echo ren "%%~nxa" "!file!" ) Run it from the location of the

Having set /p ignore capital letters in batch

别来无恙 提交于 2020-01-17 01:32:06
问题 Is there any way (via tag or other wise) to have Set /p ignore capital letters in a batch script? 回答1: I don't know about ignore, but you could convert them to lower case. Set /P Text=Please type something: Set Text=%Text:A=a% Set Text=%Text:B=b% Set Text=%Text:C=c% ... Echo %Text% If you wanted to use a For command to convert to lower case: Set Text /P=Please type something: For %%i In ("A=a" "B=b" "C=c" ...) Do Call Set "Text=%%Text:%%~i%%" Echo %Text% Or replace "A=a" with "A=" , etc. to