Computer Hope
Microsoft => Microsoft DOS => Topic started by: ALAN_BR on June 05, 2009, 11:02:24 AM
-
A commercial Windows backup utility (ACRONIS) requires me to select source and destination folders, and then runs my user defined *.CMD batch file to execute other commands.
My "other commands" need to know what I selected as source and destination.
I commence "my commands" with "SET > variable.txt",
and this shows fixed environmental variables that include some ACRONIS variables,
but nothing indicates the source and destination choices.
Just possibly these choices may be held in dynamic environmental variables.
SET totally fails to show dynamic environmental variables such as %TIME%
Is there a special argument for SET to expose all dynamic variables ?
Or is there a SET_DELUXE type of command that can reveal this information.
Regards
Alan
-
C:\>set
ALLUSERSPROFILE=C:\Documents and Settings\All Users
CLIENTNAME=Console
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=
ComSpec=C:\WINDOWS\system32\cmd.exe
DESKTOPICON=0
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\Bill Richardson
LOGONSERVER=\\NEWBILL
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Co
mmon Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\10
.0\DLLShared\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 6, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=1706
ProgramFiles=C:\Program Files
PROMPT=$P$G
RoxioCentral=C:\Program Files\Common Files\Roxio Shared\10.0\Roxio Central36\
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
USERDOMAIN=USERNAME=
USERPROFILE=
windir=C:\WINDOWS
C:\>
C:\>help
For more information on a specific command, type HELP command-name
ASSOC Displays or modifies file extension associations.
AT Schedules commands and programs to run on a computer.
ATTRIB Displays or changes file attributes.
BREAK Sets or clears extended CTRL+C checking.
CACLS Displays or modifies access control lists (ACLs) of files.
CALL Calls one batch program from another.
CD Displays the name of or changes the current directory.
CHCP Displays or sets the active code page number.
CHDIR Displays the name of or changes the current directory.
CHKDSK Checks a disk and displays a status report.
CHKNTFS Displays or modifies the checking of disk at boot time.
CLS Clears the screen.
CMD Starts a new instance of the Windows command interpreter.
COLOR Sets the default console foreground and background colors.
COMP Compares the contents of two files or sets of files.
COMPACT Displays or alters the compression of files on NTFS partitions.
CONVERT Converts FAT volumes to NTFS. You cannot convert the
current drive.
COPY Copies one or more files to another location.
DATE Displays or sets the date.
DEL Deletes one or more files.
DIR Displays a list of files and subdirectories in a directory.
DISKCOMP Compares the contents of two floppy disks.
DISKCOPY Copies the contents of one floppy disk to another.
DOSKEY Edits command lines, recalls Windows commands, and creates macros.
ECHO Displays messages, or turns command echoing on or off.
ENDLOCAL Ends localization of environment changes in a batch file.
ERASE Deletes one or more files.
EXIT Quits the CMD.EXE program (command interpreter).
FC Compares two files or sets of files, and displays the differences
between them.
FIND Searches for a text string in a file or files.
FINDSTR Searches for strings in files.
FOR Runs a specified command for each file in a set of files.
FORMAT Formats a disk for use with Windows.
FTYPE Displays or modifies file types used in file extension associations.
GOTO Directs the Windows command interpreter to a labeled line in a
batch program.
GRAFTABL Enables Windows to display an extended character set in graphics
mode.
HELP Provides Help information for Windows commands.
IF Performs conditional processing in batch programs.
LABEL Creates, changes, or deletes the volume label of a disk.
MD Creates a directory.
MKDIR Creates a directory.
MODE Configures a system device.
MORE Displays output one screen at a time.
MOVE Moves one or more files from one directory to another directory.
PATH Displays or sets a search path for executable files.
PAUSE Suspends processing of a batch file and displays a message.
POPD Restores the previous value of the current directory saved by PUSHD.
PRINT Prints a text file.
PROMPT Changes the Windows command prompt.
PUSHD Saves the current directory then changes it.
RD Removes a directory.
RECOVER Recovers readable information from a bad or defective disk.
REM Records comments (remarks) in batch files or CONFIG.SYS.
REN Renames a file or files.
RENAME Renames a file or files.
REPLACE Replaces files.
RMDIR Removes a directory.
SET Displays, sets, or removes Windows environment variables.
SETLOCAL Begins localization of environment changes in a batch file.
SHIFT Shifts the position of replaceable parameters in batch files.
SORT Sorts input.
START Starts a separate window to run a specified program or command.
SUBST Associates a path with a drive letter.
TIME Displays or sets the system time.
TITLE Sets the window title for a CMD.EXE session.
TREE Graphically displays the directory structure of a drive or path.
TYPE Displays the contents of a text file.
VER Displays the Windows version.
VERIFY Tells Windows whether to verify that your files are written
correctly to a disk.
VOL Displays a disk volume label and serial number.
XCOPY Copies files and directory trees.
C:\>Echo %TIME%
13:15:23.50
C:\>
-
Bill
My system response to "SET " is similar to yours.
It fails to show volatile variables such as %TIME% and %DATE%,
so I can only display their values if I know their names.
I can use "ECHO %ACRONIS_PATH% and that will show me what I want to know,
BUT ONLY if I correctly guess that ACRONIS_PATH is the name that I need.
As it happens ACRONIS_PATH is not defined, so the only response is "Echo is OFF".
What I am hoping for is some way to discover the names of volatile / hidden / secret variables, after which I can use ECHO %WHATEVER% etc. to find their values.
Unfortunately the HELP list of commands does not appear to include anything to help in my quest.
Incidentally, I am amused that halfway through that list is the line
"HELP Provides Help information for Windows commands."
It looks like Microsoft do not know their DOS from their WINDOWS ! !
I am hoping for a DOS or EXTENDED DOS type command to reveal dynamic variables,
or failing that a simple VB script.
If "push comes to shove" I can search the registry for dynamic variables I already know, such as DATE and TIME, and hope that I will find where these dynamic things are held. But searching the registry takes so much time
Alternatively, Google search "dynamic environmental variables" took only 0.39 Seconds to find 308,000,000 - but I am too lazy to inspect every result ! !
Regards
Alan
-
you maybe want sth like this:
set ACRONIS_PATH
-
No, that would not work.
I know that TIME is a dynamic variable,
and "ECHO %TIME%" gives a result such as 21:21:59.16
But SET TIME merely results in "Environment variable TIME not defined"
because "SET " only deals with fixed variables and not dynamic.
SET ACRONIS_PATH will always say "Environment variable ACRONIS_PATH not defined",
regardless of whether it is totally undefined (and not the NAME I am looking for),
and it will say the same even if it is defined as a dynamic variable.
It will only admit to the presence of a FIXED variable.
ACRONIS_PATH is just wishful thinking of what I would like to locate.
I just do not know if ACRONIS have created a dynamic variable,
and I do not know what name they might have used.
I could capture all fixed and dynamic 8 character variables with
SET %%A%%B%%C%%D%%E%%F%%G%%H | FIND /V /I "not defined" >> set.txt
and place that within 8 nested for loops that increment each of %%A, %%B etc. through all printable characters.
but I also need to deal with possibilities of fewer then 8 characters and more than 8 characters.
It would probably take as long as Deep Thought took to compute that "42" was the answer to
"The meaning of Life and all that" ! !
Regards
Alan
-
Incidentally, I am amused that halfway through that list is the line
"HELP Provides Help information for Windows commands."
It looks like Microsoft do not know their DOS from their WINDOWS ! !
Billrich's operating system is listed as Windows XP therefore the command list he posted is from Windows not DOS. Windows XP does not include any version of DOS, CMD.exe is a Windows program, runs in a Window and interprets Dos-like commands. The Help command quoted does Provide Help information for Windows commands.
Below is a quote from Wiki (http://en.wikipedia.org/wiki/CMD.EXE):
Technically, cmd.exe is a Windows program that acts as a DOS-like command line interpreter. It is generally compatible, but provides extensions which address the limitations of COMMAND.COM:
-
Dusty
I will concede that point to you !
I believe command.com is similarly dependant upon Windows, and is generally less powerful than cmd.exe.
One other amusing detail, Command.com has an identical help file -
so identical that it has the same line
"EXIT Quits the CMD.EXE program (command interpreter)."
Regards
Alan
-
Trying to delve into Command.com throws up more quandaries than it solves. I agree there is a dependency on Windows and also believe that there is a dependency on Cmd.exe. Just look at the top line in the attachment "Microsoft (R) Windows DOS", if ever there was an oxymoron that must be one. Also, the first line of Config.nt is "Windows MS-Dos Startup File".
The attachment shows what happens in Command.com if an attempt is made to echo a variable which is normally set by Cmd.exe, Cmd.exe is opened!!
Lots to investigate but not enough time.
Regards
Dusty.
[attachment deleted by admin]
-
Dusty
I cannot obtain your result.
Regardless of whether I use Command.com or Cmd.exe, I get the same result :-
C:\DOCUME~1\DAD>echo %cmdcmd line%
%cmdcmd line%
I launch the "DOS" thing via Windows => Run
I have administrator privileges.
I am using XP Home edition with SP3.
ESET and Comodo keep me free of malware.
I am puzzled by your qualification "a variable which is normally set by Cmd.exe".
I know that "SET " has subtle differences between Command.com and Cmd.exe,
but I tested and found that Command.com is identical to Cmd.exe in the ability to set and also display a variable that includes an embedded space.
As a final test, I used Cmd.exe to launch Command.com after it created the variable "cmdcmd line", and then Command.com received that in its environment and was able to display without peculiarity thus :-
C:\Documents and Settings\Dad>set cmdcmd line=junk
C:\Documents and Settings\Dad>echo %cmdcmd line%
junk
C:\Documents and Settings\Dad>command.com
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\DOCUME~1\DAD>echo %cmdcmd line%
junk
C:\DOCUME~1\DAD>
I find it very strange that in your example, your entire command was typed in lower case, but the DOS response when repeating your command it capitalised the "echo" but not the "%cmdcmd line%".
I so agree with your opening comment -"Trying to delve into Command.com throws up more quandaries than it solves".
Another good way of filling a slow weekend is to investigate "setlocal enabledelayedexpansion".
I have found that once it is enabled it has to remain enabled - otherwise "the results are undefined" (as often repeated by a 'C' tutor to our class when anyone tried to do anything outside the rules).
Specifically, I believe the "setlocal ..." launches a new environment in which all further variables are created, regardless of whether they need to be in this "setlocal ..." state. If this "setlocal .." is disabled than ALL variables defined BEFORE it was enabled are still known, but everything defined within the enabled state is now lost.
Regards
Alan
-
Alan_BR _ we're really beating this one to death, not sure if we'll ever reach any conclusion tho'.
Regardless of whether I use Command.com or Cmd.exe, I get the same result :-
C:\DOCUME~1\DAD>echo %cmdcmd line%
%cmdcmd line%
You've inserted a space between %cmdcmd and line% which changes the var name considerably, try it without the space.
I am puzzled by your qualification "a variable which is normally set by Cmd.exe"
When Cmd.exe is invoked it automatically sets the var %cmdcmdline% without you having to use Set (not quite true but near enough). Attached are a couple of screenshots of Cmd.exe having been invoked using Start>Run and using a shortcut with parameters (my choices). You'll note that the /E and /V parameters are selected.
I find it very strange that in your example, your entire command was typed in lower case, but the DOS response when repeating your command it capitalised the "echo" but not the "%cmdcmd line%"
I guess this was a preference of the writer of Command.com to emphasize the command being used, quite a common practice.
The uses of Setlocal Enabledelayedexpansion are well documented here (http://www.ss64.com/nt/setlocal.html)..
Always stick with what your tutor tells you :||
D.
[attachment deleted by admin]
-
I just thought of this, set acro=%acronis_in_variable% should work...
-
I just thought of this, set acro=%acronis_in_variable% should work...
::)
explain...
-
Set will make the variable whatever is on the other sidde of the equal sign at the time the command is run. So if it is a dynamic variable, then you can get it...just like %random%.
-
and what, pray, is "%acronis_in_variable%"?
-
SET totally fails to show dynamic environmental variables such as %TIME%
Is there a special argument for SET to expose all dynamic variables ?
Or is there a SET_DELUXE type of command that can reveal this information.
Regards
Alan
so are you saying that ACRONIS has set a "dynamic variable" the same as variables like %TIME% or %RANDOM% and it doesn't show when you call set? can you show what your "set' command looks like? cause AFAIK, %DATE% , %TIME% or %RANDOM% are little things that cmd.exe gives you out of convenience, they are not environment variables.
-
gh0std0g74 - thanks for dropping in.
cause AFAIK, %DATE% , %TIME% or %RANDOM% are little things that cmd.exe gives you out of convenience, they are not environment variables.
The Set command Help display (set/?) names these as "dynamic environment variables". AFAIK the placeholder does not contain a value, the value is computed when the dynamic environment variable is expanded. Not containing a value means that the dyn env var cannot be displayed using Set, there simply isn't anything to display.
Regards
D.
-
What ghostdog means is, they are not "really" environment variables, in that they do not reside in the environment block (which is basically what "set" shows.)
Also- applications can only change the environment block- including acronis.
I would imagine that they documented what variables they define.
-
What ghostdog means is, they are not "really" environment variables, in that they do not reside in the environment block (which is basically what "set" shows.)
that's right.
-
Dusty
When I first saw you jpeg I could not read it until I clicked and it enlarged.
When enlarged I saw " %cmdcmd line% ".
I now realize my tired eyes misplaced the space, it now looks like %cmdcmdl ine%,
but when I greatly magnify the image I realize the "space" is an artifact due to "DOS" not using proportional spacing.
Thank you for your explanation. The world makes a little more sense now.
Thank you for the link to "The uses of Setlocal Enabledelayedexpansion",
and also for pointing me back to the use of "SET /?" - previously I never read through to the end because my problems were usually resolved halfway through ! !
Thanks to everyone who recently posted.
If Acronis created a variable "acronis_in_variable" I would be O.K. with "set acro=%acronis_in_variable%".
Unfortunately I do not know the name(s) of any variables they may create,
and do not even know if they create any at all.
n.b. My interest is in ANY sort of variable that Acronis may use or influence,
not just fixed and dynamic, but also other sorts (I vaguely remember last year I encountered at least two other sorts, including "dynamic").
Regards
Alan
-
I think, what your seeing as "dynamic" variables, are merely variables Acronis adds before running your script.
See, when a program executes another program, it can pass a new environment block to that program. Acronis, for example, is possibly adding new variables to it's environment block and passing that as the environment of the script.
Havey you tried using "SET" from within your script? perhaps redirecting it to a file? This will reveal such variables.
I still believe that Acronis would have this type of stuff documented somewhere.
-
Hi
No, we have a misunderstanding.
I have never seen any sort of variable that looked as though it was related to Acronis.
I merely hoped that there was such a variable that might give me a clue upon what it was doing.
I have already tried
ECHO CMDCMDLINE == %CMDCMDLINE% >> C:\Utils\CMD\ToBak.txt
SET >> C:\Utils\CMD\ToBak.txt
The first item shows me command issued by Acronis, which was
CMDCMDLINE == cmd /c ""C:\Utils\CMD\ToBak.cmd" A B C D"
I had been hoping to learn of other dynamic/volatile/special variables, such as %CMDCMDLINE%, which SET does not display, but which are displayed with a suitable
ECHO %whatever%
to give me a further insight.
I have already inspected several MBytes of Acronis documentation without success,
and have also posted queries on the Acronis support forum looking for specific guidance.
I have lost hope of finding any useful Acronis variable of any sort, and think they probably have not created any such thing, so I am giving up on this and will use a totally different approach to meeting my requirements.
My thanks to everyone who has responded to this thread.
I have gained extra useful knowledge, even though my original quest has failed
Regards
Alan
-
it's also possible, that they are passing some items via command-line arguments to your batch file.
-
Yes, my script captures
CMDCMDLINE == cmd /c ""C:\Utils\CMD\ToBak.cmd" A B C D"
The trailing "A B C D" are the only arguments that I receive, and they do not help me either !
Regards
Alan