Problem with "start" command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
infectedw
Posts: 4
Joined: 16 Jun 2019 17:29

Problem with "start" command

#1 Post by infectedw » 21 Jul 2019 05:15

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.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Problem with "start" command

#2 Post by aGerman » 21 Jul 2019 10:44

As long as Log.txt is in the current directory, that should be sufficient:

Code: Select all

start "" "Log.txt"
Steffen

infectedw
Posts: 4
Joined: 16 Jun 2019 17:29

Re: Problem with "start" command

#3 Post by infectedw » 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...

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Problem with "start" command

#4 Post by dbenham » 21 Jul 2019 19:16

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

Looge
Posts: 3
Joined: 25 Jun 2019 07:21

Re: Problem with "start" command

#5 Post by Looge » 06 Aug 2019 08:20

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 ..

Eureka!
Posts: 136
Joined: 25 Jul 2019 18:25

Re: Problem with "start" command

#6 Post by Eureka! » 11 Aug 2019 08:10

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%"

Post Reply