Search found 136 matches

by Eureka!
13 Jul 2020 03:44
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 14910

Re: Redirect output to file without using > sign?

Another approach: @echo off setlocal set OUTPUT=output.txt set line1="<?xml version="1.0" encoding="UTF-8"?>" set line2="<gpx>" set line3="<trk>" set line4="<trkseg>" rem set line5="<trkpt lat="46.361004" lon="-1.180605">" set line6="</trkseg>" set line7="</trk>" set line8="</gpx>" (for /l %%x in (1...
by Eureka!
13 Jul 2020 03:35
Forum: DOS Batch Forum
Topic: Figuring out which computer is being used at two different locations
Replies: 12
Views: 13522

Re: Figuring out which computer is being used at two different locations

You can also define an asset tag in the BIOS - for example "Remote" - and check for the existence of that asset tag using a WMI query. Or: right before starting your script, connect some random USB stick to this machine that has volume label "Remote" and check for the existence of that (wmic volume ...
by Eureka!
17 May 2020 04:06
Forum: DOS Batch Forum
Topic: Debugging / syntax checksing tools for batch
Replies: 27
Views: 34247

Re: Debugging / syntax checksing tools for batch

EDIT:

Never mind; you solved it already ..
by Eureka!
16 May 2020 06:10
Forum: DOS Batch Forum
Topic: Debugging / syntax checksing tools for batch
Replies: 27
Views: 34247

Re: Debugging / syntax checksing tools for batch

Yanta wrote:
15 May 2020 23:52
Doesn't matter that I put there, it will always be the first non-remark after the label.
So, if you replace this line:

Code: Select all

IF /I NOT "%DoGame:~0,1%"=="Y" Echo %time% Not installing games >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
with:

Code: Select all

echo 123
pause
Your script fails?
by Eureka!
15 May 2020 06:15
Forum: DOS Batch Forum
Topic: Debugging / syntax checksing tools for batch
Replies: 27
Views: 34247

Re: Debugging / syntax checksing tools for batch

This is what I do: - run script with @echo on - On strategic places add code similar to this: PAUSE Start For-Loop1 The PAUSE command will ignore the "Start For-Loop1" part, but it will be shown on the screen, so you know where you are. And more important: it limts the amount of output at a time, ma...
by Eureka!
11 May 2020 09:17
Forum: DOS Batch Forum
Topic: able to run functions from another script?
Replies: 4
Views: 6394

Re: able to run functions from another script?

And yet another suggestion: MAIN.cmd @echo off setlocal set RESULT= call Maths :SUM 1 2 echo SUM RESULT = %RETURN% set RESULT= call Maths :MULTIPLY 1 2 echo MULTIPLY RESULT = %RETURN% MATHS.cmd @echo off setlocal set ALLPARMS=%* set ROUTINE=%1 call set PassParms=%%ALLPARMS:%ROUTINE%=%% call %ROUTINE...
by Eureka!
09 May 2020 18:39
Forum: DOS Batch Forum
Topic: Powershell comment
Replies: 7
Views: 8207

Re: Powershell comment

"Plan B" (or C?):

Code: Select all


(
echo Get-Service
echo #this is a comment
echo ls
) | powershell -command -

Notes:
- Get-Service without the trailing S
- The & should be inside the scriptblock
- I doubt if scriptblocks are even supported from a CMD prompt.
by Eureka!
02 May 2020 16:53
Forum: DOS Batch Forum
Topic: Reg Query For Loop and Reg Add failure
Replies: 2
Views: 4727

Re: Reg Query For Loop and Reg Add failure

Next time, please put your output and code between code tags (use the </> button ) That out of the way: Try your code with echo REG ADD .. instead of REG ADD ... to see what's going on. The issue is that it is returning the same result 3 times over for each key with "S/N: That will be caused by the ...
by Eureka!
29 Apr 2020 19:04
Forum: DOS Batch Forum
Topic: Can SET be filled by a command?
Replies: 7
Views: 11052

Re: Can SET be filled by a command?

Something like this? (not tetsed)

Code: Select all

setlocal enabledelayedexpansion
for %%x in (%__CD__%*) do set LIST=!LIST! "%%x"

echo LIST = %LIST%
by Eureka!
29 Apr 2020 18:54
Forum: DOS Batch Forum
Topic: file path with changing folder name
Replies: 2
Views: 4748

Re: file path with changing folder name

a new folder is created everyday with previous business day (t-1) as the folder name. [...] Here is an example of what the path to the folder would look like: C:\Users\UserA\Ad_Hoc\27Feb2020\Folder_A\File_A If you could convince the person or system that creates these folders to use a date format l...
by Eureka!
29 Apr 2020 18:48
Forum: DOS Batch Forum
Topic: Get IP from MAC adress?!
Replies: 6
Views: 7518

Re: Get IP from MAC adress?!

tvogel wrote:
27 Apr 2020 10:57
TahnX a lot. Where could i get the file you use? -> "C:\Tools\wakemeonlan-x64\WakeMeOnLan.exe"
nirsoft.net (first hit when you google "wakemeonlan.exe")

BTW: You didn't try my solution?
by Eureka!
29 Apr 2020 18:43
Forum: DOS Batch Forum
Topic: Why does this work from a command line but not from a batch file
Replies: 6
Views: 7718

Re: Why does this work from a command line but not from a batch file

You have a space character after set AppPath=%UserPath%\Applications and multiple spaces after set SRC=%cd:~0,2% Try it with: set "AppPath=%UserPath%\Applications" set "SRC=%cd:~0,2%" FWIW: My advice: organize per application instead of per system part. Makes it better readable and replacing applica...
by Eureka!
25 Apr 2020 13:48
Forum: DOS Batch Forum
Topic: Get IP from MAC adress?!
Replies: 6
Views: 7518

Re: Get IP from MAC adress?!

This is what I use to connect an off-line NAS to a non-reserved DHCP address. The intersting part for your case is the following line: for /f "usebackq" %%x in (`arp -a ^| findstr /i "%MAC%"`) do set IP=%%x .. but in case you want to use it for something similar as I did (waking up NAS, getting IP-a...
by Eureka!
06 Apr 2020 14:27
Forum: DOS Batch Forum
Topic: Windows Batch - Print line file containing exclamation mark
Replies: 6
Views: 14397

Re: Windows Batch - Print line file containing exclamation mark

Try it without the ENABLEDELAYEDEXPANSION as that uses ! for variables (like %): @echo off setlocal for /F "usebackq delims=" %%A in ("test_file.txt") do ( call :ACTION "%%A" ) endlocal exit /b %ERRORLEVEL% :ACTION echo. This line is: [%~1] goto :EOF Result: This line is: [TEST != TEST] Note: I also...