Page 1 of 1

Problem with "start" command

Posted: 21 Jul 2019 05:15
by infectedw
So i doing rework on my program (https://github.com/infectedw/testerandtracker) and i have some weird problem (i think its bug).

Command start won't do anything, literally anything this is example of code:

Code: Select all

:Menu
title Menu
cls
echo ===============================================================
echo ^> Logged User: %USERNAME%
echo ^> Os: %SYSTEMID%
echo ^> Admin Rights: %aenabled%
echo ===============================================================
set/p choice="Command:"

@echo [%time%] [Command] "%choice%" >> Log.txt 

if %choice%=="set-adminmode-on" goto :on
if %choice%=="set-adminmode-off" goto :off
if %choice%=="check-extension" start Extension.exe & goto Menu
if %choice%=="calc" goto calc
if %choice%=="cpanel" goto cpanel
if %choice%=="show-log" start /d "\Log.txt" Log.txt
goto Menu
So i need to open log.txt and it won't do anything, and yeah i checked twice "L" is upper.

Re: Problem with "start" command

Posted: 21 Jul 2019 10:44
by aGerman
As long as Log.txt is in the current directory, that should be sufficient:

Code: Select all

start "" "Log.txt"
Steffen

Re: Problem with "start" command

Posted: 21 Jul 2019 14:45
by infectedw
Nothing happen, won't start it at all, like i didn't wrote anything. Any suggestion? This starts to piss me off...

Re: Problem with "start" command

Posted: 21 Jul 2019 19:16
by dbenham
The /D option is used to specify the path to the directory containing your target (your file). It should not include the file name.

Also, if the first argument is quoted, then it must be your window title.

As aGerman said, if the log.txt is in the current directory, then remove the /D option altogether.

Code: Select all

start "" "log.txt"
If the file is not in the current directoy, then add the /D option with the path to the directory, If the file is "C:\MyDirectory\log.txt", then:

Code: Select all

start "" /D "C:\MyDirectory" "log.txt"

Dave Benham

Re: Problem with "start" command

Posted: 06 Aug 2019 08:20
by Looge
infectedw wrote:
21 Jul 2019 14:45
Nothing happen, won't start it at all, like i didn't wrote anything. Any suggestion? This starts to piss me off...
replace
start /d "\Log.txt" Log.txt
with
Log.txt

See what happens ..
Are you sure that text files haven an application associated to it ? Are you sure it is what you think it is ?
Then, either the file or the directory is wrong, no ? Maybe you switched drive somewhere else, and your active drive is not what you think it is.
Subsequently, your path is invalid then ..

Re: Problem with "start" command

Posted: 11 Aug 2019 08:10
by Eureka!
specify a path to the logfile, so you are not depending on the current working directory.
For example if you run elevated, the default cwd is c:\windows'system32.


set LOGFILE=%~dp0log.txt
....
@echo [%time%] [Command] "%choice%" >> "%LOGFILE%"