Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keep cmd window open?
#1
Is it possible to keep the cmd open after runconsole2 is executed.
Now it executes the .exe in the runconsole2 command and closes immediately after .exe is finished.

Or is there another way to do this?

The only way I know is to start cmd, wait for it's window to become visible and active, then use control+v or sendkeys.
But I was wondering if there is a more robust/effective way to do this?

I also looked in the "run" command (window options) but couldn't find it there.
#2
maybe something like this will help ya
http://www.quickmacros.com/forum/showthr...0#pid27790

or this
http://www.quickmacros.com/forum/showthr...6#pid27876
#3
Use cmd command line, not paste/key.
Macro Macro36
Code:
Copy      Help
run "cmd.exe" "/K taskkill.exe /?"

Or create console exe from the macro:
Macro Macro37
Code:
Copy      Help
;/exe
CreateProcessSimple "taskkill.exe /?" 1
ExeConsoleWrite "[]Press any key to exit..."
getch

;BEGIN PROJECT
;main_function  Macro37
;exe_file  $my qm$\Macro37.exe
;icon  <default>
;manifest  $qm$\default.exe.manifest
;flags  70
;END PROJECT


Function CreateProcessSimple
Code:
Copy      Help
;/
function# $cl [flags] ;;flags: 1 wait until exits, 2 return handle, 4 inherit uiAccess

;Calls CreateProcess.
;By default returns pid. If flag 2 - handle. If flag 1 - exit code.
;Error if fails.

;cl - program path, optionally followed by command line arguments.
;;;Program path can be enclosed in quotes. Should be enclosed if contains spaces.
;flags:
;;;1 - wait until exits and return the exit code.

;NOTES
;CreateProcess fails if would show UAC consent. Use run() instead.

;EXAMPLE
;int ec=CreateProcessSimple("''$my qm$\this_is_my_exe.exe'' /a ''b''" 1)
;out ec


opt noerrorshere 1

sel cl 2
,case ["$*","%*"] cl=_s.expandpath(cl)
,case ["''$*","''%*"] _s.expandpath(cl+1); _s-"''"; cl=_s

STARTUPINFOW si.cb=sizeof(si)
PROCESS_INFORMATION pi
int R ok
if flags&4
,__Handle hToken
,OpenProcessToken(GetCurrentProcess() TOKEN_QUERY|TOKEN_DUPLICATE|TOKEN_ASSIGN_PRIMARY &hToken)
,ok=CreateProcessAsUserW(hToken 0 @cl 0 0 0 0 0 0 &si &pi)
else
,ok=CreateProcessW(0 @cl 0 0 0 0 0 0 &si &pi)
if(!ok) end _s.dllerror
CloseHandle pi.hThread
R=pi.dwProcessId

if flags&1
,opt waitmsg -1
,wait 0 H pi.hProcess
,GetExitCodeProcess pi.hProcess &R

if(flags&2) R=pi.hProcess; else CloseHandle pi.hProcess

ret R
#4
Thank you both!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)