I'm New Here I Need CMDebug Help

Jan 22, 2023
2
0
I've used various interactive debuggers over time and most have a way to move/set the next line to be executed. I didn't want to have to reset my batch file which is rather lengthy but instead just set the next line to be executed back a few lines. Is this an option in CMDebug? I've done more than enough searching and haven't been able to find anything that seems related to the info I seek. So if you can help me I'd appreciate it,
 
It took me a bit, but I did find the help for this under Debug;
Jump to This Line

If you click on a line in the debugger window and select "Jump to This Line",
the debugger will continue execution starting with the selected line.

You can can also change the line to be executed next when in debugging mode by moving the caret to the line and either right clicking & selecting "Jump to This Line" or by pressing Ctrl-Shift-F11.

Note that if you attempt to jump into or out of a DO loop or IFF block, bad things will happen!

Joe
Code:
     _x64: 1
   _admin: 1
_elevated: 1

TCC  29.00.17 x64   Windows 10 [Version 10.0.19044.2486]
 
Jan 22, 2023
2
0
Most of the prior IDEs I've used you had an arrow pointing to the next line to be executed and you could move that arrow to any line you wanted.

But now I have another problem.

Here's the code and the reason I wanted to go back to the line that's bolded was because I thought maybe I missed something because the execution didn't make sense.

) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin

I bolded the next active line and I'm expecting it to jump to :gotAdmin but that's not what happens. It simply moves to the italics line and continues on. There's no option on the else it should do an unconditional jump to :gotAdmin.
 
From the help file;
The IF ... ELSE ... syntax of CMD is also supported:

IF [/I] condition (command1) ELSE (command2)

The commands to be executed must be enclosed in parentheses (as in a command group).
If condition is TRUE,
command1 is executed,
if FALSE, command2 is executed.

Note: this syntax is much less powerful than the IFF command, which is recommended.

This works fine in a .btm, but in the past, I have had problems using the IF condition (command1) ELSE (command2) in the debugger, which is why I use the IFF syntax instead.
Code:
@setlocal
@echo off

set a=10

iff %a eq 10 then
  Gosub Command1
else
  Gosub Command2
endiff
quit

:Command1
echo Command 1
Return

:Command2
echo Command 2
Return

If you still want to use the IF condition (command1) ELSE (command2) in the debugger,
and want to use the "Jump to this line" in the debugger with that format,
that is something that @rconn would have to answer.

Joe
 

rconn

Administrator
Staff member
May 14, 2008
12,552
167
Most of the prior IDEs I've used you had an arrow pointing to the next line to be executed and you could move that arrow to any line you wanted.

But now I have another problem.

Here's the code and the reason I wanted to go back to the line that's bolded was because I thought maybe I missed something because the execution didn't make sense.

) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin

I bolded the next active line and I'm expecting it to jump to :gotAdmin but that's not what happens. It simply moves to the italics line and continues on. There's no option on the else it should do an unconditional jump to :gotAdmin.

An IF / ELSE statement is treated as a single line; you can't jump to an individual command inside the IF.
 

Similar threads