Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

6751.

Solve : MS-DOS 6.22 w MS Client TCP/IP need to email from batch file?

Answer»

There's quite a few Win98 PC's in the business WORLD still...
In 3rd World countries they most LIKELY out-number XP.

6752.

Solve : Batch file to remove old pgms on Flash Drive?

Answer»

Sorry, that title was hard to write, to explain what I'm wanting to do.

I take my Utilities Flash DRIVE with me on Service Calls. On it I have all the very latest programs and updates, that I use to clean up, tune up and protect a customer's PC.
I already have a batch file on my PC to copy everything in my "Output" directory, on drive E, to the flash drive, using
XCOPY, to copy only the new or updated files.

I keep my Output directory up to date, almost daily, and I remove old, out of date, entries (files). But my
flash drive(s) can become loaded up with old and out of date files.

I'd now like to write a batch file, to do my Flash Drive cleanup for me, by comparing what's in my "Output" folder
on drive E to my Flash Drive ( N ) and removing all the files that are not on E.
So, I'll wind up with my Flash Drive being an exact duplicate of the files in "Output" on E.
Does that MAKE sense?

Any help would be greatly appreciated.

Thank You!
Shadow I'm no good with batch files, but have you considered using the excellent Microsoft SyncToy program for this?
One of the modes it can be run in compares everything in the "left" folder (your output folder) to everything in the "right" folder (your flash drive) and then copies any files that are different, and removes any files that are not present. This can work two ways to create exact copies, or it can work one-way, so the "left" folder will not change as nothing is copied from the "right" folder.
I sue "left" and "right" as that's how MS documentation REFERS to the folders as well as how they are shown in the UI. This might not be exactly what you're after, and I'm sure there is a method to do this via batch, but I thought I'd mention it as it's a lightweight, free program that can do what you're asking and other functions too. Potentially, you could use it to replace the batch file you already have, to copy new files across, too.Thanks for the suggestion.
I've long resisted, adding more programs to my PC, if I can use what's already there.

A batch file to do what I WANT to do, can be added to the end of my existing batch file,
to do a 'cleanup' after I update my flash drive(s).

For decades, I've only written the most simple batch files and the syntax to do the job I want to do, totally escapes me.

Quote from: TheShadow on June 03, 2013, 09:43:51 AM

Thanks for the suggestion.
I've long resisted, adding more programs to my PC, if I can use what's already there.

A batch file to do what I want to do, can be added to the end of my existing batch file,
to do a 'cleanup' after I update my flash drive(s).

For decades, I've only written the most simple batch files and the syntax to do the job I want to do, totally escapes me.


yeah why add a program in a less than a minute when you can write a program/script to do nearly the same thing over the span of a day or two.... Well, I guess I can think of several reasons...

Robocopy MAKES this fairly simple. you can use a /PURGE switch to delete files that aren't in source from the destination.

I'm sure the functionality could be made into a batch file if needed for XP or earlier. I won't be the one writing it, though I was just looking for some help, not a verbal Reprimand.

I thought this was the DOS section. Guess I was wrong.

I'll look for help elsewhere.

My post was just an alternative suggestion as i know that utility works great and I don't know much batch. I understand where you're coming from though and hopefully someone is able to help.TheShadow,
Often there are many piratical solutions to a problem.
Yes, this is the DOS section, but it is generally understood that a windows solution may be offered. Few are really using MS-DOS on a PC.

Use pf 'RoboCopy' is along the spirit of a command line job.

Quote
Robocopy, or "Robust File Copy", is a command-line directory replication command. It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was first introduced as a standard feature in Windows Vista and Windows Server 2008. The command is robocopy.
http://en.wikipedia.org/wiki/Robocopy
IMHO the suggestion of using Photocopy fills the requirement you specified.
Photocopy, or even Robocopy does not do what I want.

I'm sorry for wasting everyone's time.

Moderator.. Please close this thread. I'm done here.



This is called mirroring, or one-way sync. The syntax is like this for Robocopy:

Robocopy [source] [target] /MIR

[source] is the reference folder (or root of a folder tree)
[target] is the folder (or root of a folder tree) you want to keep up-to-date by reference to [source]

Quote
I'd now like to write a batch file, to do my Flash Drive cleanup for me, by comparing what's in my "Output" folder
on drive E to my Flash Drive ( N ) and removing all the files that are not on E.
So, I'll wind up with my Flash Drive being an exact duplicate of the files in "Output" on E.

Assuming your 'Output' folder is E:\Output and your pen drive is drive N the following should make the pen drive exactly like the Output folder.

Robocopy E:\Output N:\ /MIR

If the pen drive was blank, the first time you ran that command, it would create, on the pen drive, a copy of whatever was in E:\Output, including any subfolders and their contents.

If the pen drive was not blank, any files or folders not in E:\Output would be removed.

If you then removed a file or folder from E:\Output or a subfolder below it, then ran it again, then the corresponding items would be removed from pen drive N:\

If you added a file or folder to E:\Output and ran the command, then those items would be added to pen drive N:\

If you edited or updated a file in E:\Output or its tree, it would be detected and would replace a file of the same name in the same place on N:\

I just tested this on a hard drive folder (source) and pen drive (target) and as far as I can see it does what you were asking for, TheShadow, so I'd be interested to hear why it doesn't do what you want, so I could suggest a modification or some other command line solution.



Quote from: TheShadow on June 03, 2013, 12:39:34 PM
Photocopy, or even Robocopy does not do what I want.

Odd. when I did Robocopy /? I got the opposite impression. You have two folders and you want to remove files not present in A that are present in B. PURGE can be used for this. If you want to sync the entire folder (add new files and delete ones not present in the source) there is also the /MIR switch noted by Salmon Trout.

Unless of course you aren't after the desired functionality at all and are focussed on having some sort of batch file for this purpose for whatever reason.Quote from: TheShadow on June 03, 2013, 09:05:19 AM
I keep my Output directory up to date, almost daily, and I remove old, out of date, entries (files). But my
flash drive(s) can become loaded up with old and out of date files.

I'd now like to write a batch file, to do my Flash Drive cleanup for me, by comparing what's in my "Output" folder
on drive E to my Flash Drive ( N ) and removing all the files that are not on E.
So, I'll wind up with my Flash Drive being an exact duplicate of the files in "Output" on E.

Yeah, you want the /MIR function of robocopy.
This is extremely powerful and also destructive if you use the wrong folders. Be careful.

"N:\data folder" is the target drive

Code: [Select]@echo off
robocopy "E:\output folder" "N:\data folder" /FFT /R:0 /MIR /NP /FP /NDL /NJH /NJS

Quote from: foxidrive on June 04, 2013, 02:10:01 AM
Yeah, you want the /MIR function of robocopy.
This is extremely powerful and also destructive if you use the wrong folders. Be careful.
Good advice foxidrive! I normally throw a '/nocopy' switch onto the command line when testing a Robocopy script prior to full implementation.
Thanks Ocalabob - I didn't know about the /nocopy switch. It goes to show how some things don't sink in even when when you read about them.I think the OP decided to take his ball home.
It's likely that he got the replies by email, and found out the info, even if he doesn't want to play.
6753.

Solve : CMD MODE vs Device Manager show different values?

Answer»

I have a question regarding the command MODE and setting COM port SETTINGS and the VALUES displayed via device MANAGER and the registry (which are not consistent)?!
When I type MODE COM1 it shows the values, but these values do not match what I see in device manager or the following registry key (HKLM\Software\Microsoft\Windows NT\CurrentVersion\Ports). If I TRY setting the COM1 values via "MODE COM1:115200,N,8,1,P" it shows those changes when I type MODE COM1 but device manager and the registry key show the original values. If I change the COM port settings in device manager the registry gets updated but MODE COM1 doesn't reflect those changed values. -- Can anyone explain this and if using MODE COM1:xxxxxx is valid? (I'm testing on Windows XP, Windows 2003, Windows 7)

Thanks in advance!

6754.

Solve : Why is 'pause' command usually skipped in a batch file??

Answer»

I found several times that 'pause' command was not executed as EXPECTED in my batch files. It's usually executed after execution of several following commands. If one of following commands is 'exit' or 'shutdown', I can't FIND it's executed. How come?Give at least one actual EXAMPLE of code, preferably more, not a summary or description, where this happened.
Hello? Anybody there?
SORRY, it could be my MISTAKE.

6755.

Solve : Problem Writing Over Existing Files?

Answer»

I wrote a batch file that exports all of the registry hives,

HKEY_CLASSES_ROOT,
HKEY_CURRENT_USER,
HKEY_LOCAL_MACHINE,
HKEY_USERS, and
HKEY_CURRENT_CONFIG, to an external hard drive for backup.

The letter assigned to the external drive is G:

The batch file names the files:

001 HKEY_CLASSES_ROOT (HKCR).reg.txt
002 HKEY_CURRENT_USER (HKCU).reg.txt
003 HKEY_LOCAL_MACHINE (HKLM).reg.txt
004 HKEY_USERS (HKU).reg.txt
005 HKEY_CURRENT_CONFIG (HKCC).reg.txt

It WORKS beautifully the FIRST time I run it. But, if run it a second time, it gives me these messages.

For the backup file for 001 HKEY_CLASSES_ROOT (HKCR).reg.txt

The operation completed successfully

For the backup file for 002 HKEY_CURRENT_USER (HKCU).reg.txt

Error: Cannot create a file when that file already exists.

For the backup file for 003 HKEY_LOCAL_MACHINE (HKLM).reg.txt

The operation completed successfully

For the backup file for 004 HKEY_USERS (HKU).reg.txt

Error: Cannot create a file when that file already exists.

For the backup file for 005 HKEY_CURRENT_CONFIG (HKCC).reg.txt

The operation completed successfully

For some reason it doesn't have a problem overwriting the backup files for

001 HKEY_CLASSES_ROOT (HKCR).reg.txt,
003 HKEY_LOCAL_MACHINE (HKLM).reg.txt, or
005 HKEY_CURRENT_CONFIG (HKCC).reg.txt,

but it does have a problem with

002 HKEY_CURRENT_USER (HKCU).reg.txt and
005 HKEY_CURRENT_CONFIG (HKCC).reg.txt

I used the CACLS command on the two files I was having trouble with, to alter the permissions, and give them full control.

I typed the following commands into the command console:

First I changed the directory to the external hard drive with the command

CD "G:\Registry (Backup Files)"

Then i typed in

CACLS "002 HKEY_CURRENT_USER (HKCU).reg.txt" /e /c /g Owner:f

and

CACLS "004 HKEY_USERS (HKU).reg.txt" /e /c /g Owner:f

and it reported these two statments:

processed file: G:\Registry (Backup Files)\002 HKEY_CURRENT_USER (HKCU).reg.txt

and

processed file: G:\Registry (Backup Files)\004 HKEY_USERS (HKU).reg.txt

So, it processed both files and gave them full control, but it still will not let me overwrite them.

I used the program Unlocker to see if the files were in use, and locked by the system or not, and they were not. So, I am at a loss as to why I cannot overwrite these files.

They are not locked by the system, and they have full permission to be overwritten.

I don't want get around this problem by deleting, moving or copying them to another location.
I just want overwrite them.

Got any IDEAS about how to overwrite these files?

ThanksTry renaming all your current backups to "FILENAME.reg.txt.tmp" then check to make sure it wrote correctly, and if so delete "*.tmp".Exporting the hives may not give complete copies.

I used this under XP - or Cobian backup can do volume SHADOW copy.


ERUNT - The Emergency Recovery Utility NT
=========================================

Registry Backup and Restore for WINDOWS NT/2000/2003/XP

v1.1j, 10/20/2005, Freeware
Written by Lars Hederer

6756.

Solve : copy files of multiple folders and rename them?

Answer»

I have list of folders like this!


files in all the folder are named that way

I want EXTRACTING them in one folder without losing the order ([MFT]Nuit_119 to [MFT]Nuit_128)
the result will appear like this

I didn't find the way to do it with cmd because I want to do it without any software just with windowstry this:
Code: [Select]@echo off
md FULL
for /f "delims=" %%A in ('dir /b /a:d ^| find /v "FULL"') do (
cd %%A
for /f "delims=" %%B in ('dir /b') do (
echo copy "%%B" "..\FULL\%%A_p%%B"
)
cd ..
:: rd /q /s %%A
)

If you like it, remove "echo" and "::" (but only remove "::" if you want to delete the folders and files not in FULL)

It goes in the folder with [MFT]Nuit_xxx folders. will rename all the files "[MFT]Nuit_###_p##"

EDIT: make sure you don't have folders named "1" and "10" as it will order them 1,10,2,3,4,5,6,7,8,9. to get around this, MANUALLY put 0's (zeros) in front of all the numbers until they are the same number of digits 01,02,03,04,05,06,07,08,09,10. I'll look into making this automatic, but that might not be possible with only windows commands.

EDIT2: here is how you can organize them without the manual input (UNTESTED)
Code: [Select]@echo off
setlocal EnableDelayedExpansion
set name=<PUT YOUR FOLDER NAME HERE WITHOUT THE NUMBERS AT THE END>
set end=<PUT THE END NUMBER HERE>
md FULL
for /l %%Z in (1,1,%end%) do (
if exist !name!%%Z echo !name!%%Z >>tmp
)
for /f "delims=" %%A in (tmp) do (
cd %%A
for /f "delims=" %%B in ('dir /b') do (
echo copy "%%B" "..\FULL\%%A_p%%B"
)
cd ..
:: rd /q /s %%A
)
del tmp
If that doesn't work then explain how you want the 01.jpg 02.jpg etc files to be renamed. The third IMAGE gives no clue as to how they should all appear in one folder, as the filenames don't relate to the first two images at all.

Quote from: hackerwz on August 02, 2013, 09:15:45 AM

I want extracting them in one folder without losing the order ([MFT]Nuit_119 to [MFT]Nuit_128)
the result will appear like this
Quote from: foxidrive on August 02, 2013, 10:24:59 PM
If that doesn't work then explain how you want the 01.jpg 02.jpg etc files to be renamed. The third image gives no clue as to how they should all appear in one folder, as the filenames don't relate to the first two images at all.
I said that I want extracting them in one folder considering that I have a list of chapiter(Folders) of manga like narutochapter01 to narutochapter200 I wish extracting all of them at once in
one volume folder which contains nautochapter01 to chapter200's pictures
I use CDisplayEx to read manga and it doesn't support subdirectories READING pictures forcing me to switch from folder to folder therefore I have to extract file from chap01 and then rename chap02's files and extracting them .... it does not matter For the filenames I just have to use Windows to rename them in bulk
Please clarify the adjustment of the code because I am a total beginner in coding and I just learned how to say hello in cmd
PS : tell me if you find another solution like alternative softwareI forgot to thank the helpers Test this in an empty folder, that contains some test folders with the JPG pictures. It will move them all into the empty folder and rename them.

Code: [Select]@echo off
for /f "delims=" %%z in ('dir *.jpg /b /s /a-d ') do (
for %%a in ("%%~dpz%\.") do (
move "%%z" "%%~nxa_%%~nxz"
)
)
6757.

Solve : About fetching files in folder whose name containing blank?

Answer»

Below is my program for comparing files in two folders. It works well if no space character exists in folder names. But if there is a space in folder name, it goes wrong from loop of "FOR /d %%H in (*) DO ". I tested this program with c:\av1\11 vs c:\av1\22. There is a sub-folder "kk yy" under c:\av1\11.
In case of "kk yy" being empty, after showing "files done, then subdir", it shows
"to compare %~fH :::: c:\av1\22\kk yy\%~nxH"
"The follwing usage of the path operator in batch-parameter substitution is invalid: %~fH" "C:\av1\22\kk yy\%~nxH"
In my opinion, it shouldn't show "to compare ...." for folder "kk yy" is empty. No any iteration should be executed, I think.

In case of "kk yy" containing a file "0000", it shows
"c:\av1\11\kk yy\0000 ++++ c:\av1\22\kk yy\0000
"The system cannot find the path specified"

Is there any way to conquer the issue from folder containing SPACES?


:cmpdir dir1 dir2
setlocal enabledelayedexpansion

@echo on
pushd %2
@echo off

for /f "delims=" %%A in ('cd') do set dir2=%%A
popd

echo %1 ***vs*** %2

pushd %1
echo to compare file first
FOR %%G in (*) DO (
echo file: %%G
echo %%~fG ++++ %dir2%\%%~nxG
if not exist %dir2%\%%~nxG (
echo file %dir2%\%%~nxG disappeared
goto :cmpdir_err
)
fc /b **~fG %dir2%\**~nxG &GT; nul
if !ERRORLEVEL! neq 0 (
echo file %dir2%\%%~nxG corrupted
goto :cmpdir_err
)
)
echo files done, then subdir
FOR /d %%H in (*) DO (
echo === to enter %%~fH
if not exist %dir2%\%%~nxH (
echo folder %dir2%\%%~nxH disappeared
exit /b 255
)
echo to compare %%~fH :::: %dir2%\%%~nxH
call :cmpdir "%%~fH" "%dir2%\%%~nxH"
if !errorlevel! equ 255 goto :cmpdir_err
)
:cmpdir_ok
popd
exit /b 0

:cmpdir_err
popd
exit /b 255Try putting the file names in quotes.It doesn't work.

6758.

Solve : How to get Startup folder in all versions of Windows??

Answer»

There seems several ways to get location of startup; such as
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
or
C:\Documents and Settings\%username%\Start Menu\Programs\Startup

But I wonder a general way to get the path to the folder of startup in all versions of Windows in DOS command box.You would make exceptions for each version of Windows.In Windows 8 it is here:

"c:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup"

Should work for Vista/7/8.
Since there is no general method to get it, it causes another issue: how to know the version of Windows? There must be a way to know the version of Windows and then we can determine the way to get the Startup folder.You could use a VBScript:

getstartup.vbs
Code: [Select]WScript.Echo Wscript.CreateObject("Wscript.Shell").SpecialFolders.Item("Startup")
batch:
Code: [Select]FOR /F "delims=" %%i IN ('cscript /nologo getstartup.vbs') DO SET startupfolder=%%i
Quote from: Stan Huang on June 03, 2013, 06:36:33 PM

Since there is no general method to get it, it causes another issue: how to know the version of Windows? There must be a way to know the version of Windows and then we can determine the way to get the Startup folder.
Type VER at a cmd prompt.In my Windows 7, I typed "ver" in DOS Command and I got "Microsoft Windows [Version 6.1.7601]" which I can't get infer from it that this is a Windows 7 system.
In my POSReady 2009, I got "Microsoft Windows XP [Version 5.1.2600]".Quote from: Stan Huang on June 05, 2013, 01:42:37 AM
I typed "ver" in DOS Command and I got "Microsoft Windows [Version 6.1.7601]" which I can't get infer from it that this is a Windows 7 system.

Yes you can.

1.
http://www.robvanderwoude.com/ver.php

2.
http://en.wikipedia.org/wiki/Ver_(command)

Windows 1.0 1.04
Windows 2.0 2.11
Windows 3.0 3
Windows for Workgroups 3.11 3.11
Whistler Server Preview 2250
Whistler Server alpha 2257
Whistler Server interim release 2267
Whistler Server interim release 2410
Windows NT 3.1 3.10.528
Windows NT Workstation 3.5 3.5.807
Windows NT Workstation 3.51 3.51.1057
Windows NT Workstation 4.0 4.0.1381
Windows 95 4.0.950
Windows 95 OEM Service Release 1 (95A) 4.00.950
Windows 95 OEM Service Release 2 (95B) 4.00.1111
Windows 95 OEM Service Release 2.1 4.03.1212-1214
Windows 95 OEM Service Release 2.5 C 4.03.1214
Windows 98 4.1.1998
Windows 98 Second Edition 4.1.2222
Windows Millenium Beta 4.90.2476
Windows Me 4.90.3000
Windows NT 5.00 (Beta 2) 5.00.1515
Windows 2000 (Beta 3) 5.00.2031
Windows 2000 (Beta 3 RC2) 5.00.2128
Windows 2000 (Beta 3) 5.00.2183
Windows 2000 5.00.2195
Windows 2000 Professional 5.0.2195
Windows XP (RC 1) 5.1.2505
Windows XP 5.1.2600
Windows XP, Service Pack 1 5.1.2600.1105-1106
Windows XP, Service Pack 2 5.1.2600.2180
Windows XP, Service Pack 3 5.1.2600
Windows XP Professional X64 Edition 5.2.3790
Windows .NET Server interim 5.2.3541
Windows .NET Server Beta 3 5.2.3590
Windows .NET Server Release Candidate 1 (RC1) 5.2.3660
Windows .NET Server 2003 RC2 5.2.3718
Windows Server 2003 (Beta?) 5.2.3763
Windows Home Server 5.2.3790
Windows Server 2003 5.2.3790
Windows Server 2003, Service Pack 1 5.2.3790.1180
Windows Server 2003 5.2.3790.1218
Windows Longhorn 6.0.5048
Windows Vista, Beta 1 6.0.5112
Windows Vista, Community Technology Preview (CTP) 6.0.5219
Windows Vista, TAP Preview 6.0.5259
Windows Vista, CTP (December) 6.0.5270
Windows Vista, CTP (February) 6.0.5308
Windows Vista, CTP (Refresh) 6.0.5342
Windows Vista, April EWD 6.0.5365
Windows Vista, Beta 2 Preview 6.0.5381
Windows Vista, Beta 2 6.0.5384
Windows Vista, Pre-RC1 6.0.5456
Windows Vista, Pre-RC1, Build 5472 6.0.5472
Windows Vista, Pre-RC1, Build 5536 6.0.5536
Windows Vista, RC1 6.0.5600.16384
Windows Vista, Pre-RC2 6.0.5700
Windows Vista, Pre-RC2, Build 5728 6.0.5728
Windows Vista, RC2 6.0.5744.16384
Windows Vista, Pre-RTM, Build 5808 6.0.5808
Windows Vista, Pre-RTM, Build 5824 6.0.5824
Windows Vista, Pre-RTM, Build 5840 6.0.5840
Windows Vista, RTM (Release to Manufacturing) 6.0.6000.16386
Windows Vista 6.0.6000
Windows Server 2008 6.0.6001
Windows Vista, Service Pack 2 6.0.6002
Windows 7, RTM (Release to Manufacturing) 6.1.7600.16385
Windows 7 6.1.7600
Windows 7, Service Pack 1 6.1.7601
Windows Server 2008 R2, RTM (Release to Manufacturing) 6.1.7600.16385
Windows 8, RTM (Release to Manufacturing) 6.2.9200.16384
Windows 8 6.2.9200
Windows Server 2012, Developer Preview 6.2.8102
Windows Server 2012 6.2.9200
Also...

How to determine what version of Windows you are running in a batch file

http://thelostartofbatchscript.blogspot.co.uk/2010/09/how-to-determine-what-version-of.htmlIf you keep giving them the fish they will never learn to use google to learn how to fish. Give a man a fish ...he will eat for a Day...
Teach a man to fish...and he'll sit in a boat all Day drinkin Beer...More...
http://www.quoteland.com/topic/Teaching-Quotes/140/
after you teach a fish to swim
Quote from: patio on June 05, 2013, 04:35:54 PM
Give a man a fish ...he will eat for a Day...
Teach a man to fish...and he'll sit in a boat all Day drinkin Beer...
Give a man faith and he will starve to death praying for a fish...Quote from: Squashman on June 05, 2013, 04:26:19 PM
If you keep giving them the fish they will never learn to use google to learn how to fish.

The answers I have given in this THREAD are so very obvious, viz: Google for pages about the ver command, and check out Wikipedia, that I think fishing lessons may be pointless.
6759.

Solve : Tasklist not outputting to file when run from batch?

Answer»

Tasklist isn't outputting to file when run from a batch file. It will CREATE the file, just won't write anything to it.

It works perfectly otherwise when I run it in cmd.exe

Code: [SELECT]tasklist /FO CSV >"output.txt"
Not sure why.tasklist /fo csv>output.txt

This worked for me without the " " and bound tight csv>output.txtQuote from: DaveLembke on June 06, 2013, 07:38:27 PM

tasklist /fo csv>output.txt

This worked for me without the " " and bound tight csv>output.txt
Hm, that still gave me an EMPTY file when ran from a batch file.Quote from: bbman12 on June 06, 2013, 06:51:04 PM
Tasklist isn't outputting to file when run from a batch file. It will create the file, just won't write anything to it.

Code: [Select]tasklist /FO CSV >"output.txt"

It works fine here - copy and pasted.

You batch file isn't called tasklist is it?Quote from: foxidrive on June 06, 2013, 07:44:34 PM
You batch file isn't called tasklist is it?
Wow, I WOULD have never imagined that would affect anything. That fixed it, thanks.GOOD CATCH Foxidrive!!! Quote from: bbman12 on June 06, 2013, 07:54:26 PM
Wow, I would have never imagined that would affect anything. That fixed it, thanks.

Of course it will affect plenty! When a batch script finds a command which is not an internal command like DIR etc, it first looks in the current folder for a executable program or script with that name, if that fails it then searches through the folders listed in the PATH variable. If you name the batch the same as a command, if the batch finds itself first, it will call itself. You couild avoid this by using the extension as well as the name - tasklist.exe - in a batch script but it is very bad idea to name batch scripts the same as Windows commands.


I think that is the 3rd time I have seen SOMEONE make that mistake this week.
6760.

Solve : Batch file Searching for directories or exe's?

Answer»

Hi I would just like you guys you do an amazing job on these forum. This is my first time at looking at building a batch file or anything like it, my project is building a uninstaller for my FS2004 graphics upgrade program which is about 95% OVERWRITES, hence the need for a backup which my inno installer creates.
My PROBLEM now is getting a batch file to find the main flightsim directory path on the users PC as this can be anywhere not just on C:\ default reg path is [ HKLM\Software\Microsoft\Microsoft Games\FLIGHT Simulator 9 ] and the .exe file name is [ FS9.exe ] I have trawled the net for a month looking and tried all the answers before giving up and asking. It needs to be XP and later including 64bit

Thanks Howard

you can use the REG /QUERY cmd to EXTRACT the path from that registry key.Thanks for getting back to me
I was sure REG QUERY was the right one but cant find the right code after it to locate the path, all I get is failed
REG/? FS9.exe /s cmd
or
REG/? HKLM\Software\Microsoft\Microsoft Games\Flight Simulator 9\ FS9.exe /s
My flightsim is not in the default install location
been trying different things for a month now, but I don't fully understand batch files programming Here is an example: It will only show the keys containing flight, and then you can use another query to examine the values - if the key is present


REG QUERY "HKLM\SOFTWARE\MICROSOFT\MICROSOFT GAMES"|find /i "flight"Thank for the input, but still not there yet the code tells me the Synex is wrong I manage to move it on to "invalid key name" "cannot open" "cannot find" thought this looked easy

my string from regedit is
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft Games\Flight Simulator\9.0 EXE PATH

and it still never finds it

Q/ what is "Wow6432Node" ?

help

6761.

Solve : Create CSV from filepath.?

Answer»

Hello people

I got a little question here that shouldn't be very long.

What I'm trying to do, basically, is creating a .csv file using only a single .bat program. That would help my department a lot because .csv file are very long to CREATE (by human) and generating them automatically would help us out a lot!

Here's what i currently have

------------------------------------------------------

@ECHO OFF
CLS
REM This program will generate a .csv file for import. @ECHO OFF Will hide the command flow because no one cares.
SET T=,4,
SET C=,
ECHO ....................................... ..........................
ECHO Welcome to the csv generating tool. Press enter to continue.
ECHO ....................................... ..........................
PAUSE > nul
ECHO Make sure this program and all the files are in a single directory.
ECHO It'll take the files and file path to generate a .csv to import.
ECHO Once this operation is done, zip all the files together.
SET /P D=Please Input the ID Number:
PAUSE > nul
ECHO Attachment Name,Type,File,Related Event > Output.csv

--------------------------------------------------------

Now, for every file inside the folder where the program will be dropped, i need to generate a text line with these information:

For attachment name, i simply need the file name (like Report.pdf or Audio.mp4)
For type, i need 4 (therefore %T%)
For File, i need the filepath from inside the .zip. That means i need to "trim" the filepath from :

C:\Documents and Settings\Username\Desktop\Test File\test1\txt1.txt

to

\test1\txt1.txt

and for related event, that would be the user input here.

Therefore a line would look like :

%ATTACHMENTNAME%%T%%TRIMMEDFILEPATH%C%%D% (%C% is only a single comma)

Translated it would be like this (let's say user input is 999)

txt1.txt,4,\test1\txt1.txt,999

And this for all files contained in within the folder. Final input in notepad would look like :

Attachment Name,Type,File,Related Event
txt1.txt,4,\test1\txt1.txt,999
txt2.txt,4,\test1\txt2.txt,999
txt3.txt,4,\test1\txt3.txt,999
txt4.txt,4,\test2\txt4.txt,999

And so on.

I am willing to use other programming language if needed but i believe batch should work. As long as it can run with a single executable with a double click that would be perfect (i don't want to confuse our poor secretary).

For those wondering, yeah, that's my first batch program. :p

Thanks in advance please help My suggestion would be to do this in PERL instead of batch

I use Perl to perform similar instructions in which I create CSV and TXT files and its simple to achieve and very fast. I can copy/paste a small Perl program that shows how to generate files. The most commonly used one I created generates URL's for websites where pages are numerical or in an alpha order to search for info etc that is openly available on the www.Wish I could help. I can not FOLLOW what you are doing nor even guess as to why it is a CSV file. Normally CSV is used by a spreadsheet program.as way of import or export to other programs.

Have you read the Help for the FOR command?
The parts of a file name have specific variables in the FOR statement.
Code: [Select]@ECHO OFF
CLS
REM This program will generate a .csv file for import. @ECHO OFF Will hide the command flow because no one cares.
set "file=output.csv"
ECHO .................................................................
ECHO Welcome to the csv generating tool. Press enter to continue.
ECHO .................................................................
PAUSE > nul
ECHO.
ECHO Make sure this program and all the files are in a single directory.
ECHO It'll take the files and file path to generate a "%file%" to import.
ECHO Once this operation is done, zip all the files together.
ECHO.
SET /P "ID=Please Input the ID Number: "
ECHO Attachment Name,Type,File,Related Event > "%file%"
for %%a in (*.*) do (
if /i not "%%~nxa"=="%~nx0" (
if /i not "%%~nxa"=="%file%" (
for /f "delims=" %%b in ("%%~dpa\.") do (
>>"%file%" echo "%%~nxa",4,"%%~nxb\%%~nxa",%ID%
)
)
)
)
pause

Output is

Attachment Name,Type,File,Related Event
"File.txt",4,"abc\File.txt",999
"ren file.bat",4,"abc\ren file.bat",999
"result.txt",4,"abc\result.txt",999
"sourceText.txt",4,"abc\sourceText.txt",999
"Target.txt",4,"abc\Target.txt",999
"Ten Twenty.txt",4,"abc\Ten Twenty.txt",999
Thanks a lot that seems to do the trick. Before being done with the issue, could you explain a little this part of the code :

Code: [Select]
for %%a in (*.*) do (
if /i not "%%~nxa"=="%~nx0" (
if /i not "%%~nxa"=="%file%" (
for /f "delims=" %%b in ("%%~dpa\.") do (
>>"%file%" echo "%%~nxa",4,"%%~nxb\%%~nxa",%ID%
)
)
)
)


Thanks. I really want to understand all this in case i need to unbug SOMETHING.

EDIT :

I would also like the program to be able to go fetch files into sub-directories. Let's say i have a file named test6.jpg which is inside folder "def" inside folder "abc", the csv output would include:

"test6.jpg",4,"abc\def\test6.jpg",999

Sad thing i don't fully understand the code maybe you can help me on this one also.
Thanks again i really gotta say you are helping me out a lot here .I can't help with your 2nd question, but I might be able to help with understanding the code.
Code: [Select]for %%a in (*.*) do (
REM This command will do everything within the "( )" for each file in the current directory

if /i not "%%~nxa"=="%~nx0" (
REM This will check to see if the file's name and extention and equal to the name and extention of the first argument ignoring case. Then will run "( )" if they are not the same.

if /i not "%%~nxa"=="%file%" (
REM This will check to see if the file's name and extention are the same as the input file, and execute "( )" if not. Ignoring case.

for /f "delims=" %%b in ("%%~dpa\.") do (
REM This will then execute "( )" on the drive\pathway of the file [from the first command].

>>"%file%" echo "%%~nxa",4,"%%~nxb\%%~nxa",%ID%
REM It will then write to %file% "<name.extention of file>,4,<path\name.extension>,<id>"
)

)

)

)

I find it easyer to understand when it's tabbed out
Code: [Select]for %%a in (*.*) do (
if /i not "%%~nxa"=="%~nx0" (
if /i not "%%~nxa"=="%file%" (
for /f "delims=" %%b in ("%%~dpa\.") do (
>>"%file%" echo "%%~nxa",4,"%%~nxb\%%~nxa",%ID%
)
)
)
)
Quote from: Quardah on August 01, 2013, 05:48:35 AM

I would also like the program to be able to go fetch files into sub-directories.

Next time you post here, explain the entire task, because changing the task after
you have got some tested code means more work changing the code, and more testing.

Quote from: foxidrive on August 01, 2013, 10:15:26 AM
Next time you post here, explain the entire task, because changing the task after
you have got some tested code means more work changing the code, and more testing.

You are right and i am sorry for this. Although i did wrote up in the basic example that it could occur that files could be in different sub-folders;

From First post :
txt1.txt,4,\test1\txt1.txt,999
txt2.txt,4,\test1\txt2.txt,999
txt3.txt,4,\test1\txt3.txt,999
txt4.txt,4,\test2\txt4.txt,999

We see that, in the third variable, the folder changes from test1 to test2. I should have been more clever on this and i am sorry. Don't take this as an insult i don't want to get you wrong on this, i accept the blame for not being specific enough.

All in all, as the final thing, i would like the program to be able to fetch all the files into the specified folder, which means the third variable (File) could be very short or very long depending of the tree in which the program is in.

The files may also be in root directory.

Like this :

txt1.txt,4,\txt1.txt,999
txt2.txt,4,\test1\txt2.txt,999
txt3.txt,4,\test1\test3\test5\test7\txt3.txt,999
txt4.txt,4,\test2\test8\test11\test15\test19\lemay\olddisk\backup\txt4.txt,999

I tested your code (which is great btw thanks again) and i've manage to understand the %%~nxa and %%~nxb and %%~nxc thing and so on which as far as i understand it is the filepath while %%~nxa stands for the file name and %%~nxb is the folder right before in the tree and so on but i just don't have enough experience to code the tree as a variable.

In other words, if you get into terminal and then go into that specific directory, then issue this command :

dir /a:-D /b /s

I would like the .csv to have a line for all the entries that shows up, which means those in the root directory and also those in the sub-directories (also goes on to sub-sub-directories...)

EDIT : Just so you know for double help i double thanked you

EDIT 2 : I've manage to find out that if i input "/R" right after the first "FOR" i get a recursive operation (i don't know if it's the good term but it simply means the operation is also applied to files into sub-folders)!C:\Users\Lemonilla>for /? | find "%~" | find "I"
%~I - expands %I removing any surrounding quotes (")
%~FI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
%~ftzaI - expands %I to a DIR like output line
Hum yeah, i tried to set something like

IF /i "%%~nxa"=="%~nx0" (
Set "dir=%%~nxb"

Just so for the program into the file it would once set the main directory you know, and then i would have tried to tell it to input everything until he FINDS out that "dir=%%~nx(something)" it would stop.

But i failed miserably.

Help this is harder than vba Still no answer yet. I really hope somebody comes and help me finish this cause i have no clue what to do.

I just don't get the FOR function under batch. It's very hard...Asking for help by PM is not how this site works.

Now, if you show actual paths to folders and explain which folder you are launching the batch file in, and the folders you are processing then you will usually get something that works for your situation.

It's a sad fact that many people show folders and filenames that are made up - and as a result they get code that doesn't work for them, because they forget details like you did, or the filenames and foldernames are important in the batch file.The Problem becomes knowing where you want your folder structure to start for the output. It has to be constant for it to work. In other words we really need to know what the base folder is and from there we could output the correct path into your CSV. So basically the base path pretty much has to be hardcoded.
6762.

Solve : vbs help?

Answer»

I have some code that is suppose to find y VALUES for -10->10 for an input y=mx+b formula. And then run _graph.bat with said points as arguments. I'm getting a lot of errors when I try to run it with any equation (type mismatch [string " "]). It is not very consistent as to which string it decides to pick, mainly bouncing between " " and m. Any help would be much appreciated.
Code: [Select]dim m,opp,b,working,points
m = wscript.arguments(0)
opp = Wscript.arguments(1)
b = Wscript.arguments(2)

for i=-10 to 10
if opp = "+" then
working = m * i + b
Elseif opp = "-" then
working = m * i - b
End if
points = points + working + " "
Next

Dim objShell
Set objShell = WScript.CreateObject ("WScript.shell")
objShell.run "graph.bat" + points
Set objShell = NOTHING

Edit: added quotes and it WORKED, now it cant find my file. I added %cd% as the 4th arguments, but can't get it to load 'objShell.run cd + "\graph.bat" + points'. it can't find the file.

EDIT2: So it turns out my objShell.run syntax was WRONG, and you use & not + to combine strings >.<
FINISHED code:
Code: [Select]'wscript //nologo _findLine.vbs "%m%" "%opp%" "%b%"


dim m,opp,b,working,points,cd
m = wscript.arguments(0)
opp = Wscript.arguments(1)
b = Wscript.arguments(2)

for i=-10 to 10
if opp = "+" then
working = m * i + b
Elseif opp = "-" then
working = m * i - b
End if
points = points & " " & i & "." & working
Next

Dim objShell
Set objShell = WScript.CreateObject ("WScript.shell")
objShell.run("%comspec% /k _graph.bat" + points), 1, True
Set objShell = Nothing

6763.

Solve : Reg Query for Key Name; grab the key name to use as variable?

Answer»

Hello -

I'm trying to get the key NAME from the RESULT of a reg query command.

So I run the following:
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f "EMC Avamar for Windows"

The RESULTS of the command:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C87FD1C7-F6B1-41EF-82B3-3E2165E161C7}
DisplayName REG_SZ EMC Avamar for Windows

This is what I want to grab from the results and set as a variable:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C87FD1C7-F6B1-41EF-82B3-3E2165E161C7}

How COULD I accomplish this?This should work.

Code: [Select]@echo off
for /f "delims=" %%a in (' reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f "EMC Avamar for Windows" ^|FIND "{" ') do set "var=%%a"
echo "%var%"
two thumbs up to foxidrive! Works to perfection...thank you!

6764.

Solve : Remove veriable?

Answer»

So I am creating a batch file that will create a graph of points input as arguments. The issue arose when I try to add a feature to change the display characters. For some reason, when I go to remove the verable, it doesn't work for some, but works the rest of the time.
Code: [Select]C:\Users\Lemonilla\Documents\prog\bat\table>graph 1.2 4.6 6.7 9.3
the program STORES arguments as %arg%
so if we use 'set a' we get a list of the argument veriables * removed stuff standard stuff
Code: [Select]arg1=1.2
arg2=4.6
arg3=6.7
arg4=9.3

The code: (error near the bottom in :modifyers)
Code: [Select]@echo off
setlocal EnableDelayedExpansion
set cordinate=+
set space=-

set num_args=0
:loop
set findArg_value=%1
set f |find "%findArg_value%" 1>nul 2>&1
if "%errorlevel%"=="0" (
set /a num_args+=1
set arg!num_args!=%1
shift
goto loop)
set findArg_value=

call :Modifyers
set >log
notepad log

set a=0
:find_argX/argY
set /a a+=1
for /f "tokens=1,2 delims=." %%B in ('call echo !arg%a%!') do (
set argX%a%=%%B
set argY%a%=%%C
)
if not "%num_args%"=="%a%" goto :find_argX/argY



set argX_max=0
set argY_max=0
set a=0
:find_argX.max/argY.max
set /a a+=1
call set workingArgX=!argX%a%!
call set workingArgY=!argY%a%!
if %workingArgX% GTR %argX_max% set argX_max=%workingArgX%
if %workingArgY% GTR %argY_max% set argY_max=%workingArgY%
if not "%a%"=="%num_args%" goto :find_argX.max/argY.max
set workingArgX=
set workingArgY=
set a=



for /l %%D in (1,1,%argX_max%) do (
for /l %%E in (1,1,%argY_max%) do (
set cordx=%%D
set cordy=%%E
set "cord!cordx!.!cordy!=!space!"
)
)
set cordx=
set cordy=



set a=0
:cord.arg.loop
set /a a+=1
call set cord!arg%a%!=!cordinate!
if not "%a%"=="%num_args%" goto :cord.arg.loop
set a=



set /a y=%argY_max%+1
:display_y.loop
echo.
set /a y-=1
set x=0
:display_x.loop
set /a x+=1
0>nul set /p"=!cord%x%.%y%!"
if not "%x%"=="%argX_max%" goto :display_x.loop
if not "%y%"=="0" goto :display_y.loop
set y=
set x=



for /f "tokens=1 delims==" %%Y in ('set a ^| find "arg"') do (
set %%Y=
)
for /f "tokens=1 delims==" %%Z in ('set c ^| find "cord"') do (
set %%Z=
)
set space=

exit /b


:Modifyers
set a=0
:check.loop
set /a a+=1
:: Space Char
if "!arg%a%!"=="/s" set /a b=%a%+1
if "!arg%a%!"=="/s" call set "space=!arg%b%!"
if "!arg%a%!"=="/s" set arg%a%=
if "!arg%a%!"=="/s" set arg%b%=
:: Coord Char
if "!arg%a%!"=="/c" set /a b=%a%+1
if "!arg%a%!"=="/c" call set "cordinate=!arg%b%!"
if "!arg%a%!"=="/c" set arg%a%=
if "!arg%a%!"=="/c" set arg%b%=
if not "%a%"=="%num_args%" goto :check.loop
goto :eof

The problem is that it will sometimes not remove the values of /c or /s, CAUSING the program to error when it tries to check 'if /c GTR 0'


'set a' (from 'graph /c 0 /s + 1.2 2.3 4.5 6.7')
Code: [Select]arg2=0
arg4=+
arg5=1.2
arg6=2.3
arg7=4.5
arg8=6.7

EDIT: the other issue that could be happening is that %b% is not being assigned the correct value. Don't know why this would happen though.Found the issue, needed to flip which one got reset. Because arg%a% was getting reset before arg%b%, the if statement was returning false.

finished code (fixed another bug before posting)
Code: [Select]@echo off
setlocal EnableDelayedExpansion
set cordinate=+
set space=-

set num_args=0
:loop
set findArg_value=%1
set f |find "%findArg_value%" 1>nul 2>&1
if "%errorlevel%"=="0" (
set /a num_args+=1
set arg!num_args!=%1
shift
goto loop )
set findArg_value=

call :Modifyers

set a=0
:find_argX/argY
set /a a+=1
for /f "tokens=1,2 delims=." %%B in ('call echo !arg%a%!') do (
set argX%a%=%%B
set argY%a%=%%C
)
if not "%num_args%"=="%a%" goto :find_argX/argY



set argX_max=0
set argY_max=0
set a=0
:find_argX.max/argY.max
set /a a+=1
call set workingArgX=!argX%a%!
call set workingArgY=!argY%a%!
if %workingArgX% GTR %argX_max% set argX_max=%workingArgX%
if %workingArgY% GTR %argY_max% set argY_max=%workingArgY%
if not "%a%"=="%num_args%" goto :find_argX.max/argY.max
set workingArgX=
set workingArgY=
set a=



for /l %%D in (1,1,%argX_max%) do (
for /l %%E in (1,1,%argY_max%) do (
set cordx=%%D
set cordy=%%E
set "cord!cordx!.!cordy!=!space!"
)
)
set cordx=
set cordy=



set a=0
:cord.arg.loop
set /a a+=1
call set cord!arg%a%!=!cordinate!
if not "%a%"=="%num_args%" goto :cord.arg.loop
set a=



set /a y=%argY_max%+1
:display_y.loop
echo.
set /a y-=1
set x=0
:display_x.loop
set /a x+=1
0>nul set /p"=!cord%x%.%y%!"
if not "%x%"=="%argX_max%" goto :display_x.loop
if not "%y%"=="0" goto :display_y.loop
set y=
set x=



for /f "tokens=1 delims==" %%Y in ('set a ^| find "arg"') do (
set %%Y=
)
for /f "tokens=1 delims==" %%Z in ('set c ^| find "cord"') do (
set %%Z=
)
set space=



echo.
exit /b



:Modifyers
set a=0
set b=0
:check.loop
set /a a+=1
:: Space Char
if "!arg%a%!"=="/s" set /a b=%a%+1
if "!arg%a%!"=="/s" call set "space=!arg%b%!"
if "!arg%a%!"=="/s" set arg%b%=0.0
if "!arg%a%!"=="/s" set arg%a%=0.0
set b=0
:: Coord Char
if "!arg%a%!"=="/c" set /a b=%a%+1
if "!arg%a%!"=="/c" call set "cordinate=!arg%b%!"
if "!arg%a%!"=="/c" set arg%b%=0.0
if "!arg%a%!"=="/c" set arg%a%=0.0
set b=0
if not "%a%"=="%num_args%" goto :check.loop
set a=
goto :eof
Lemonilla,
Interesting CHALLENGE for a batch file.

I gave your script a test and ended with these results.
-Screen Shot-
Quote

F:\test_it>graph 1.2 4.6 6.7 9.3
-----+---
---+-----
---------
---------
--------+
+--------
---------
F:\test_it>
Are the results what I should expect from the script?
Thank you!if we check the point (1,2) we know that it will be 1 to the right (on the x axis) and 2 up (on the Y axis). If the bottom left point is (1,1) then we count up one to get to (1,2) and find the point (represented by a "+").

checking the next point: (4,6) we would count right 3, and up 5 (because the bottom right is (1,1) ) we get the 2nd highest point.

From what I'm seeing, they all seem to work.


EDIT: also if you change line
Code: [Select]0>nul set /p"=!cord%x%.%y%!"
to
Code: [Select]0>nul set /p"=!cord%x%.%y%! "
(found under the flag :display_y.loop, 3rd block from the bottom.)
(added a space before the 2nd quotation mark)
You will get a much nicer looking graph, as it appears to be more to scale

Code: [Select]
C:\Users\Lemonilla\Documents\prog\bat\table>graph 1.2 4.6 6.7 9.3

- - - - - + - - -
- - - + - - - - -
- - - - - - - - -
- - - - - - - - -
- - - - - - - - +
+ - - - - - - - -
- - - - - - - - -

C:\Users\Lemonilla\Documents\prog\bat\table>
Correct me if I am wrong but most X,Y graphs I have seen all start at ZERO.The 9,3 plotting point looks weird/wrong.fixed to start on (0,0)
Code: [Select]@echo off
setlocal EnableDelayedExpansion


REM Declare default signs
set cordinate=+
set space=-


REM Find the number of arguments
set num_args=0
:loop
set findArg_value=%1
set f |find "%findArg_value%" 1>nul 2>&1
if "%errorlevel%"=="0" (
set /a num_args+=1
set arg!num_args!=%1
shift
goto loop )
set findArg_value=

REM Check for modifyers
goto :Modifyers.start
:Modifyers.end


REM Seperate coordinates into X and Y values
set a=0
:find_argX/argY
set /a a+=1
for /f "tokens=1,2 delims=." %%B in ('call echo !arg%a%!') do (
set argX%a%=%%B
set argY%a%=%%C
)
if not "%num_args%"=="%a%" goto :find_argX/argY


REM Find the max X and Y values
set argX_max=0
set argY_max=0
set a=0
:find_argX.max/argY.max
set /a a+=1
call set workingArgX=!argX%a%!
call set workingArgY=!argY%a%!
if %workingArgX% GTR %argX_max% set argX_max=%workingArgX%
if %workingArgY% GTR %argY_max% set argY_max=%workingArgY%
if not "%a%"=="%num_args%" goto :find_argX.max/argY.max
set workingArgX=
set workingArgY=
set a=


REM Create coordinate veriables
for /l %%D in (0,1,%argX_max%) do (
for /l %%E in (0,1,%argY_max%) do (
set cordx=%%D
set cordy=%%E
set "cord!cordx!.!cordy!=!space!"
)
)
set cordx=
set cordy=


REM Assign arguments to coordinates
set a=-1
:cord.arg.loop
set /a a+=1
call set cord!arg%a%!=!cordinate!
if not "%a%"=="%num_args%" goto :cord.arg.loop
set a=


REM Display table
set /a y=%argY_max%+1
:display_y.loop
echo.
set /a y-=1
set x=-1
:display_x.loop
set /a x+=1
0>nul set /p"=!cord%x%.%y%! "
if not "%x%"=="%argX_max%" goto :display_x.loop
if not "%y%"=="-1" goto :display_y.loop
set y=
set x=


REM Remove veriables from memory and exit
for /f "tokens=1 delims==" %%Y in ('set a ^| find "arg"') do (
set %%Y=
)
for /f "tokens=1 delims==" %%Z in ('set c ^| find "cord"') do (
set %%Z=
)
set space=
goto :end


:Modifyers.start
set a=0
set b=0
:check.loop
set /a a+=1
:: Space Char
if "!arg%a%!"=="/s" set /a b=%a%+1
if "!arg%a%!"=="/s" call set "space=!arg%b%!"
if "!arg%a%!"=="/s" set arg%b%=0.0
if "!arg%a%!"=="/s" set arg%a%=0.0
set b=0
:: Coord Char
if "!arg%a%!"=="/c" set /a b=%a%+1
if "!arg%a%!"=="/c" call set "cordinate=!arg%b%!"
if "!arg%a%!"=="/c" set arg%b%=0.0
if "!arg%a%!"=="/c" set arg%a%=0.0
set b=0
:: Help
if "!arg%a%!"=="/?" (
echo Graphs coordinates on a coordinate plane.
echo.
echo Graph ^[^/c ^<char^>^] ^[^/s ^<char^>^] x.y x.y x.y ...
echo.
echo /c Defines what character the coordinates will be shown as.
echo /s Defines what character the empty spaces will be shown as.
echo.
echo %%^^^&^)^=^|^;^"^<^>^,^! Cannot be used with /c or /s.
goto :end
)
:: No arguments
if not defined arg!a! echo The syntax of the command is incorrect.
if not defined arg!a! goto :end
if not "%a%"=="%num_args%" goto :check.loop
set a=
goto :Modifyers.end

:end
Code: [Select]7 - - - - - + - - -
6 - - - + - - - - -
5 - - - - - - - - -
4 - - - - - - - - -
3 - - - - - - - - +
2 + - - - - - - - -
1 - - - - - - - - -
0 1 2 3 4 5 6 7 8 9

Will work on MAKING the numbering automaticWhat if I want to input 0.5?Code: [Select]
C:\Users\Lemonilla\Documents\prog\bat\table>graph 0.5

+
-
-
-
-
-

C:\Users\Lemonilla\Documents\prog\bat\table>graph 0.5 6.9

- - - - - - +
- - - - - - -
- - - - - - -
- - - - - - -
+ - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -
- - - - - - -

C:\Users\Lemonilla\Documents\prog\bat\table>

Though if you enter in a negative value, you get a blank Y axis.Lemon, You seem to be using y,x plotting points instead of the x,y notation. Is there a reason for that?Code: [Select]C:\Users\Lemonilla\Documents\prog\bat\table>graph 0.5 6.9
Y
9 - - - - - - +
8 - - - - - - -
7 - - - - - - -
6 - - - - - - -
5 + - - - - - -
4 - - - - - - -
3 - - - - - - -
2 - - - - - - -
1 - - - - - - -
0 - - - - - - -
0 1 2 3 4 5 6 X

No, I am using (x,y). (0,5) would be right 0 on the X and up 5 on the Y.

http://nces.ed.gov/nceskids/createagraph/default.aspx?ID=5e30cb9e4c5248e1a899869b2c1b16f8BTW ...it's variable.
6765.

Solve : MS DOS program froze, now black screen, white flashing cursor?

Answer»

New and inexperienced comp. user. Have old computer, windows7, run a DOS -based program that froze. Now have black screen, white flashing cursor. What do I do? Researched familiar topics, but didn't understand lingo, BIOS, etc.
Have deadline. How do I get back into my work w/out freezing?Please list detailed computer specs ( Computer Make/Model (or) if its a CUSTOM built the specs ), also what OS was running on this computer before it crashed with blinking cursor? And is this a failed upgrade to Windows 7? What program where you trying to run that messed up the system? And lastly do you have the system recovery set that goes with this computer or the Windows 7 installation Disc to boot from?Please also confirm if you were running the dos based program while Windows 7 was running. If so then just close the dos window.

Or were you were running an MSdos based program in actual MSdos?

Your description is not very clear...Ok, sorry. I was running the dos based program, The Therapist, a practice management program. I load it in Windows, then use it without cursor, as it is very old, but has worked well for our purposes for years. So Windows 7 was running while I was using the dos program. I could not close the dos program, it opens to the opening screen, then I cannot go any further, nor can I close or reboot. I have to turn off the computer. Even then, when I turned it back on it was frozen in the same place. I messed with some function key (F1?) while turning computer on and now I just have the black screen with flashing cursor. The computer is COMPAQ Presario 5170. I cannot find a recovery set or disc for windows 7. I only use this old computer for this function and planned to upgrade to whole new system after this summer so that I could use my laptop and an updated system. However, I still need this data in order to follow-up on outstanding bills and generate income reports for taxes, etc. Thanks for any help you can give and for your follow-up!Boot up the PC...tap F8 repeatedly to bring up Safemode...choose the last item on the list...Win7 Startup Repair.
Do NOT interrupt it ...even if it seems to hang...be patient.P.S. If this method is unsuccesful your other alternative for retrieving the data is to pull the HDD and hook it up to a working PC as a slave drive...
Slave Drive Tutorial...Quote from: Debbie C on July 31, 2013, 02:10:55 PM

I was running the dos based program, The Therapist, a practice management program. I load it in Windows, then use it without cursor, as it is very old, but has worked well for our purposes for years. So Windows 7 was running while I was using the dos program. I could not close the dos program, it opens to the opening screen, then I cannot go any further, nor can I close or reboot. I have to turn off the computer. Even then, when I turned it back on it was frozen in the same place.

Windows 7 cannot run a full screen dos session, so it would seem that you were running Windows XP or earlier and it matters which version of Windows you were running because the options change.

Do as suggested and repeatedly tap F8 while booting just before the Windows screen would appear - in the XP boot MANU that would appear there is an option to load recent settings that worked. The fact that your machine is only displaying a black screen is an added complication which could indicate a failed hardware component like hard drive etc.Thank you guys! From the bottom of my heart! Followed your instructions, pushed F8 and then #3, safe mode and it is now running through some procedures, opened safe mode. By the way, you were right, looks like I have Windows 8 on this computer. So now that I am in safe mode, how do I get back into running Windows normally? What I see on the screen is larger and appears different, but same desktop with "Safe Mode" in the corners.
My instinct is to select the DOS prompt and run the THFIX utility from the Therapist program that froze and caused the problems. Would you agree? Then how do I return to NORMAL, or out of safe mode?
I'll wait a little while to see if one of you has some opinion on what I should do next.
Thanks again for helping!
That's odd. Windows 8 doesn't have a full screen dos prompt either.

Remove "the Therapist" from the startup and then boot normally to see if it's ok.

You can then TRY launching "the Therapist" manually to see if it will run.He may also want to DLoad and install the XP compatibility pack from MS to run older apps...
6766.

Solve : reg query; 7 vs xp?

Answer»

Hello -

I can RUN the following reg query command in Windows 7 and get the following results:

command-
Reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /F "EMC Avamar for Windows"

results-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1693DDE2-4577-46E9-AEE2-0EAFE1F2A00E}
DisplayName REG_SZ EMC Avamar for Windows

Now when I run the same command in Windows XP, I get the following error:

error-
Error: Too MANY command-line parameters

Now I've found that with Window XP, you have to tweak the command and run it as follows:

command-
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s | FIND "EMC Avamar for Windows"

The command works but I only get the following output minus the actual regkey:

output-
DisplayName REG_SZ EMC Avamar for Windows


Like the Windows 7 command, is there a way to run the query in XP to get the key name as well?

6767.

Solve : How to supress "Compare more file (Y/N)?"?

Answer»

In my system, it doesn't support 'fc' command. The only way I can do is to use 'comp' instead. But 'comp' always prompt "Compre more file (Y/N)?" which is not what I want. I want only its return code 'errorlevel'. How can I SUPPRESS its prompt?Quote from: Stan Huang on June 10, 2013, 05:23:45 AM

In my system, it doesn't support 'fc' command. The only way I can do is to use 'comp' instead.

What do you get when you type FC ?

Is there something broken on your computer in this regard, like when you claimed that pause didn't work on your computer?

Why can't you use FC?I typed 'fc' and the responsed message is: " 'fc' is not recognized as an internal, EXTERNAL command, operable program or batch file.
My system is POSReady 2009. Something could be missed in system build.
I APOLOGIZE again for the mistake about 'pause' last time.I used the following to supress any prompt and message:
echo n > NNNN
comp file1 file2 < nnnn > nul 2> null

I works.Quote from: Stan Huang on June 10, 2013, 06:58:50 PM
I typed 'fc' and the responsed message is: " 'fc' is not recognized as an internal, external command, operable program or batch file.
My system is POSReady 2009. Something could be missed in system build.

Which version of Windows is it?
What does it print when you type VER

Quote from: Stan Huang on June 10, 2013, 07:23:25 PM
I used the following to supress any prompt and message:
echo n > nnnn
comp file1 file2 < nnnn > nul 2> null

I works.

STDERR is going into a file called null and you meant to use nul I presume.ver ==>> "Microsoft Windows XP [Version 5.1.2600]"
null is typo of nulQuote from: Stan Huang on June 11, 2013, 01:32:09 AM
ver ==>> "Microsoft Windows XP [Version 5.1.2600]"

FC.EXE is in every NORMAL copy of XP according to google.

Is your XP version a special build, or is it corrupted and files are missing? You can run SFC.EXE to check and replace the system files.That's not my PC. Its owner took my program to run. So, I don't know why it doesn't have popular command like 'fc.exe'. Anyway, I copied it from other system and it worked.In case it's not general knowledge, FC is not reliable in text mode. I think you are using it in binary mode but wanted to make that comment just in case.

Here are some KB articles
XP
http://support.microsoft.com/kb/953929
http://support.microsoft.com/kb/953930

Vista/2008
http://support.microsoft.com/kb/953932
http://support.microsoft.com/kb/953931Quote from: Stan Huang on June 10, 2013, 07:23:25 PM
I used the following to supress any prompt and message:
echo n > nnnn
comp file1 file2 < nnnn > nul 2> null
IF IT WORKS, USE IT!
6768.

Solve : Script terminating without error?

Answer»

So my program is stopping without telling me the error (if there is one).
code:Code: [Select]::@echo off
setlocal EnableDelayedExpansion

REM Declare default signs
set cordinate=+
set space=-
set zero=^&


REM Find the number of arguments
set num_args=0
:loop
set findArg_value=%1
set f | find "%findArg_value%" 1>nul 2>&1
if "%errorlevel%"=="0" (
set /a num_args+=1
set arg!num_args!=%1
shift
goto loop )
set findArg_value=

REM Check for modifyers
goto :Modifyers.start
:Modifyers.end


REM Seperate coordinates into X and Y values
set a=0
:find_argX/argY
set /a a+=1
for /f "tokens=1,2 delims=." %%B in ('call echo !arg%a%!') do (
set argX%a%=%%B
set argY%a%=%%C
)
if not "%num_args%"=="%a%" goto :find_argX/argY
set a=

REM Find the max X and Y values
set argX_max=0
set argY_max=0
set a=0
:find_argX.max/argY.max
set /a a+=1
call set workingArgX=!argX%a%!
call set workingArgY=!argY%a%!
if %workingArgX% GTR %argX_max% set argX_max=%workingArgX%
if %workingArgY% GTR %argY_max% set argY_max=%workingArgY%
if not "%a%"=="%num_args%" goto :find_argX.max/argY.max
set workingArgX=
set workingArgY=
set a=

REM Find the min X and Y values
set argX_min=0
set argY_min=0
set a=0
:find_argX.min/argY.min
set /a a+=1
call set workingArgX=!argX%a%!
call set workingArgY=!argY%a%!
if %workingArgX% LSS %argX_min% set argX_min=%workingArgX%
if %workingArgY% LSS %argY_min% set argY_min=%workingArgY%
if not "%a%"=="%num_args%" goto :find_argX.min/argY.min
set workingArgX=
set workingArgY=
set a=


REM Create COORDINATE veriables
for /l %%D in (%argX_min%,1,%argX_max%) do (
for /l %%E in (%argY_min%,1,%argY_max%) do (
set cordx=%%D
set cordy=%%E
set "cord!cordx!.!cordy!=!space!"
)
)
set cordx=
set cordy=


REM assign 0
for /l %%A in (%argX_min%,1,%argX_max%) do (
for /l %%B in (%argY_min%,1,%argY_max%) do (
if %%A == 0 set "cord%%A.%%B=%zero%"
if %%B == 0 set "cord%%A.%%B=%zero%"
)
)


REM Assign arguments to coordinates
set a=-1
:cord.arg.loop
set /a a+=1
call set cord!arg%a%!=!cordinate!
if not "%a%"=="%num_args%" goto :cord.arg.loop
set a=


REM Display table
set /a y=%argY_max%+1
:display_y.loop
echo.

set /a y-=1
set /a x=%argX_min%-1
:display_x.loop
set /a x+=1
0>nul set /p"=!cord%x%.%y%! "
if not "%x%"=="%argX_max%" goto :display_x.loop
if not "%y%"=="%argY_min%" goto :display_y.loop
set y=
set x=
echo.




REM Remove veriables from memory and exit
::for /f "tokens=1 delims==" %%Y in ('set a ^| find "arg"') do (
:: set %%Y=
::)
::for /f "tokens=1 delims==" %%Z in ('set c ^| find "cord"') do (
:: set %%Z=
::)
::set space=
::set zero=
endlocal
goto :end


:Modifyers.start
set a=0
set b=0
set c=0
:check.loop
set /a a+=1
:: Space Char
if "!arg%a%!"=="/s" set /a b=%a%+1
if "!arg%a%!"=="/s" call set "space=!arg%b%!"
::------------------------------------------------------------------------------------------------ENDING HERE-------------------------------
if "!arg%a%!"=="/s" (
set /a c=%a%+2
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
) else (
set /a c+=2
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
) else (
set /a c-=4
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
)
)
)
set c=0
set b=0
:: Coord Char
if "!arg%a%!"=="/c" set /a b=%a%+1
if "!arg%a%!"=="/c" call set "cordinate=!arg%b%!"
if "!arg%a%!"=="/c" (
set /a c=%a%+2
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
) else (
set /a c+=2
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
) else (
set /a c-=4
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
)
)
)
set c=0
:: Zero Char
if "!arg%a%!"=="/z" set /a b=%a%+1
if "!arg%a%!"=="/z" call set "zero=!arg%b%!"
if "!arg%a%!"=="/z" (
set /a c=%a%+2
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
) else (
set /a c+=2
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
) else (
set /a c-=4
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
)
)
)
set c=0
:: Help
if "!arg%a%!"=="/?" (
echo Graphs coordinates on a coordinate plane.
echo.
echo Graph ^[^/c ^<char^>^] ^[^/s ^<char^>^] x.y x.y x.y ...
echo.
echo /c Defines what character the coordinates will be shown as.
echo /s Defines what character the empty spaces will be shown as.
echo.
echo %%^^^&^)^=^|^;^"^<^>^,^! Cannot be used with /c or /s.
goto :end
)
:: No arguments
if not defined arg!a! echo The syntax of the command is INCORRECT.
if not defined arg!a! goto :end
if not "%a%"=="%num_args%" goto :check.loop
set a=
goto :Modifyers.end

:end

It's ending at ::----------------------------

screen:
Code: [Select]C:\Macros\In The Works>set findArg_value=0.-1

C:\Macros\In The Works>set f | find "0.-1" 1>nul 2>&1

C:\Macros\In The Works>if "0" == "0" (
set /a num_args+=1
set arg!num_args!=0.-1
shift
goto loop
)

C:\Macros\In The Works>set findArg_value=

C:\Macros\In The Works>set f | find "" 1>nul 2>&1

C:\Macros\In The Works>if "1" == "0" (
set /a num_args+=1
set arg!num_args!=
shift
goto loop
)

C:\Macros\In The Works>set findArg_value=

C:\Macros\In The Works>REM Check for modifyers

C:\Macros\In The Works>goto :Modifyers.start

C:\Macros\In The Works>set a=0

C:\Macros\In The Works>set b=0

C:\Macros\In The Works>set c=0

C:\Macros\In The Works>set /a a+=1

C:\Macros\In The Works>if "!ARG1!" == "/s" set /a b=1+1

C:\Macros\In The Works>if "!arg1!" == "/s" call set "space=!arg0!"

C:\Macros\In The Works>

Any help would be great.Quote from: Lemonilla on August 01, 2013, 04:40:43 PM

So my program is stopping without telling me the error (if there is one).
It's ending at ::----------------------------

Replace that ::------------ line with PAUSE. See if it executes the pause or not.

If it does then PLACE PAUSE further down.

The call set command doesn't need a call though, does it?@No need for 'call set'
No I guess it doesn't, good catch.

@pause
It does execute the pause, just not anything after it. Is there a limit on how many else if statements you can use?
Code: [Select]pause
if "!arg%a%!"=="/s" (
pause
does first pause, not 2nd.


EDIT:
I managed to get it to run. It still isn't doing what it's suppose to though.
Code: [Select]if "!arg%a%!"=="/c" set /a b=%a%+1
if "!arg%a%!"=="/c" call set "cordinate=!arg%b%!"
if "!arg%a%!"=="/c" set /a c=%a%+2
if "!arg%a%!"=="/c" if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
) || (
set /a c+=2
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
) || (
set /a c-=4
if not "!arg%c%:~0,1!"=="/" (
set arg%a%=!arg%c%!
set arg%b%=!arg%c%!
)
)
)
set c=0

It is suppose to look to the right and left 2 arguments and copy those. so '_graph.bat 1.3 /c o' would change "/c o" to "1.3 1.3"So I jumped through some hoops for this one, but I got it working.
Code: [Select]@echo off
setlocal EnableDelayedExpansion

REM Declare default signs
set cordinate=+
set space=-
set zero=^&


REM Find the number of arguments
set num_args=0
:loop
set findArg_value=%1
set f | find "%findArg_value%" 1>nul 2>&1
if "%errorlevel%"=="0" (
set /a num_args+=1
set arg!num_args!=%1
shift
goto loop )
set findArg_value=

REM Check for modifyers
goto :Modifyers.start
:Modifyers.end


REM Seperate coordinates into X and Y values
set a=0
:find_argX/argY
set /a a+=1
for /f "tokens=1,2 delims=." %%B in ('call echo !arg%a%!') do (
set argX%a%=%%B
set argY%a%=%%C
)
if not "%num_args%"=="%a%" goto :find_argX/argY
set a=

REM Find the max X and Y values
set argX_max=0
set argY_max=0
set a=0
:find_argX.max/argY.max
set /a a+=1
call set workingArgX=!argX%a%!
call set workingArgY=!argY%a%!
if %workingArgX% GTR %argX_max% set argX_max=%workingArgX%
if %workingArgY% GTR %argY_max% set argY_max=%workingArgY%
if not "%a%"=="%num_args%" goto :find_argX.max/argY.max
set workingArgX=
set workingArgY=
set a=

REM Find the min X and Y values
set argX_min=0
set argY_min=0
set a=0
:find_argX.min/argY.min
set /a a+=1
call set workingArgX=!argX%a%!
call set workingArgY=!argY%a%!
if %workingArgX% LSS %argX_min% set argX_min=%workingArgX%
if %workingArgY% LSS %argY_min% set argY_min=%workingArgY%
if not "%a%"=="%num_args%" goto :find_argX.min/argY.min
set workingArgX=
set workingArgY=
set a=


REM Create coordinate veriables
for /l %%D in (%argX_min%,1,%argX_max%) do (
for /l %%E in (%argY_min%,1,%argY_max%) do (
set cordx=%%D
set cordy=%%E
set "cord!cordx!.!cordy!=!space!"
)
)
set cordx=
set cordy=


REM assign 0
for /l %%A in (%argX_min%,1,%argX_max%) do (
for /l %%B in (%argY_min%,1,%argY_max%) do (
if %%A == 0 set "cord%%A.%%B=%zero%"
if %%B == 0 set "cord%%A.%%B=%zero%"
)
)


REM Assign arguments to coordinates
set a=-1
:cord.arg.loop
set /a a+=1
call set cord!arg%a%!=!cordinate!
if not "%a%"=="%num_args%" goto :cord.arg.loop
set a=


REM Display table
set /a y=%argY_max%+1
:display_y.loop
echo.

set /a y-=1
set /a x=%argX_min%-1
:display_x.loop
set /a x+=1
0>nul set /p"=!cord%x%.%y%! "
if not "%x%"=="%argX_max%" goto :display_x.loop
if not "%y%"=="%argY_min%" goto :display_y.loop
set y=
set x=
echo.




REM Remove veriables from memory and exit
::for /f "tokens=1 delims==" %%Y in ('set a ^| find "arg"') do (
:: set %%Y=
::)
::for /f "tokens=1 delims==" %%Z in ('set c ^| find "cord"') do (
:: set %%Z=
::)
::set space=
::set zero=
endlocal
goto :end


:Modifyers.start
set a=1
set b=0
set c=0
set err=0
:: Help
if "!arg%a%!"=="/?" goto :help
:: No arguments
if not defined arg%a% goto :help
call :loop.findpoint
:check.loop
:: Space Char
if "!arg%a%!"=="/s" set /a b=%a%+1
if "!arg%a%!"=="/s" set "space=!arg%b%!"
if "!arg%a%!"=="/s" set /a c=%a%+2
if "!arg%a%!"=="/s" (
set arg%a%=%arg_rep%
set arg%b%=%arg_rep%
)
set c=0
set b=0
set err=0
:: Coord Char
if "!arg%a%!"=="/c" set /a b=%a%+1
if "!arg%a%!"=="/c" set "cordinate=!arg%b%!"
if "!arg%a%!"=="/c" set /a c=%a%+2
if "!arg%a%!"=="/c" (
set arg%a%=%arg_rep%
set arg%b%=%arg_rep%
)
set c=0
:: Zero Char
if "!arg%a%!"=="/z" set /a b=%a%+1
if "!arg%a%!"=="/z" set "zero=!arg%b%!"
if "!arg%a%!"=="/z" set /a c=%a%+2
if "!arg%a%!"=="/z" (
set arg%a%=%arg_rep%
set arg%b%=%arg_rep%
)
set c=0
set /a a+=1
if not "%a%"=="%num_args%" goto :check.loop
set a=
goto :Modifyers.end

:loop.findPoint
for /f "tokens=1,2 delims==" %%A in ('set arg') do (
call :findpoint %%A %%B

)
goto :loop.findpoint.end

:findpoint
for /f "tokens=1,2 delims=." %%B in ("%2") do (
if not "%%C"=="" set arg_rep=%2
)
goto :eof
:loop.findpoint.end
goto :eof

:help
echo Graphs coordinates on a coordinate plane.
echo.
echo Graph ^[^/c ^<char^>^] ^[^/s ^<char^>^] ^[^/z ^<char^>^] x.y x.y x.y ...
echo.
echo /c Defines what character the coordinates will be shown as.
echo /s Defines what character the empty spaces will be shown as.
echo /z Defines what character the axis will be shown as.
echo.
echo %%^^^&^)^=^|^;^"^<^>^,^! Cannot be used with /c, /s or /z.
goto :end

:end
exit /b

Ex:
Code: [Select]
C:\Macros\In The Works>_graph 1.2 -5.3 7.0 9.5 0.-3

- - - - - & - - - - - - - - +
- - - - - & - - - - - - - - -
+ - - - - & - - - - - - - - -
- - - - - & + - - - - - - - -
- - - - - & - - - - - - - - -
& & & & & & & & & & & & + & &
- - - - - & - - - - - - - - -
- - - - - & - - - - - - - - -
- - - - - + - - - - - - - - -

C:\Macros\In The Works>
That's a neat batch.
6769.

Solve : Modifying file name by adding a suffix?

Answer»

Hi All, DOS Noob here. I have been working on a problem that unfortunately has me stumped. I have a jpg file name I WANT to convert the file to a png file which I can do with xcopy however I am having a lot of trouble in adding _small to the filename. The resultant should be *_small.png. My code gets me to *.png_small.png I have tried many different THINGS (variations) and I cannot find an answer for it. Please help.


@Echo
c:
CD \test\

xcopy *.jpg *.png

FOR /f "delims=" %%F IN ('dir /b/s *.png') do Echo REN "%%F" "%%F"_small.png

Pause

Thankyou in advance



Quote

I have a jpg file name I want to convert the file to a png file which I can do with xcopy

XCopy cannot and will not change a file's internal organization. Changing a file extension does not give you a new type of file. For instance, changing a file extension to XLS does not convert the file to an Excel workbook. Best practices indicate reading the contents of the file into a variable, then saving the contents with the new file type. Powershell can do this (see below)

This LITTLE blurb shows how to write your for statement (execution at command prompt): The code syntax will rename the file correctly but will not convert PNG to JPG.

Code: [Select]for /f "delims=" %F in ('dir /b/s *.png') do echo %~dpnxF %~dpnF_small.jpg

Powershell script to change PNG file to JPG file:
Code: [Select]#Requires -Version 2.0

Add-Type -AssemblyName System.Drawing
$imageFormat = "System.Drawing.Imaging.ImageFormat" -as [type]

$sourceFile = "C:\temp\razr_product_red.jpg"
$saveFile = "C:\temp\razr_product_red_small.png"

$image = [drawing.image]::FromFile($sourceFile)
$image.Save($saveFile, $imageFormat::png)

Happy Days, just a clarification, if the file names you are working with you in the for loop contain spaces it could error. i would recomend putting quotations around the %~pdnxF as well as the %~pdnF_small.jpg.thanks for your input guys. Even if I did not change the file type I still cannot add the SUFFIX, even after your suggestions. My knowledge of DOS is extremely limited and I am not sure where to go from here. Anymore ideas?Give this a shot. The free graphics viewer/editor Irfanview is able to convert from JPG to PNG using a command line interface and batch file.

Code: [Select]FOR /f "delims=" %%F IN ('dir /b /s /a-d *.png') do REN "%%F" "%%~nF_small.png"Is the OP WANTING to crate a photo album for a web site?
There are programs that do all the work for you. It is a feature in Dreamweaver as well as other WYSIWYG editors.
http://www.youtube.com/watch?v=YlB_IZqKg_o

Thankyou everybody for their efforts. Foxidrives' solution did the trick. I will look into irfanview.
6770.

Solve : DOS from CNET Download?

Answer»

If you need a copy of DOS, you may find it on the CNET download site.
There are three kinds you can find there.

  • Free versions that run like the Microsoft product.
  • Abandoned commercial versions. DR-DOS
  • A Microsoft MS-DOS from years ago.
This does not mean you can use any or all for any purpose. All have some REASONABLE RESTRICTIONS. Think about it.
Example: If you GET a 'Public Domain' program and merely change the name and sell it or exchange it representing it as your product, you are commuting fraud.

The site is http://download.cnet.com/windows/
To clarify: no Microsoft operating system whatsoever, and this includes every version of MS-DOS, has ever become "abandonware". All Microsoft software ever released REMAINS copyrighted. Although there may be web sites which offer copies of such software for download, they are operating illegally.
I agree...

Topic CLOSED.
6771.

Solve : How to rename the file with file size using dos command?

Answer»

Hi,

I need help on this

There is two FILE abcMMDD-123 and abcMMDD-456

in this abcMMDD-123 is 0KB and abcMMDD-456 is 1KB

i want only abcMMDD-456 1KB file to rename (i am using this in a batch file)

ren abcMMDD* filename_to_MMDD.txt
Your request isn't very clear.

You've said that you have two files and one of them is zero bytes, and you want to rename the other one.

Explain what you want to rename it to, and also tell us if you are renaming more files at the same time, and if you only want to ignore zero byte files.
i just want to skip the 0KB file as i ill be using MMDD - the date which i want to give as %input%

for ex - 0729 today will be having 2 files in which 1 file 0KB and 1 file 1KB, I need this 0kb to skip and 1kb file to rename

See if this helps you.

Code: [Select]@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%
set Min=%dt:~10,2%
set Sec=%dt:~12,2%

set d=%MM%%DD%

for /f "delims=" %%a in ('dir "*%d%*" /b /a-d ') do (
if %%~za GTR 0 ren "%%a" "something else"
)
pausebut both the file generates at the same time, no diffrence in timing



The code doesn't check by time, it checks the filesize which is what you asked for.

If it doesn't do what you want to do then please clarify the task and provide further details.

@ ECHO OFF
ECHO TYPE THE DATE AND PRESS ENTER, PRESS F6 AND PRESS ENTER AGAIN.
ECHO.
ECHO Enter date below in MMDDYYYY format now:
FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A

ECHO TYPE THE TIME AND PRESS ENTER, PRESS F6 AND PRESS ENTER AGAIN.
ECHO.
ECHO Enter time below in HHMMSS format now:
FOR /F "tokens=*" %%B IN ('TYPE CON') DO SET INPUT1=%%B

d:
ren abc* rename_to_%input%_%input1%.txt

pause

output for this will be rename_to_MMDDYYYY_HHMMSS.txt

in this 0 kb file needs to remain same with out renaming

the below example files are SYSTEM generated file the NUMBERS what mentioned will change on daily basis.

abcMMDD-123 is 0KB and abcMMDD-456 is 1KB

I am beginner...

any update... please give me the batch script which will work on thisI don't think this will correct your problem, but you can replace
'for /f "tokens=*" %%A in ('type con') do set input=%%A'
with
'set /p input="

It should save you some time typing.This is what you seem to want, judging from your code.

Code: [Select]@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%
set Min=%dt:~10,2%
set Sec=%dt:~12,2%

for /f "delims=" %%a in ('dir "abc*" /b /a-d ') do (
if %%~za GTR 0 ren "%%a" "rename_to_%YYYY%%MM%%DD%_%HH%%Min%%sec%.txt"
)
pauseHi

this is not working

what is the meaning of GTR in the qury ?QUOTE from: itkesavan on July 30, 2013, 08:21:36 PM

Hi

this is not working

What error message do you get?

Quote from:
what is the meaning of GTR in the qury ?

It means greater than
6772.

Solve : Delete Folders With a Specific Name or With Specific Contents?

Answer»

I am interested in adding to an EXISTING batch script some code that will look for folders with a particular name and delete them. In this case the folders are named like this:

dfd87.tmp
baols.tmp
08ds2.tmp

I have no idea how to accomplish this. So I decided to try a different approach. Each of those folders contains a .vbs file. So I thought I could use this:

Code: [Select]For /F "tokens=*" %%G IN ('dir /s /a-d *.vbs') DO RMDIR /S /Q %%G

This should do the job however the script won't be running from the %userprofile%\AppDATA\Local\Temp folder. So what I'm interested in knowing is

1. How can I SEARCH for subdirectories of %userprofile%\AppDATA\Local\Temp with names that include .tmp and delete them
2. How can I reference a particular directory in the code provided above. I tried this Code: [Select]For /F "tokens=*" %%G IN ('dir %userprofile%\AppDATA\Local\Temp /s /a-d *.vbs') DO RMDIR /S /Q %%G but am finding that a folder that does not have any .vbs files in it is being deleted . . .

Thanks for the help.

MJtry
Code: [Select]@echo off
for /f "delims=" %%A in ('dir "%userprofile%\AppDATA\Local\Temp" /b ^| find ".tmp"') do (
for /f "delims=" %%B in ('dir /b "%userprofile%\appdata\local\temp\%%A"') do (
if "%%~xB"==".vbs" echo "%userprofile%\appdata\local\tmp\%%A"
)
)

This will echo the pathways to the folders, you should double check them before changing 'echo' to 'rd'.

This was tested with no .vbs in any .tmps, so it might not work properly.This is untested - it should remove every folder in %temp% which contains a *.vbs file and has a .tmp on the end of the folder name.

Code: [Select]@echo off
for /f "delims=" %%a in ('dir "%temp%\*.vbs" /b /s /a-d ') do (
for /f "delims=" %%b in ("%%~dpa\.") do (
if /i "%%~xb"==".tmp" rd /s /q "%%~dpa" 2>nul
)
)
pause
Thank you both for your help. I took notes on what you wrote for future use and added this to my script as a result:

Code: [Select]for /f "delims=" %%A in ('dir "%userprofile%\AppDATA\Local\Temp" /b ^| find ".tmp"') do rd /s /Q "%userprofile%\AppDATA\Local\Temp\%%A" 2>NUL
I found it STRANGE that I couldn't remove the %%A directories without referencing the full path to them but it wasn't until I entered the full path that I stopped getting errors so I guess there's something to it.

Thanks again,

MJQuote from: powlaz on June 13, 2013, 12:17:05 PM

I found it strange that I couldn't remove the %%A directories without referencing the full path to them

The bare folder names will not be found by the batch unless you are running it in the folder "%userprofile%\AppDATA\Local\Temp




Quote from: powlaz on June 13, 2013, 12:17:05 PM
Code: [Select]for /f "delims=" %%A in ('dir "%userprofile%\AppDATA\Local\Temp" /b ^| find ".tmp"') do rd /s /Q "%userprofile%\AppDATA\Local\Temp\%%A" 2>NUL

You will GET errors trying to RD a filename.
6773.

Solve : AMI BIOS password reset/remove on Asus K40IJ?

Answer»

hey guys,
i have an asus k40ij with an ami bios i once set a password and forgot it and then opened my laptop and removed the cmos battery after reading about that in the internet but that didn't work and my password was still there. i also used all the bios/cmos tools on the hiren's bootcd (kill cmos/password cracker/blasting/brute force/clear cmos data) non worked form me. i really NEED help with this issue.In the case of laptops the CMOS battery does NOT hold the password info...this is by design.
You will need to take it to an ASUS Service Center to have it re-set....be prepared to show proof of OWNERSHIP as they will ask for it.i think this is what i will do but isnt there any way Sadly if the CMOS battery doesn't reset it there is very little that you can do except for taking it to ASUS or looking online incase anyone has discovered a master password. The CMOS battery trick can work sometimes (I've used it on a couple of old laptops from 2001 and 2007) but I imagine that yours stores the BIOS password in non-volatile memory. The only thing you may want to check is that the main laptop battery was also removed when you pulled the CMOS battery and that you left the battery out for at least 15mins.

Other than that, ASUS is your best bet.There was a time that I researched this aspect of laptops and a HARDWARE hack was on various pages involving a soldering iron. I don't recall the details now but I recall that it wasn't appropriate for all systems.try GOING to cmd and typing
debug press enter
o 70 2E press enter
o 71 FF press enter
q press enter
Quote from: Jad Ch on JUNE 09, 2013, 06:53:48 AM

i think this is what i will do but isnt there any way

You can keep asking but you won't get another answer. Portable computers are easily stolen and it often happens. This is a well known fact. Robust password security is thus necessary (this is also a well known fact!) and it is therefore very foolish to set a password and then "forget" it. If passwords were easy to alter or remove this would very useful to thieves and those who buy from them. And for people trying to steal information or pry into the affairs of friends, relatives or others, or to play pranks on them. So at least you can be happy your data is safe. If there was a special method known to techies we would, for the foregoing reasons, be very irresponsible to publish it here.
6774.

Solve : read .txt file by line?

Answer»

i am creating a batch file that requires me to read a random line in a .txt file.
for example it WOULD find the random line in file.txt and display it onscreen.
i need to search through a 200-line .txt file and pull a random line.
then it would be echoed onscreen.
i figured someone would have a fancy FOR script for this.@echo off
REM test.txt is a file of 200 lines
REM this script will select a line at random
REM and echo it on screen

set linecount=200
set /a number=(%random% %% %linecount%)+1
For /f "skip=%number% delims=" %%L in ('type test.txt') do set line=%%L & goto next
:next
echo %line%




YES, it can be done in a Batch file. Do you intend to invoke it from another program or batch file?
Here is a very simple program to do only ten lines of text.
Code: [Select]echo please wait..
echo off
:loop
set num=%randOM%
if %num% GTR 5 goto loop
if %num% LSS 1 goto loop
echo number %num%
if %num%==1 goto goblin
if %num%==2 goto wolf
if %num%==3 goto cat
if %num%==4 goto girl
if %num%==5 goto dragon
:goblin
echo Goblin creature is attacking you!
goto EXIT
:wolf
echo Wolf creature is attacking you!
goto exit
cat:
echo Cat creature is attacking you!
goto exit
girl:
echo Girl creature is attacking you!
goto exit
:dragon
echo Dragon creature is attacking you!

:exit
OK, that is not what you asked for, but it is a start.
edit: My code does not use a FOR loop.
The Salmon Trout code is MUCH better.Quote from: Geek-9pm on July 30, 2013, 10:59:47 AM

Girl creature is attacking you!

This is the one I prefer.
@echo off
setlocal enabledelayedexpansion
set linecount=200
set /a randnum=%random% %% %linecount%+1
set tempnum=1
For /f "delims=" %%L in ('type test.txt') do (
if !tempnum! equ %randnum% (
set line=%%L
goto next
)
set /a tempnum+=1
)
:next
echo %line%

This is better than my previous effort, which would never show the first line of the input text file.

6775.

Solve : Things to Program?

Answer»

Maybe I was too brief.

Code: [Select]::Devcon_Reboot.bat
::@echo off
C:\"Program Files (X86)"\O2Micro\Oz600\Devcon Reboot Code: [Select]shutdown /r

Code: [Select]REM this one saves your applications
shutdown /g
@Lemonilla
I was trying for something more esoteric just for fun. Your solutions are more 'real world'. Hat tip! Quote from: Ocalabob on JUNE 14, 2013, 07:08:23 PM

@Salmon Trout
Batch file using WIN 7.

Code: [Select]C:\"Program Files (x86)"\O2Micro\Oz600\Devcon Reboot
foxidrive?

Devcon is a Microsoft COMMAND line utility that is not a standard part of Windows; you have to download it. It is a developer tool, a command line EQUIVALENT of Device Manager, and I should think that used carelessly by someone with LITTLE knowledge or sense of responsibility it could seriously disrupt a computer. However you can reboot the computer with no need for extras in one line like this:

Code: [Select]@shutdown /r /t X
where X is the number of seconds you want to wait before rebooting, 0 (zero) being immediately.
beaten by page 2 Quote from: Ocalabob on June 14, 2013, 07:08:23 PM
@Salmon Trout
Batch file using WIN 7.

Code: [Select]C:\"Program Files (x86)"\O2Micro\Oz600\Devcon Reboot
foxidrive?
Why wouldn't you just use the SHUTDOWN command.Quote from: Squashman on June 15, 2013, 05:15:19 AM
Why wouldn't you just use the SHUTDOWN command.

Welcome to the chorus...
Code: [Select]::Devcon.exe from microsoft
@echo off
Devcon Reboot
There wouldn't have been any comment if the path wasn't there and the point it was from Microsoft was made.

After all, this thread is about figuring out different ways to write batch files...

6776.

Solve : Issues come from comparing two trees?

Answer»

Below is my program for comparing all files and folders under two specified folders, dir1 & dir2. It works if two folders contain only one layer. That is, it succeeds if each folder contains only ordinary files and no sub-folders. In case each dir1/2 contains sub-folders, it goes WRONG. For example, SUPPOSE dir1 contains one ordinary file 1.txt and dd sub-folder containing 11.txt. This program will compare dir1\1.txt to dir2\1.txt. That's fine. But it will further compare dir1\11.txt to dir2\11.txt. That's SURELY wrong because what it is supposed to do is to compare dir1\dd\11.txt to dir2\dd\11.txt.
The trouble comes from that 'for' in DOS Command can only offer below variable substitutions:
%~P: full path
%~f: full path and file name
%~nz: file name

So, there is no easy way to transform \dir1\dd\11.txt to \dir2\dd\11.txt. Using variable substitutions, for dir1\dd\11.txt, we can only get \dir1, \dir1\dd\11.txt. What I need is to get dd\11.txt and then append it to \dir2\. This way, I can get \dir2\dd\11.txt. But how can I get dd\11.txt from all possible variable substitutions?


:cmpdir
setlocal ENABLEEXTENSIONS
@echo off

setlocal enabledelayedexpansion
FOR /R "%1\" %%G in (*) DO (
if not exist %2\%%~nxG (
echo "%2\%%~nxG disappeared"
exit /b 255
) else (
if not exist "%1\%%~nxG\" (
echo "%1\%%~nxG compared to %2\%%~nxG"
fc /b %1\%%~nxG %2\%%~nxG > nul
if !errorlevel! neq 0 (
echo "%2\%%~nxG corrupted"
exit /b 255
)
)
)
)There is an old command line program called Comptree (ct.exe) which binary compares trees of files.

http://allan.hoiberg.dk/eng/prog_ct.htmI tested the program: http://allan.hoiberg.dk/eng/prog_ct.htm
It works, but there are two issues: it works only at 32-bit computer and it's executable one so there is no way to modify it if necessary. I finished a script program as below and verified it. ANYONE can use it, modify or spread it.

REM ::::::::::::::::::::::::::::::::::::::::::::::::::::::
REM Subroutines
REM ::::::::::::::::::::::::::::::::::::::::::::::::::::::
:cmpdir dir1 dir2
setlocal enabledelayedexpansion

pushd %2
for /f "delims=" %%A in ('cd') do set dir2=%%A
popd

pushd %1
FOR %%G in (*) DO (
echo "%%~fG" ***vs*** "%dir2%"\"%%~nxG"
if not exist "%dir2%"\"%%~nxG" (
echo "%dir2%"\"%%~nxG" disappeared
goto :cmpdir_err
)
fc /b "%%~fG" "%dir2%"\"%%~nxG" > nul
rem comp "%%~fG" "%dir2%"\"%%~nxG" < nnnn > nul 2> nul
if !errorlevel! neq 0 (
echo "%dir2%"\"%%~nxG" corrupted
goto :cmpdir_err
)
)
FOR /d %%G in (*) DO (
echo === %%~fG
if not exist "%dir2%"\"%%~nxG" (
echo "%dir2%"\"%%~nxG" disappeared
exit /b 255
)
call :cmpdir "%%~fG" "%dir2%"\"%%~nxG"
if !errorlevel! equ 255 goto :cmpdir_err
)
:cmpdir_ok
popd
exit /b 0

:cmpdir_err
popd
exit /b 255What does this do...

for /f "delims=" %%A in ('cd') do set dir2=%%A

that this...

set dir2=%cd%

...does not?What you said is right. I need study script language deeper.It's only been 2 Months...be patient.What does it mean?

6777.

Solve : vbs, powershell, or java script??

Answer»

So I've decided to learn a new scripting LANGUAGE, and was wondering which one you guys would recommend and if you had any good online material to learn from.Your said:
Quote

vbs, powershell, or java SCRIPT?
If your interest is mostly Windows, then VBScript is your best bet.

Otherwise, I would have said PHP or Java.
(Never confuse Java with JavaScript). Still, VB cript is an excellent pick.

There are a NUMBER of tutorials on on the major languages in current use.

Once you pick one, come back here and ask for HELP. CH is free and even better than a paid-for tutor.

BTW, if you work as an administrator in a Windows environment, you need to know power-shell. DOS is dead.Quote from: Geek-9pm on July 28, 2013, 07:51:41 PM
Otherwise, I would have said PHP or Java.
(Never confuse Java with JavaScript).

You just did...Quote from: BC_Programmer on July 28, 2013, 08:31:10 PM
You just did...
Not I... it was the spell check monster.
6778.

Solve : Changing IP address to Static in DOS 6.22 for SLIP connection for file transfer?

Answer»

I am looking to make a SLIP communication connection between a host PC (Windows 7) to 4 Industrial machines running on basic Dos. I have a 4 to 1 adapter on the back of my pc and RS 232 cables attached to each machine. I am looking to find/change the address of the machines so I can send a ping from the PC to the machines. I am not very familiar with the DOS commands of the machine. I am a student engineer working for the summer. I appreciate any help!Quote

...
make a SLIP communication connection...
I have a 4 to 1 adapter on the back of my pc and RS 232 cables attached...
Welcome to the CH forum.
Please help us understand what SLP is.
What 4 to 1 adapter do your have?
RS232 is an older method used to interface with slow data rate DEVICES. Typically 8600 baud or even much lower. Also, all old DOS programs will be the 8086 real-mode program model. The programs are often called "16 bit programs" because they are not compatible with the mode used in Windows 7.

I do not WANT to ruin your project. What I am here SAYING is you should consider the feasibility of using the hardware and software resources you have. Many industrial applications do not run on Windows 7, expect with a VM (Virtual Machine), which adds another level of complexity to want you want to do.

To get to my point. Find and old PC with older serial ports and an old version of DOS.
Older PCs run four RS-232 ports.
My comments are a general observation based on information you gave.
BTW: I did a little work on industrial automation a long time ago.
Thanks for the response. I am sending the programs from a host PC to four identical machines. At the moment I am loading programs onto a floppy and physically transferring the data to each machine. We have a switchbox (A/B switch) as an opption but we are looking to create communication with 4 machines simultaneously. The adapter from the pc goes from one 25 pin port to four 9 pin ports. I can send and revceive files for a dedicated line. However, I am looking into a basic Serial Line IP instead of Point to Point Protocol because we don't need anything more from the link but straightforward small file sharing. I believe if I can change the static IP addresses of each machine I can link each to an individual connection witht he PC, I am just unfamilar with the DOS commands that would ALLOW this connection. Thanks again.

Note: It might not be RS-232, I did have to short two wires from my null modem to match the adapter diagram from testing with a multimeter. But I have tested that the file transfers are correct.


-I am running virtual machines from another computer to other machines and I understand most of the compatability issues. This PC is simply for transferring the files to the machines.Good. Now what hour are doing makes sense.
You have four machines that communicate directly with a host over some form of serial lines. Logically, some implementation of RS232 hardware. Or are you using an Ethernet cable? With network adapters?

But SLP is a software thing. It is not inherently part of RS232, a hardware lathing.
SLP, serial Line Protocol is defined here:
http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol
Quote
The Serial Line Internet (or, Interface) Protocol (SLIP) is an encapsulation of the Internet Protocol designed to work over serial ports and modem connections. It is documented in RFC 1055
. On personal computers, SLIP has been largely replaced by the Point-to-Point Protocol (PPP), which is better engineered, has more features and does not require its IP address configuration to be set before it is established. On microcontrollers, however, SLIP is still the preferred way of encapsulating IP packets due to its very small overhead.

Notice the association with TCP/IP. That is often RJ-45 hardware. But fom my dim memory, X25 was used on serial devices with RS323 hardware.

This is now getting beyond my ability. Are you making the assumption that the serial ports have drivers that support SLP? I don't think so.

Hey anybody!
I need some help here.
to the OP: Do you have communication established from the serving PC to one of the industrial control machines using SLIP, and it works to send a file?
You really need to get that proof of concept before adding a serial hardware 1 to 4 splitter and attempting to get it all working at the same time.

The hardware device is sharing one serial port to 4 serial ports and that could complicate the situation.Geek: I really appreciate your interest in my networking struggle. I am young and have not worked on these older machines and I am an Industrial Engineering major and my tech understanding in general is much under the general audience of this site.

You raise a point that I have been struggling about myself when it comes to the serial ports not having drivers that support SLIP. I also have been curious of how that I will call to the different machines to send the files if I can get the communication lines running: is there software needed, or will I just send the files to the different addresses via command prompt on my PC? I have looked through the articles you have attached and I am continuing to explore my resources to attack the problem. I will keep you posted on my findings and solution. I found an article that talks about the use of the slattach tool to convert the serial line into SLIP mode but am unaware if this has to do with communication to a modem (which I will not be using).

http://k12linux.mesd.k12.or.us/nag2/x-087-2-slip.operation.html

Quote
A simple way to convert a serial line to SLIP mode is by using the slattach tool. Assume you have your modem on /dev/ttyS3 and have logged in to the SLIP server successfully. You will then execute:
# slattach /dev/ttyS3 &

This tool switches the line discipline of ttyS3 to SLIPDISC and attaches it to one of the SLIP network interfaces. If this is your first active SLIP link, the line will be attached to sl0 ; the second will be attached to sl1, and so on. The current kernels support a default maximum of 256 simultaneous SLIP links.

Foxidrive: I have connected to the machine from the back of any of the 1 to 4 splitters off the PC. I have both sent and received files without any issues. I am now ready to attempt to set the 4 lines up to run simultaneously.Maybe you have RS232 hardware

Many industrial control and telemetry jobs use a serial communication method slower that Ethernet, which is 10 to 100 Megabits. Rather that RS-232, a better interface, RS-422, is used with multiple devices.
I think you should use RS-422 hardware.
http://en.wikipedia.org/wiki/RS-422
As mentioned in the article, up to ten devices can tenon one twisted pair over a moderate distance
Quote
RS-422 (also EIA-422) is a technical standard that specifies electrical characteristics of a digital signaling circuit. Differential signaling can transmit data at rates as high as 10 million bits per second, or may be sent on cables as long as 1500 meters. Some systems directly interconnect using RS-422 signals, or RS-422 converters may be used to extend the RANGE of RS-232 connections. The standard only defines signal levels; other properties of a serial interface are set by other standards...
It is a hardware protocol, not software.
Quote from: connor3 on June 16, 2013, 07:44:30 PM
Foxidrive: I have connected to the machine from the back of any of the 1 to 4 splitters off the PC. I have both sent and received files without any issues. I am now ready to attempt to set the 4 lines up to run simultaneously.

How? Using a terminal program? You just mentioned in the same message that you haven't done it using SLIP and then you mention what is apparently a Linux tool: slattach as /dev/tty3 is linux terminology.
6779.

Solve : How to stay at DOS after exit from a batch file launched by doubling clicking??

Answer»

I would LIKE to launch a batch SCRIPT program in Windows by double clicking and stay at DOS command after it exits. I know 'pause' can have it stay at DOS, but one click will close DOS BOX. What I want is to stay at DOS box after the end of the batch program. In such way, I can continue to USE DOS commands and see previous execution result.This will open a cmd prompt and run a command, and LEAVE the cmd window open.

Code: [Select]%comspec% /k

6780.

Solve : grammar?

Answer»

I don't have a computer with me, but try ^!
THANKS alot...using ^! its work thank you

now
-------------------------------------------------------------------

set bI=1
set bwash=2
set bthe=3
set bcar=4
set byesterday=5

if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!"
echo !bI!>>"bword.txt"
)
goto :eof

if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)
goto :eof

if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)
goto :eof

if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)
goto :eof

if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eof

-------------------------------------------------------------------
each set plus 1

but output becomes

set bI=2
set bwash=2
set bthe=2
set bcar=2
set byesterday=2

not

set bI=2
set bwash=3
set bthe=4
set bcar=5
set byesterday=6any ONE?
Quote

goto :eof
d
That is not in the right place. What you WANT it to mean?
Are your thinking about a CASE statement?
Batch does not have a CASE statement, not does it lend itself to a graceful way of making something like a CASE or SELECT structure.


i put goto :eof because i dont want it run all not necessary script.

-----------------------------------------------------------------------------------

i put value to each set

set bI=1
set bwash=2
set bthe=3
set bcar=4
set byesterday=5

went i run this script below

if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!"
echo !bI!>>"bword.txt"
)
goto :eof

if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)
goto :eof

if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)
goto :eof

if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)
goto :eof

if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eof

------------------------------------------------------------------
this script should make each set +1

from this to
plus 1 each of set
set bI=1 1+1=2 set bI=2
set bwash=2 2+1=3 set bwash=3
set bthe=3 3+1=4 set bthe=4
set bcar=4 4+1=5 set bcar=5
set byesterday=5 5+1=6 set byesterday=6


but output on bword.txt becomes like this

set bI=2
set bwash=2
set bthe=2
set bcar=2
set byesterday=2

you know how to solve this?Just remove all of goto :eof and it might work.it not work

it just going run all script...

output on bword.txt becomes

set bI=2
set bI=3
set bI=4
set bI=5
set bI=6
set bwash=2
set bwash=3
set bwash=4
set bwash=5
set bwash=6
set bthe=2
set bthe=3
set bthe=4
set bthe=5
set bthe=6
set bcar=2
set bcar=3
set bcar=4
set bcar=5
set bcar=6

it run all not necessary script.

if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!" if i remove goto :eof its will be run all not necessary script below
echo !bI!>>"bword.txt"
)
goto :eof

if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)
goto :eof

if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)
goto :eof

if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)
goto :eof

if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eofThis is as FAR as I can help you.
This term
"%word%"
is a persistent entity in the code you gave. It does not wear mutilate or change value by itself.
When the test of
==
meaning really equal to,
is used, the result is exclusive for a persistent entity tested on unique values., but not null null values. You were supposed to learn that back in Programming 101 some time ago.
Sorry, if you don't grasp this, I can not help you.

The script you gave has blocks that are mutually exclusive, so a break is not needed. Take out all the gooto.
@echo off
setlocal enabledelayedexpansion

echo 1 scan document
echo 2 create document
echo 3 reset document
set/p "pilih=^>"
if %pilih%==1 goto :scan
if %pilih%==2 goto :create
if %pilih%==3 goto :reset

:reset

set bI=0
set bwash=0
set bthe=0
set bcar=0
set byesterday=0



goto enter

:create

set bI=1
set bwash=2
set bthe=3
set bcar=4
set byesterday=5


if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!"
echo !bI!>>"bword.txt"
)


if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)


if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)


if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)


if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eof

:enter
echo enter text and enter
set /p input=:

:savebword


:scan
set /p input=file name with (.txt) :
type "%input%"
echo.
echo.

:loop
for /f "delims=" %%A in ('type "%input%"') do (
for %%B in (%%A) do (
echo %%B
call :set "%%B"
call :save "%%B"
call :create "%%B"
echo.
)
)

goto :end

:set

echo set " %~1 " as
echo 1 (pronoun)
echo 2 (noun)
echo 3 (verb)
echo 4 (adverb)
echo 5 (adjective)
echo 6 (preposition)
echo 7 (subject)
echo 8 (object)

set/p "cho=^>"
if %cho%==1 goto SOMEWERE
if %cho%==2 goto SOMEWERE
if %cho%==3 goto SOMEWERE
if %cho%==4 goto SOMEWERE
if %cho%==5 goto SOMEWERE
if %cho%==6 goto SOMEWERE
if %cho%==7 goto SOMEWERE
if %cho%==8 goto SOMEWERE
echo Invalid choice.
goto :eof

:save
set "word=%~1"
set "if=if"

set "tword=word"
set "code=word"

set "tset=set"
set "tbword=b!word!"

set "techo=echo"
set "simbol=^!"


set "output=!if! "%%!tword!%%"=="!word!" goto !tbword!"
set "outputt=:!tbword!"
echo !output!>>"word.txt"
echo !outputt!>>"word.txt"


set "output2=!tset! !tbword!=0"
echo !output2!>>"setword.txt"


set "output3=!tset! /a !tbword!=%%!tbword!%%+1"
echo !output3!>>"word.txt"

echo (set /a bword=%bword%+1)

set (bof=%bof%)





set "output4=!tset! !tbword!=%%!tbword!%%"

set "output6=!tset! "!tbword!=!simbol!tset!simbol! !simbol!tbword!simbol!=!simbol!!tbword!!simbol!""
set "output7=!techo! !simbol!!tbword!!simbol!>>"bword.txt""
set "output8=goto :eof"
echo !output6!>>"word.txt"
echo !output7!>>"word.txt"
echo !output8!>>"word.txt"

echo word " %~1 " now save
if "%~1"=="" goto nothaveit

goto :eof


:end
echo END OF CODE
pause>nul


this full script i make so far...

the problem is here

if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!"
echo !bI!>>"bword.txt"
)
goto :eof

if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)
goto :eof

if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)
goto :eof

if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)
goto :eof

if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eof

it should create output like this

set bI=2
set bwash=3
set bthe=4
set bcar=5
set byesterday=6

but

set bI=2
set bwash=2
set bthe=2
set bcar=2
set byesterday=2

!bI!, !bwash!, !bthe! ,!bcar! and !byesterday! all =2...
why?

this is the problem that i need help to solveTry changing your set /a to

Code: [Select]Set /a %var%+=1
Quote
if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)


1. There is no IF .... DO in batch language. (Are you making the syntax up as you go?) I am amazed you have not seen lots of error messages (or are you running batch scripts by double clicking them?)

2. To alter, or set and then read a variable inside parentheses you need delayed expansion. (Read about it).

I suggest you read the documentation for each command or keyword, either from the prompt by typing the command FOLLOWED by /? (example: if /?) or you can use a site like ss64.com

http://ss64.com/nt/

Start with simple scripts and learn how each command or keyword works. You are just making up code by guesswork, and that will just lead to very long threads like this one.



6781.

Solve : Delete all the files in folder except one type of file?

Answer»

Is there a way to delete all the files in folder EXCEPT one type of file extension (*.zip) USING batch fileCode: [Select]@echo off
pushd "C:\folder" && (
attrib +h *.zip
del *.*?
attrib -h *.zip
popd
)
It is working fine, THANKS you

6782.

Solve : Cross Reference Company Name and Computer Name?

Answer»

Sorry if the title was misleading, I'm not really sure how to word what I want to do. I would like to add a command to a tool I use to manage our servers every day. The logic is this:

If the server NAME starts with set VARIABLE=Company Name. i.e. The script will need to be able to cross reference a list of server names and company names. The servers are named as such: TS888-101. The company associated with all TS888 servers is WIDGET Company. So If the first 5 characters in %computername% are TS888 SET CONAME=Widget Company

I'm nearly positive I can do this with a utility called SSR but I'm interested in how to do it without the help of a third party utility. Any ideas?

Thanks,

MJDo you have a file with the company names and codes?
Or do you want to hardcode all of this in a batch file?Squashman - I imagined using a text file - FarmID.txtQuote from: powlaz on June 14, 2013, 10:39:55 AM

Squashman - I imagined using a text file - FarmID.txt
And the format of this file will be???We can tell you how to compare parts of a string (set /? has INFO) but to give you something that will work for you depends on the file format, as Squashman said.Sorry, I disappeared. I've been very sick. I don't THINK I really put much thought into what was going to be in the file, just that there would be a file. Hmmmm . . . I'm not really sure how the file should read.

Could something like this work:

TS888-101=Widget Company
TS888-102=Widget Company
TS899-101=Gadget Company

etc.?

If not, can you suggest a format?

Thank,

MJThis should work with the format you listed above. It's untested:

Code: [Select]@echo off
set "name=%computername:~0,5%"
set "coname="
for /f "tokens=1,2,* delims==-" %%a in ('type "companylist.txt") do if "%name%"=="%%a" set "coname=%%c"

if defined coname (
echo from %name% the company found was "%coname%"
) else (
echo no company name was found
)
pause
6783.

Solve : MSDos Password has been forgotton?

Answer»

Afternoon!
Trying to get an old PARTS list WRITTEN in 1990 off a comp running MSDos but I don't know the login details. The woman who originally did it is now DEAD so no chance of getting it from her! Any way to bypass the login or reset the password somehow? Please bear in mind, I know little about computers.
Thanks What message do you get when you try to log in? As far as I know MS-DOS did not have any password system. Is it a password set by the parts list application?

Well, it appears that you are referring to the BIOS prompt, and not the DOS itself.


In 80's, users resorted to SETTING passwords in their BIOS (usually you enter it by pressing either the F1 key or the Del key on bootup, till you actually enter.


If this is the case, means the battery is still going great, and holding on to the password. Simply yank out the battery, wait for a few MINUTES and then put it back.


You should be able to login now.

6784.

Solve : Can I execute commands when the window closes??

Answer»

I have been programming a chatroom for me and my friends on BATCH.
I was wondering if I could execute a command as the WINDOW is closing.
What this would be used for is to display:
CODE: [Select]echo // %username% has left.when they X out.
Is this possible?You can have an exit script that it can run in the background, but this would have to remain open while the chat service is running
Code: [Select]@echo off
:loop
tasklist | find "CHAT.exe"
if %errorlevel% == 0 goto loop
REM send echo // %username% has left. command
exit /b

*untestedQuote from: Lemonilla on June 19, 2013, 10:17:34 AM

You can have an exit script that it can run in the background, but this would have to remain open while the chat service is running
Code: [Select]@echo off
:loop
tasklist | find "CHAT.exe"
if %errorlevel% == 0 goto loop
REM send echo // %username% has left. command
exit /b

*untested

I'm sorry, I don't understand what you mean. I don't know how to run it in the background. The batch itself is called Chatroom.bat and the LOG is called ChatLog.txt, if this helps at all.If you were to MAKE chatroom.bat into a .exe program, then you would use
Code: [Select]@echo off
:loop
tasklist | find "CHAT.exe"
if %errorlevel% == 0 goto loop
echo ^/^/ %username% has left. >>ChatLog.txt
REM this is where you resend your chatlog.
exit /b

Otherwise, you would have to make a logout option/command within the chat system.
Code: [Select]REM say we are using %input% as our veriable that would get entered into chatlog.txt
if "%input%"=="$logout" (
echo ^/^/ %username% has left. >>ChatLog.txt
REM this is where you resend your chatlog.
)

this would not happen if they were to just x out of the program.
6785.

Solve : Need help with a Batch file to copy and rename files?

Answer»

I have a large quantity of movies that are in separate folders. Each folder has a FILE named 'moviename-poster.jpg'. I would like to make a copy of that file and rename it 'folder.jpg' in each of those folders. I hope there is a way to do so that doesn't require that I DROP the batch file in each folder and run it. I would prefer to be ABLE to run the batch file from the root folder and have it go into each movie folder and do the copy/rename PORTION for me. Thanks in advance for any assistance.Place script in root folder and try script. Remove ECHO if happy.

@echo off
for /f "delims=" %%F in ('dir /b /s *-poster.jpg') do Echo COPY "%%~dpnxF" "%%~dpF\folder.jpg"
echo Done
Pause




6786.

Solve : Archiving Files Using Copy/Move Command??

Answer»

Hello,

First off, I'd just like to thank anyone who reads/answers this thread. I have no experience in this area whatsoever so I would really appreciate any help I can get.

For work, I have been tasked with archiving any files older than January 1st, 2012. I'd like to move older files from N:\New Filing System (.doc, .xls, .mp4, etc.) to E:\Archived. The perfect solution would copy the files to E: drive and delete them from the N: drive, but I would be happy with it at least copying them over. Then I would CONDUCT a search and just delete the old files.

Actually, I FOUND a code like this:

Code: [Select]for %A in (*.*) do @xcopy /D:12-8-08 /L "%~fA" "%~fA" >NUL 2>NUL &&echo.DEL "%~A"
I was hoping I could use that to do the second part of my plan (deleting files). Would this code go through all SUBDIRECTORIES or only the current folder?

Edit: When I search files older than Jan 1 2012, I find around 24,000 files.

I have read dozens of threads that deal with similar issues but either the codes don't work or I just don't understand how to alter them to fit my needs. I read about Robocopy and Forfiles but neither of the kits are allowed to be installed on my computer (says our IT group) so I am stuck with playing around with the basics. I've also tried the move command but I'm really struggling with the syntax of that one and batch files are super confusing.

I hope my question was EXPLAINED clearly. Again, I know this probably has appeared in the forum before and I have come across a few topics, but none of the solutions (although GREAT solutions) worked for me. I am a novice beyond a novice in this area!!

Thanks again and I apologize for the inconvenience this question may cause you and for most likely repeating a thread. I really appreciate any help!Try this:

Code: [Select]@echo off
for /r %%A in (*.*) do if %%:~tA LEQ 2012 echo xcopy "%%~A" E:\Archived\%%A >>log.txt
notepad log.txt

It should write a list of all the files it would move, in the form of the command that would move them. (I don't know if this will take the subfolders over, or just the files)Thanks for your reply! For the first time in a long time, it actually worked to produce something. Unfortunately it didn't really produce the results I wanted. Sorry about this pickiness, but I needed something that could move all 24,000 files over in one go. Even if it is just a copy and paste job, it would help so much. I'm really sorry that it didn't work but you have no idea how much I appreciate your help! Thanks for taking the time to read and reply.

Edit: Is there a way to do a list of things that should be excluded? So do xcopy and then build a list from there, make it an exclude list, and then repeat xcopy so everything moves except the things on the list (theoretically would be things after Jan 1, 2012)?This should give you a list of all the NEWER files from 1/1/2012 (it will not copy them with the /L switch) and you can then create a batch file to use that information in xcopy.log and MOVE all those files to a new folder tree, then change the top level folder names of the two trees to suit you. The new tree will have post 2011 files and the old tree will have files before 1/1/2012

Code: [Select]xcopy /s/h/e/k/f/c /d:12-31-2011 /L "N:\New Filing System\*.*" "E:\Archived\" >"%userprofile%\desktop\xcopy.log"
Actually, your comment about excluding files is a good one - you could use the xcopy.log that is created to exclude all those post 2011 files in an xcopy operation, then another batch file can use the copied tree to remove all those filenames from the original tree.

This second command on the xcopy.log file will modify the information so that it contains only the drive:\path\filenames of the newer files and you can use that as an exclude file in an xcopy command.

It uses a helper batch file called repl.bat: from - http://www.dostips.com/forum/viewtopic.php?f=3&t=3855

Code: [Select]type "%userprofile%\desktop\xcopy.log"|repl "(.*) ->.*" "$1" >"%userprofile%\desktop\xcopy2.log"Absolutely perfect!!! Thank you so much for your reply, foxidrive. Great information and great help. It completed what I wanted! Again, thank you very much for your time and help. Super appreciate it.
And thanks to everyone who read this thread, too!

6787.

Solve : Create a batch file to automatically backup folder to my flash drive?

Answer»

Hi everyone,
I want to create a batch file to automatically copy the FOLLOWING folder to my flash drive.

Folder to copy = Thunderbird OS=Windows 7
C:\Users\WindowsUserName\AppData\ Roaming\Thunderbird
Copy to......
Where ever the batch file on flash drive is... for example
if my batch file is in G:\backup i want the folder "Thunderbird" to be copied in G:\backup folder. NOTE: the drivel letter can change according to attached devices. it can be H:\backup or J:\backup. i want the batch file to copy "Thunderbird" folder regardless of drive letter of flash drive. Just copy the folder where the batch file resides.

I want to the same batch file to work on windows XP also (if possible). the location of the folder "Thunderbird" on windows XP is
C:\Documents and Settings\WindowsUserName\APPLICATION Data\Thunderbird

NOTE: WindowsUserName should be the name of user currently logged on. I want it to work in any account without worrying about user name
I have tried to read tutorials of creating batch files but could not create my batch file. Please helpIs this for Windows 7? I
http://www.informationweek.com/byte/personal-tech/desktop-operating-systems/how-to-automate-synctoy-jobs-in-windows/231001020
SyncToy is available from Microsoft.
http://www.microsoft.com/en-us/download/details.aspx?id=15155
There are already many attempts to automate o this kind of thing.
Some free.
Others you buy for absurd prices.
Why do it in batch?
Because of security issues, it has to be stated by somebody with administrative permissions. Getting around that can be a chore.
Otherwise, your would just run SyncToy as administrator. Once you have created a profile, you just plug in the flash drive and start up SyncToy with the profile.
Is this what you want?
I gather that you are CLICKING a BAT file on the flash drive itself. This will backup the folder to \tb_backup in the root of the flash drive, for the current user.

Untested - and you may need to right click and elevate permissions.

Code: [Select]@echo off
rd /s /q "\TB_backup" 2>nul

if exist "C:\Users\%username%\AppData\Roaming\Thunderbird\" (
xcopy "C:\Users\%username%\AppData\Roaming\Thunderbird\*.*" "\TB_backup\" /s/h/e/k/f/c
)

if exist "C:\Documents and Settings\%username%\Application Data\Thunderbird\" (
xcopy "C:\Documents and Settings\%username%\Application Data\Thunderbird\*.*" "\TB_backup\" /s/h/e/k/f/c
)
pause
Thanks to both of you. I have downloaded SyncToy and i will test the code also. I will post my feedback tomorrow after testing.
Thanks a lot guysIt'll only work in batch if the destination drive...the flash drive...has a fixed drive letter...
If you are moving it from to PC to PC as stated that may change and the batch file won't run properly...My effort above doesn't RELY on the drive letter - it uses the drive that the batch file is located on, which is the requirement I think from reading the posts.Thanks everybody, especially foxidrive
Following is the code which worked for me - perfectly so far

set backupcmd=xcopy /s /c /d /e /h /i /r /y
%backupcmd% "%AppData%\Thunderbird" "%CD%\Thunderbird"

It automatically copies Thunderbird folder from AppData and creates a folder named Thunderbird in the same directory where the batch file resides. The same code works on Win7, Win8, and WinXP. It does not matter which drive letter is assigned to my flash drive where the batch file resides.

Thanks to all of you

6788.

Solve : Help with code to delete file when not in use?

Answer»

I was helped recently with my question regarding opening a *.ts file in my video conversion project, which worked well.

I now want to check to see if the file is finished converting, and then delete the original, and found this code (Salmon Trout):


@echo off
echo Testing file %~nx1
if not exist "%~dpnx1" echo File does not exist! & GOTO end
if exist "%~dp1\dummy.file" del "%~dp1\dummy.file"
ren "%~dpnx1" dummy.file
If %ERRORLEVEL% gtr 0 (
echo file in use
) else (
echo file not in use
ren "%~dp1\dummy.file" "%~nx1"
)
:end


This looks as if it's perfect for me, but I don't understand how to use it (%~nx1
?).

I'll be checking this file:
J:\Documents and Settings\All Users\Documents\My Videos\wintv\*.avi
and then will use something like this to delete it when it's "not in use"(?):
@echo off
cd C:\Documents and Settings\All Users\Documents\My Videos\
DEL *.ts


Can SOMEONE tell me how to implement the above code to achieve this? Any notes on why you changed what would be helpful, but not necessary if you don't have time for it, but I'd like to understand what you did if possible.try this:
Code: [Select]@echo off
for /f "delims=" %%A in ('dir /b /a-d ^| find ".avi"') do call :check "%%A"
pause>nul
exit

:check
echo Testing file %~nx1
if not exist "%~dpnx1" echo File does not exist! & goto end
if exist "%~dp1\dummy.file" del "%~dp1\dummy.file"
ren "%~dpnx1" dummy.file
If %Errorlevel% gtr 0 (
echo file [%~n1] in use
) else (
echo file [%~n1] not in use
ren "%~dp1\dummy.file" "%~nx1"
call :del "%~1"
)
:end
goto :eof

:del
@echo off
echo del "C:\Documents and Settings\All Users\Documents\My Videos\%~n1.ts"
goto :eof

6789.

Solve : Filename Glitch with "FOR" When Directing Output of Decompiler to TXT File?

Answer»

This should be a piece of cake for you folks, I'm trying to use "FOR" to decompile a bunch of files using a 3rd party decompiler. What I'm using works, but the filename of the output isn't coming out like I want it to, here's my command:

for %f in (*.agn) do agn2txt.exe %f &GT; %f.txt

My files are all named like "001222031313031an.agn", "001222031313033an.agn", etc (autogen files for MS FLIGHT Simulator). I'd like the output .txt files to be named similarly, i.e. "001222031313031an.txt", "001222031313033an.txt", but instead I'm GETTING "001222031313031an.agn.txt", "001222031313033an.agn.txt"

I'm guessing it's blissfully simple, but how do I make it not include the ".agn" in the filename of the .txt file? I thought "%f" was a variable for the wildcard "*", but apparently it's everything within the parentheses? Do I need "delims"?

I'd appreciate any help someone can give me.

Thanks,
JimUse this:

CODE: [Select]> %~nf.txt
Help info on the modifiers is on the last page of for /?Cool, thanks foxidrive, much appreciated .

"%~nI - expands %I to a file name only"

I guess in this case it's %~nf just because I used %f rather than %I as my variable?

Thanks,
JimQuote from: JRobinson on June 22, 2013, 02:46:52 AM

I guess in this case it's %~nf just because I used %f rather than %I as my variable?

Yes, Jim. Glad to see it helped.Quote from: JRobinson on June 22, 2013, 02:46:52 AM
I guess in this case it's %~nf just because I used %f rather than %I as my variable?

In the examples in the FOR documentation, the character I (upper case i) is used as a placeholder for whatever letter you choose to use.

Quote from: Salmon Trout on June 23, 2013, 06:22:56 AM
In the examples in the FOR documentation, the character I (upper case i) is used as a placeholder for whatever letter you choose to use.

It's funny that. I learned in programming never to use an i I l 1 or o 0 O as a variable name because in in some fonts you can't tell which is which. Programmers of today don't seem to have learned that - and it being MICROSOFT makes it even more of an oversight.

Quote from: foxidrive on June 23, 2013, 07:02:55 AM
I learned in programming never to use an i I l 1 or o 0 O as a variable name because in in some fonts you can't tell which is which.

I have noticed that lots of example code uses lower case i or j as loop counters... I just confirmed you can use a pipe symbol in cmd provided you escape it:

Code: [Select]for %^| in (*.*) do @echo %^|
Code: [Select]@echo off
for %%^| in (*.bat) do echo %%^|

That's surprising.

I hate when people use things like %%# and especially %%? to confuse the newbies with wildcards.Quote from: foxidrive on June 23, 2013, 07:59:50 AM
That's surprising.

I hate when people use things like %%# and especially %%? to confuse the newbies with wildcards.
But Jeb writes some pretty wicked batch files.That's for sure.
6790.

Solve : "SET" Command and Editing a BAT?

Answer»

Hello GUYS,

I need a little help:

How can i make a variable like "NINO" to the username

EG:
Code: [Select]SET NINO=USERNAME
ECHO %NINO%
PCFORMNINO
Is there a special way to SAY that USERNAME is the username? %username% holds the current username account. I don't know if that's what you're looking for or not though.

Code: [Select]set "NINO=%username%"

Type SET at the command PROMPT and you will see all the environmental variables that are in use.Yeah yeah

@echo off
echo haha
net user %username% 12128949348353
pause

Another thing, is there ANYWAY to make the file "unclosable" like the shutdown GUI?

And also make it non editable?

6791.

Solve : Newbie Batch file question?

Answer»

Newbie here.
Can I do this?
I want to use XP's Scheduled events to run a batch file to do the following:
Start my video compression/conversion software, Sothink Video Converter:
START c:\progra~1\sothin~1\svc.exe
Open a video that has been just been created (I'll have the scheduled event start 5 minutes after the file is to be completed):
C:\Documents and Settings\All Users\Documents\My Videos\*.ts
and run the conversion with the default profile "MyProfile", creating a *.avi file somewhere else (part of the profile)
Then delete the original *.ts file:
DEL C:\Documents and Settings\All Users\Documents\My Videos\*.ts /Q
And end the batch:
:END
I think this should work, but don't know how to append the START COMMAND to open a file and start the process using MyProfile.
svc.exe would have to support work from commandline inorder to run the converstion, but to open a video you would just need to use
Code: [Select]START c:\progra~1\sothin~1\svc.exe C:\Documents and Settings\All Users\Documents\My Videos\NAME.ts
Paths with spaces need quote marks.
Using the above info, I tried this:
START c:\progra~1\sothin~1\svc.exe "C:\Documents and Settings\All Users\Documents\My Videos\"*".ts"
but it didn't open the .ts file in that directory. I'm likely using the wildcard incorrectly, huh?
Once I have my .ts file opened in the program, I should be able to send KEYSTROKES to simulate Alt-F-C {enter} to start the conversion process, right? I've searched googlitiously and it seems that you can use wildcards and keystrokes, but I can't find the basic, basic premise, only very COMPLICATED scenarios.
BTW, when I change the above line from "*".ts" to test.ts", the .ts file opens in the program.Try this:

Code: [Select]START "" c:\progra~1\sothin~1\svc.exe "C:\Documents and Settings\All Users\Documents\My Videos\*.ts"

You can use the long pathnames of "c:\program files\sothin whatever\svc.exe" if you double quote it, too.

And if your svc.exe program doesn't accept wildcards then you can try this instead:

Code: [Select]@echo off
for %%a in ("C:\Documents and Settings\All Users\Documents\My Videos\*.ts") do (
START /w "" "c:\progra~1\sothin~1\svc.exe" "%%a"
)

If that doesn't work then you will have to investigate the command line options of svc.exeThat second option worked, it opened the program and loaded my .ts file. *applause!*

I found out how to send keystrokes (I think) :
http://www.ehow.com/how_7788761_press-buttons-batch-file.html

Now my batch looks like this:
@echo off
for %%a in ("C:\Documents and Settings\All Users\Documents\My Videos\*.ts") do (
START /w "" "c:\progra~1\sothin~1\svc.exe" "%%a"
)
sleep 60
WshShell.Sendkeys "%f"
sleep 5
WshShell.Sendkeys "c"

This is SUPPOSED to load the *.ts file, wait 60 secs, press ALT F (file), wait 5 secs, and press C (convert)
Doesn't seem to work though, it just opens the file and sits.
Ideas?You might like to look into AutoIt to press buttons in an app.

6792.

Solve : need an echo loop?

Answer»

hey guys.

we have a long long console output from a job we are doing. what i would like is a simple loop that will echo "next command" or something similar 40 times or so

this is so that, rather than squinting my EYES TRYING to find the command, i can easily identify where the commands have been issued, and at what command it ran into trouble.
So for instance my bat file would read:

command
loop
command
loop
command
loop

and so on.


does anyone know a simple loop i could use to repeat 40 lines of text to the screen plz?

regards,
redd .Is it the same command each time? Maybe something like this...

for /L %%A in (1,1,40) do (
echo next command
[command]
)

FOR /L syntax: FOR /L %%var in (start, step, end) do...



cheers man!

yes the same command each time, its just like a bookmark really, so i don't have to go hunting for the commands.

I'll give that a try )This seems to be closed already, but an alternative solution would be
Code: [Select]@echo off
setlocal EnableDelayedExpansion
set /a foo=1
:A
if %foo% leq 40 (
ping 192.0.2.2 -n 1 -W 500 >nul
echo looped !foo! times
set /a foo=!foo!+1
goto A
)
pause
cls
exit
)You could modify the "ping 192.0.2.2 -n..." by changing the 500 to another number.
500 represents the milliseconds to wait.
So 1000 is one second, 10000 is ten, and so on.
I just put the wait there so it didn't just say the whole 40 times instantly.
Take that line out if you feel you need to.1. You left a final parenthesis

2. You didn't need delayed expansion

Code: [Select]@echo off
set foo=1
:A
ping 192.0.2.2 -n 1 -w 500 >nul
echo looped %foo% times
set /a foo+=1
if %foo% leq 40 goto A
pause
cls
exit

3. What's wrong with using FOR /L?

Quote

Quote from: Salmon Trout on July 16, 2013, 10:49:52 AM
1. You left a final parenthesis

2. You didn't need delayed expansion

Code: [Select]@echo off
set foo=1
:A
ping 192.0.2.2 -n 1 -w 500 >nul
echo looped %foo% times
set /a foo+=1
if %foo% leq 40 goto A
pause
cls
exit

3. What's wrong with using FOR /L?


Nothing is wrong with FOR /L, I just... find it hard to figure out... ummm xD
And excuse me for the flaws. I was half asleep at 6 AM.
Quote from: jofspades on July 16, 2013, 02:57:30 PM
And excuse me for the flaws. I was half asleep at 6 AM.

This is a help forum, not a chat room. You should only post code that you have actually tested.
6793.

Solve : Comparing variables?

Answer»

I have written the following MS Dos Batch File
@echo off
setlocal enabledelayedexpansion
set xserial=DCD24116T8
set xserial=%xserial:~0,10%
echo %xserial%

for /F "skip=1 delims=" %%j in ('WMIC bios get serialnumber') do (
set serial=%%j
echo !serial!
if NOT !serial==%xserial% goto DONE
)
endlocal
echo They are the same
goto END

:DONE
echo ========
echo %xserial%
echo !serial!
echo They are not the same
:END

When this Batch File is run in Command WINDOW the variables are echoed as the same but the if statement equates them to not being equal. What am I doing wrong??FWIW this command doesn't return a value on all machines.

d:\abc>wmic bios get serialnumber
SerialNumber



d:\abc>


Wmic usually ends the output with a single CR and as it stands your variable will be wrong. It also pads the string with trailing spaces in many cases, unless you use a CSV output.

This should help with setting the variable
Code: [Select]if not defined serial set serial=%%j
and then use echo "!serial!" and see if it has trailing spaces inside the double quotes.

This particular WMIC command produces three lines of output, a header, the actual serial number and a blank line. By using the skip parameter in the for loop you are positioning the file at the second record. So far so good, but the if NOT !serial==%xserial% goto DONE resolves to false. (ie. The serial numbers are equal). Consequently the for loops executes one final time with the third (blank) line where the serial numbers are not equal.

You might FIND it EASIER to do all the logic COMPARES within the for loop and quit after processing the single record with the serial number.

Code: [Select]@echo off
setlocal enabledelayedexpansion
set xserial=DCD24116T8

for /f "skip=1" %%i in ('wmic bios get serialnumber') do (
set serial=%%i
if %xserial% EQU !serial! echo %xserial% and !serial! are equal
if %xserial% NEQ !serial! echo %xserial% and !serial! are not equal
goto :eof
)

Thankyou - Sidewinder, that works for me!. The point has been taken about the "wmic bios get serialnumber" sometimes not returning a value - ie to supplied by oem provider. What unique identifier can be used to id a particular pc that will be more reliable. Will the Network Card be the answer and how would you read and isolate that variable into this batch file?Code: [Select]wmic nic get macaddress|find ":"
You might get more than one

6794.

Solve : How to copy all the files to a folder which has created using command ??

Answer»

ECHO TYPE THE DATE AND PRESS ENTER,
ECHO.
ECHO Enter date below in MMDD format now:

FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A


z:
cd folder1\folder2

MD %input% (this is creating a folder with input data)

copy *%input%*.* Z:\folder1\folder2 (what i have to giver here to make all the files which i am copying using "copy *%input%*.*" this command to the folder which created with md %input%)Why are you doing this:

FOR /F "tokens=*" %%A IN ('TYPE CON') DO SET INPUT=%%A

... when you COULD do this:

set /p input="Enter date below in MMDD format now: "

... ?

If you want to copy all the files from this folder: Z:\folder1\folder2 to this folder: %input%

then do this:

copy "Z:\folder1\folder2\*.*" "%input%"









Thanks Salmon

move "Z:\folder1\folder2\*.*" "%input%"

this is working....

6795.

Solve : [Bat]Find path in registry and copy files to this path.?

Answer» HELLO,
Need a batch script. The task is: find in REGISTRY path to the program, copy files (with other extensions) from folder where i have batch file and paste copied files to folder from path .

Possible ?
I hope that was understood. Sorry for my english What is the registry key?Thanks for reply. I'm not sure I understand the question correctly....(translator)

Quote
What is the registry key?
In example :
HKEY_LOCAL_MACHINE\SOFTWARE\7-ZipOn my machine it's

HKEY_CURRENT_USER\Software\7-Zip

Ok, in example can be. (on mine is in this two places )

=====

I try to do this on my own in that way :

Quote
for /f "tokens=3" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path ^| find /i "REG_SZ"') do CD /D %a

or

Quote
for /f "tokens=3" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path ^| find /i "REG_SZ"') do set Path=%a

but i dont know how to copy files, or how to refer to correct paths. I find something like that :

Quote
set OLDDIR=%CD%
copy file.1 file.2
chdir /d %OLDDIR% &rem restore current directory
(cmd=%,batch=%%)
But dont know how to, and I'm probably wrong ...1. Do not use Path as a variable name. This name is already USED for a system variable and you will cause lots of problems!

2. Why do you need to copy ADDITIONAL files into a program directory? This is bad security practice.
1. Path in this command this is string value - REG_SZ > Path > C:\Program Files\7-Zip
2. Program directory is only example. Quote
for /f "tokens=3" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path ^| find /i "REG_SZ"') do set Path=%a

Your code uses Path as a variable name. Use something else e.g. Mypath

Now %Mypath% contains a path

copy some files into that folder

copy *.txt "%Mypath%"

I cant use Mypath in this example, becouse name of string value is "Path" . In other cases it can be InstallPath or InstallLocation etc.
Is not a problem I check this in cmd with command: SET , and everything is fine with system "Path"

7-Zip is only example, because there was a high probability that someone who try to help will have this program

Quote
The task is: find in registry path to the program, copy files (with other extensions) from folder where i have batch file and paste copied files to folder from path .

Possible ?

Possible ?Quote
Your code uses Path as a variable name. Use something else e.g. Mypath

Now %Mypath% contains a path

copy some files into that folder

copy *.txt "%Mypath%"

Thats it ! Working like a charm. THANK You very much Quote from: Bzik on July 16, 2013, 01:14:19 PM
I cant use Mypath in this example, becouse name of string value is "Path"

You can use anything you like. You are not understanding that Path is the name (in the registry) of the registry key. In your batch you can use any variable name you like to hold the string value of the registry key.

Code: [Select]@echo off
for /f "tokens=1-2*" %%A in ('reg query HKEY_CURRENT_USER\Software\7-Zip /v path ^| find "REG_SZ"') do set MyPath=%%C
echo The path string value is "%MyPath%"


If you did set Path=%%C you would find that all external commands would stop working in that command session.
Yes, You right. Mypath is working.

Thanks again.
6796.

Solve : how to copy if the folder name contains space?

Answer»

copy *%input%*.* Z:\asfas asa\asdf AAF

i am GETTING this error - The SYNTAX of the COMMAND is incorrect.

is there a way to copy if the FOLDER name has space Use quote marks "Z:\asfas asa\asdf aaf"
Thankyou Salmon ...

6797.

Solve : Help with replaceable parameters?

Answer»

Hello,

I am taking an intro class and not getting this concept. Have tried various ways and come up frustrated.

Create a batch file to demonstrate replaceable parameters that will clear the screen and display all the *.%1 files (GIVEN on the command line) in the C:\windows\system32 directory. Replacable Parameters:
http://academic.pgcc.edu/~ebouling/lab3a.htm

From what I am understanding Replacable Parameters are the arguments that you give a command. I'll give you a run-down, as I can't seem to remember which command's help has this information.

%0 = batch file
%1-%9 = first-ninth argument

Thus:
Code: [Select]File.bat arg1 arg2 arg3
%0 = File
%1 = arg1
%2 = arg2
%3 = arg3

You can also use the help for 'call' which includes:
Code: [Select]In addition, expansion of batch script argument references (%0, %1,
etc.) have been changed as FOLLOWS:


%* in a batch script refers to all the arguments (e.g. %1 %2 %3
%4 %5 ...)

Substitution of batch parameters (%n) has been enhanced. You can
now use the following optional syntax:

%~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter only
%~p1 - expands %1 to a path only
%~n1 - expands %1 to a file name only
%~x1 - expands %1 to a file extension only
%~s1 - expanded path CONTAINS short names only
%~a1 - expands %1 to file attributes
%~t1 - expands %1 to date/time of file
%~z1 - expands %1 to size of file
%~$PATH:1 - searches the directories listed in the PATH
environment variable and expands %1 to the fully
qualified name of the first one found. If the
environment variable name is not defined or the
file is not found by the search, then this
modifier expands to the empty string

The modifiers can be combined to GET compound results:

%~dp1 - expands %1 to a drive letter and path only
%~nx1 - expands %1 to a file name and extension only
%~dp$PATH:1 - searches the directories listed in the PATH
environment variable for %1 and expands to the
drive letter and path of the first one found.
%~ftza1 - expands %1 to a DIR like output line

In the above examples %1 and PATH can be replaced by other
valid values. The %~ syntax is terminated by a valid argument
number. The %~ modifiers may not be used with %*

If you launch this batch file like this: Mybatch exe cls

it will clear the screen and list the exe files in the C:\windows\system32 folder
That's all the sense I can make out of the question.

Code: [Select]@echo off
%2
dir C:\windows\system32\*.%1Run the batch file below. From a command shell with type: List_it.bat C O M
That will give a you an idea how the arguments work.

Code: [Select]::List_it.bat
@Echo Off
CLS
DIR C:\Windows\System32\*.%1%2%3

6798.

Solve : Command 'grep' and 'awk'?

Answer»

Hi guys,

I'm learning how to use MS-Dos and I have a code to implement:

Quote

gpdcreport my_run.report -gm -m 1 | gprofile -vs -resample -d 50 -N 50 | grep -v "#" | awk '{print $2,$1}' | gphistogram -y-min 150 -y-max 3500 -x-min 1 -x-max 50 -x-count 50


This works just fine, till the command grep and awk
Anyone knows how to solve this?

Probably it's a dumb question. I'm a newbie in Ms-dos.
ThanksWelcome to the CH forum.
There are no dumb questions.
Programs grep and awk COME from UNIX, not MS-DOS.
Some versions of those two programs have been adapted to run as Windows command line programs.
Some questions for you:
Which version of Windows or DOS you your have?
Which version of awk?
Which of grep?
What is the error message you get?
Answers to the above will help us help you.

grep and awk are not "ms-dos" commands; they are part of Unix and related operating systems, such as Linux etc. To use them on a Microsoft Windows system you will have to install Windows versions ("ports"). Google for "Windows grep" and "Windows awk". The Gnuwin32 utilities include versions of grep and awk for Microsoft Windows command prompt (which is not MS-DOS).

http://gnuwin32.sourceforge.net/packages/grep.htm

There are various Windows versions of awk called gawk including Gnuwin32:

http://gnuwin32.sourceforge.net/packages/gawk.htm

Or there is the unxutils package which has grep and gawk

http://unxutils.sourceforge.net/

A warning: you may find that the Windows versions do not use exactly the same syntax as the UNix originals and you may NEED to modify the command line you are USING. Would you care to EXPLAIN why you are trying to run that command on a Windows or MS-DOS system without preparation or prior study?

As Geek says, exactly what operating system are you using?




6799.

Solve : Batch PrintScreen + Save?

Answer»

I was going to make a batch to "TRACK" someone else's account on my PC.
Don't question it xD
I have it so every 30 seconds it saves a screenshot as %fileNumber%.png or .jpg or whatever.
I wasn't sure if this was possible, it seems all the software like BatchRun is out of date.
Plus I don't even like installing extra software...
By the WAY, I will end up shoving this in the Startup scripts. I have a VBScript set up to run it hidden.
Code: [Select]@ECHO off
:AAA
set startTime=%time:~6,2%
set /a snapScreen=%time:~6,2%+30
:AAB
if %startTime%==%snapScreen% (
:: This is where I would use the printscreen/saving code
goto AAA
) else (
goto AAB
)If someone COULD HELP me with this ASAP that's be great.Quote from: jofspades on July 16, 2013, 06:11:35 AM

Don't question it xD

Why not?
6800.

Solve : Save/load help?

Answer»

Ok I need some help with a test file to load data from a save state after checking if it even exist.
Here's the code:
Code: [Select]@echo off
title test save game batch
color 0f

set /a gold=0
set /a hp=100
set /a level=1
set /a potions=1
set /a food=1

:name
echo what is your first name?
set /p name=
goto StartScreen

:StartScreen
cls
echo Please chose an option:
echo.
echo 1. Load
echo 2. Change Varibles
echo 3. Check Varibles
echo 4. Save
echo 5. Exit
echo.
set /p pass=
if %pass%==1 goto load
if %pass%==2 goto ChangeVaribles
if %pass%==3 goto CheckVaribles
if %pass%==4 goto Save
if %pass%==5 exit
goto StartScreen

:load
cls
if exist ("tsgb%name%.txt") goto loader
echo No file exist for you.
pause >nul
goto StartScreen

:loader
for /f %%a in ("tsgb%name%.txt") do set %%a
echo Done. Please check stats to verify.
pause >nul
goto StartScreen

:ChangeVaribles
cls
echo what would you LIKE to change?
echo.
echo 1. Gold
echo 2. HP
echo 3. Level
echo 4. Potions
echo 5. Food
echo.
set /p change1=
echo what would you like to change it to?
set /p change2=
if %change1%==1 set gold=%change2%
if %change1%==1 set change1=gold
if %change1%==2 set hp=%change2%
if %change1%==2 set change1=HP
if %change1%==3 set level=%change2%
if %change1%==3 set change1=Level
if %change1%==4 set potions=%change2%
if %change1%==4 set change1=Potions
if %change1%==5 set food=%change2%
if %change1%==5 set change1=Food

echo.
echo.
echo Done. Changed %change1% to %change2%
goto StartScreen

:CheckVaribles
cls
echo Gold %gold%
echo HP %hp%
echo Level %level%
echo Potions %potions%
echo Food %food%
pause >nul
goto StartScreen

:save
cls
(echo gold=%gold%)> tsgb%name%.txt
(echo hp=%hp%)>> tsgb%name%.txt
(echo Level=%level%)>> tsgb%name%.txt
(echo Potions=%potions%)>> tsgb%name%.txt
(echo food=%food%)>> tsgb%name%.txt
echo Done. Saved to tsgb%name%.txt
pause >nul
goto StartScreen


Each time it changes everything as it should and SAVES to the correct file, but when I select load even after just SAVING it, i get the message: No file exist for you.

Any suggestions?
if exist "tsgb%name%.txt" goto loader instead of if exist ("tsgb%name%.txt") goto loader

If that doesn't help then check that the file actually exists in the current folder.QUOTE from: foxidrive on July 12, 2013, 06:03:13 PM

if exist "tsgb%name%.txt" goto loader instead of if exist ("tsgb%name%.txt") goto loader

If that doesn't help then check that the file actually exists in the current folder.

Ok that sort of worked. Now I get a whole new issue.
The output on the :loader screen now reads


Environment variable tsgbjasperjester.txt not defined.
Done. Please check stats to verify.


just as a note i tried removing the () around the

Code: [Select]for /f %%a in ("tsgb%name%.txt") do set %%a
but it just closed immediately.

thank you again for the helpCode: [Select]for /f "usebackq delims=" %%a in ("tsgb%name%.txt") do set myvar=%%a
If that text file just has one line of text in it and you are trying to assign it to a variable then just do this.
Code: [Select]set /p myvar=<tsgb%name%.txtQuote from: Squashman on July 12, 2013, 08:15:29 PM
Code: [Select]for /f "usebackq delims=" %%a in ("tsgb%name%.txt") do set myvar=%%a
If that text file just has one line of text in it and you are trying to assign it to a variable then just do this.
Code: [Select]set /p myvar=<tsgb%name%.txt

Uh, I'm not sure what that was supposed to do but it did no load the changed variables at all. I am actually trying to change 5 in this test game, but there 12 variables in the full game.Quote from: Jasperjester on July 12, 2013, 08:10:43 PM
The output on the :loader screen now reads


Environment variable tsgbjasperjester.txt not defined.
Done. Please check stats to verify.


just as a note i tried removing the () around the

Code: [Select]for /f %%a in ("tsgb%name%.txt") do set %%a
but it just closed immediately.

Yes, that is a different command and has different syntax and it should be:


Code: [Select]for /f "delims=" %%a in ('type "tsgb%name%.txt" ') do set variable=%%a
but this will only populate the variable to the last line in the file

Quote from: foxidrive on July 13, 2013, 04:07:03 AM
but this will only populate the variable to the last line in the file

ok but if one player has 7 stats to track and each player gets up to 3 companions each will ever changing stats that have to be saved and loaded, this will require me to enter the same line at least 8 times for each player totaling 36 times and creating 36 small files for each player stats alone not including the money and inventory systems I have in place. I need all this in a maximum of 6 pages. There are already 4 people here who are testers and react differently and that would seriously bloat the folder in which the files are saved.1. Writevals.bat

@echo off
REM save values
set name=Joe
set money=1000
set energy=50
set friend1=Mary
set friend2=Jim
set friend3=Peter
if exist "%name%.values" del "%name%.values"
echo money=%money% >> "%name%.values"
echo energy=%energy% >> "%name%.values"
echo friend1=%friend1% >> "%name%.values"
echo friend2=%friend2% >> "%name%.values"
echo friend3=%friend3% >> "%name%.values"

2. Joe.values

money=1000
energy=50
friend1=Mary
friend2=Jim
friend3=Peter

3. Readvals.bat

@echo off
REM read values
set name=Joe
set money=
set energy=
set friend1=
set friend2=
set friend3=
for /f "delims=" %%A in ('type "%name%.values"') do (
set %%A
)
echo name=%name%
echo energy=%energy%
echo friend1=%friend1%
echo friend2=%friend2%
echo friend3=%friend3%

4. Output of Readvals.bat

name=Joe
money=1000
energy=50
friend1=Mary
friend2=Jim
friend3=PeterQuote from: Jasperjester on July 14, 2013, 01:18:43 AM
ok but if one player has 7 stats to track and each player gets up to 3 companions each will ever changing stats that have to be saved and loaded

I was pointing out that your syntax was wrong and it would not read a file at all.Quote from: foxidrive on July 14, 2013, 05:05:37 AM
I was pointing out that your syntax was wrong and it would not read a file at all.

Oh, I apologize for the misunderstanding. I hope you may forgive my ignorance on the matter. I am still learning

Quote from: Salmon Trout on July 14, 2013, 02:49:42 AM
for /f "delims=" %%A in ('type "%name%.values"') do (
set %%A
)

Had an issue where it wouldn't read the files at first, but it turned out, I forgot the tsbg before the %name%.values

Kudos for all the help!!!!!!!!!!!!!What is a 'tsbg'?
Quote from: Salmon Trout on July 14, 2013, 07:05:51 AM
What is a 'tsbg'?

tsbg was a prefix I added to make sure i never mixed up the test save batch game with the real game save files.
example:
Code: [Select]tsbg%name%.values

vs

Code: [Select]realgame%name%.values