Code: Select all
start myapp.exe
Code: Select all
start /w myapp.exe
Code: Select all
start myapp.exe
Code: Select all
start /w myapp.exe
Like this?!jassing wrote:Any ideas on a way to detect if the app is run via:or (actually more important)Code: Select all
start myapp.exe
Code: Select all
start /w myapp.exe
Code: Select all
Import "kernel32.lib"
AttachConsole(PID)
EndImport
#ATTACH_PARENT_PROCESS = -1
If AttachConsole(#ATTACH_PARENT_PROCESS)
GetConsoleScreenBufferInfo_(GetStdHandle_(#STD_OUTPUT_HANDLE), csbi.CONSOLE_SCREEN_BUFFER_INFO)
If csbi\dwCursorPosition\x = 0
text$ = Chr(13) + "Program was started with 'start /w'. Press 'Enter' To continue..."
Else
text$ = Chr(13) + "Program was started from the command line. Press 'Enter' To continue..."
EndIf
WriteConsole_(GetStdHandle_(#STD_OUTPUT_HANDLE), @text$, Len(text$), 0, 0)
If csbi\dwCursorPosition\x = 0
ReadConsole_(GetStdHandle_(#STD_INPUT_HANDLE), @null, 0, @null, 0)
EndIf
Else
MessageRequester("", "Program was started the usual way...")
EndIf
Code: Select all
Procedure.s _input_()
Protected.s inString
Protected *buffer, buflen=2048
*buffer = AllocateMemory(buflen)
If ReadConsole_(GetStdHandle_(#STD_INPUT_HANDLE),*buffer,buflen,@buflen,0)
OutputDebugString_("Len: "+buflen)
OutputDebugString_("Success: "+PeekS(*buffer))
inString = PeekS(*buffer,buflen)
Else
OutputDebugString_("Failed read()")
EndIf
FreeMemory(*buffer)
MessageRequester("Input()","Input result: "+inString)
ProcedureReturn inString
EndProcedure
Import "kernel32.lib"
AttachConsole(PID)
EndImport
#ATTACH_PARENT_PROCESS = -1
If AttachConsole(#ATTACH_PARENT_PROCESS)
GetConsoleScreenBufferInfo_(GetStdHandle_(#STD_OUTPUT_HANDLE), csbi.CONSOLE_SCREEN_BUFFER_INFO)
If csbi\dwCursorPosition\x = 0
text$ = Chr(13) + "Program was started with 'start /w'. Press 'Enter' To continue..."
Else
text$ = Chr(13) + "Program was started from the command line. Press 'Enter' To continue..."
EndIf
WriteConsole_(GetStdHandle_(#STD_OUTPUT_HANDLE), @text$, Len(text$), 0, 0)
MessageRequester("Before...","About to get input, Type 'DIR<enter>'"+#CRLF$+"Notice, it displays the directory"+#CRLF$+"Then type 'XYZ<enter> at next prompt'")
s$=_input_()
MessageRequester("Past Input()","Input retrieved:"+s$)
Else
MessageRequester("", "Program was started the usual way...")
EndIf
MessageRequester("test","All done")
Code: Select all
EnableExplicit
#PB_Compiler_Processor = #PB_Processor_x64 ;x86 x64
#PB_Compiler_ExecutableFormat = #PB_Compiler_Executable ; #PB_Compiler_Executable #PB_Compiler_Console #PB_Compiler_DLL
Import "kernel32.lib"
AttachConsole(PID)
EndImport
#ATTACH_PARENT_PROCESS = -1
#STARTF_TITLEISLINKNAME = $800
Define.CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo
Define.STARTUPINFO StartupInformation
Define.s sTitle
Define.s sExtention
Define.s sMessage
Define.s sConsoleMessage
Define.s CrLf
GetStartupInfo_(StartupInformation)
sTitle = PeekS(StartupInformation\lpTitle)
sExtention = LCase(Right(sTitle, 4))
CrLf = Chr(13) + Chr(10)
If StartupInformation\dwFlags And #STARTF_TITLEISLINKNAME
If sExtention = ".lnk"
sMessage = "This program was started via this shortcut."
ElseIf sExtention = ".exe"
sMessage = "This program was started via Explorer" + CrLf +
"or by the Run dialog or by another process."
EndIf
sMessage = sMessage + CrLf + CrLf + "Exe name is: " + sTitle
Else
sMessage = "This program was started from a batch file or command prompt." + CrLf + CrLf +
"Exe name is:" + CrLf + sTitle
If AttachConsole(#ATTACH_PARENT_PROCESS)
GetConsoleScreenBufferInfo_(GetStdHandle_(#STD_OUTPUT_HANDLE), ConsoleScreenBufferInfo)
If ConsoleScreenBufferInfo\dwCursorPosition\x = 0
sConsoleMessage = CrLf + "This program was started with [Start /w]." + CrLf
Else
sConsoleMessage = CrLf + "This program was started from the command prompt." + CrLf
EndIf
WriteConsole_(GetStdHandle_(#STD_OUTPUT_HANDLE), sConsoleMessage, Len(sConsoleMessage), 0, 0)
EndIf
EndIf
MessageBox_(#HWND_DESKTOP, sMessage, "Started from...", #MB_OK | #MB_TOPMOST)
Code: Select all
/W or /WAIT Start application and wait for it to terminate.
I think we have a misunderstanding.... the problem is that when used with start/w input fails.chi wrote:It kinda sounds intended... Start and Wait. I don't think you're able to run additional commands with /WCode: Select all
/W or /WAIT Start application and wait for it to terminate.
Do you know a program that behaves like you want? I couldn't find one...
Code: Select all
Import "kernel32.lib"
AttachConsole(PID)
EndImport
#ATTACH_PARENT_PROCESS = -1
If AttachConsole(#ATTACH_PARENT_PROCESS)
GetConsoleScreenBufferInfo_(GetStdHandle_(#STD_OUTPUT_HANDLE), csbi.CONSOLE_SCREEN_BUFFER_INFO)
If csbi\dwCursorPosition\x = 0
text$ = Chr(13) + "Program was started with 'start /w'. Press 'Enter' To continue..."
Else
text$ = Chr(13) + "Program was started from the command line. Press 'Enter' To continue..."
EndIf
WriteConsole_(GetStdHandle_(#STD_OUTPUT_HANDLE), @text$, Len(text$), 0, 0)
If csbi\dwCursorPosition\x = 0
;ReadConsole_(GetStdHandle_(#STD_INPUT_HANDLE), @null, 0, @null, 0)
OpenConsole("test")
PrintN("")
Print("Input: ")
a$ = Input()
PrintN("Your input: " + a$)
Input()
CloseConsole()
EndIf
Else
MessageRequester("", "Program was started the usual way...")
EndIf