read arguments for console application
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
read arguments for console application
I am writing a modular program that runs in user mode. However, the program will need a kernel driver and DLL running. If those items are not present, I would like to install them. Is there a way to temporarily escalate execution level for a single command and WMI stuff (because some users have UAC running silent mode and don't see the requests, just deny them)?
I was thinking it would be better to have an external program that requested administrative privileges, and then would read the arguments passed to it and perform the functions. For example:
// No Driver Installed
get shell("adminpriv.exe /installdriver /installtask /installDLL")
So in writing adminpriv, how would I read the arguments that were passed to it (/installdriver, etc) ? Is there a better way to pass arguments to a runrev application (windowless)?
I was thinking it would be better to have an external program that requested administrative privileges, and then would read the arguments passed to it and perform the functions. For example:
// No Driver Installed
get shell("adminpriv.exe /installdriver /installtask /installDLL")
So in writing adminpriv, how would I read the arguments that were passed to it (/installdriver, etc) ? Is there a better way to pass arguments to a runrev application (windowless)?
Re: read arguments for console application
Hello Steve,
Robert
I would ask for username and password, escalate the execution level by the runas command or the ShellExecute API via VBScript, check the permissions and do my stuff.Is there a way to temporarily escalate execution level for a single command and WMI stuff (because some users have UAC running silent mode and don't see the requests, just deny them)?
That's up to you.I was thinking it would be better to have an external program that requested administrative privileges, and then would read the arguments passed to it and perform the functions.
Look in the docs for the dollar keyword. Specify "-ui" as part of the launching commandline or hide the stack, handle the arguments in the preopenStack handler, write your output to stdout and dont forget to quit the engine.[...] how would I read the arguments that were passed to it (/installdriver, etc) ? Is there a better way to pass arguments to a runrev application (windowless)?
Robert
Re: read arguments for console application
Well i got it working as a console thing. However, I am having some trouble getting the output to show up.
I am running shell commands but i can't seem to capture the output and print it to the terminal.
ex:
Nothing shows up in the terminal. Does stdOut need to be initialized somehow?
I am running shell commands but i can't seem to capture the output and print it to the terminal.
ex:
Code: Select all
set the hideconsolewindows to true
write "Hello? Anyone Home?" to stdOut
get shell("netsh firewall delete portopening protocol = TCP port = 22217")
write it to stdOut
Re: read arguments for console application
Sorry I forgot that this is a know issue or bug. And I bet that "-ui" is not working anymore too cause of the 4.0 engine changes. So you have to use something else (AutoIT, a VBScript using cscript or a command line- / batch script).Nothing shows up in the terminal.
AutoIT could create compiled console applications and if you deceide to use VBScript or a command line / batch script, you could use a script packaging application or a batch compiler to get a binary. Simply search for "vbs to exe" or "batch compiler" in the search engine of your choice.
I would suggest that use a command line script, thats the easiest way and it should sufficient too for the mentioned task.
I used QuickBFC in the past to create a compile application and could recommend it.sample.cmd
@echo off
echo.Sample v.1.0
echo.Copyright (C) 2010 by ... All rights reserved.
echo.
if %1!==! goto argument_missing
if %1==status goto status
:status
echo. Status Overview
echo.
goto quit
:argument_missing
echo.Missing argument!
echo.
echo.Valid arguments are status, ...
echo.
goto quit
:quit
Of course you could also use C/C++ to create a Win32 console application in a fairly amount of time depending on your knowledge. If you like to do so check out Visual C+ 2008 Express Edition.
Robert
Re: read arguments for console application
Thanks for that. I can see this is an issue as well for Windows. However, I was able to capture the stdout and just stick it elsewhere for the time being.
Re: read arguments for console application
I took some time to look into the issue in detail. The reason why you could not write to stdout under Windows using the put command is caused by the fact that the executable is set to WINDOWS_GUI instead of WINDOWS_CUI (console application) in the subsystem field within the PE header.
You could change that by patching the binary with PE Patcher for example.
Simply change Windows GUI to Windows Console and click "Save".
PS: You still need to start your executable using the -ui argument.
Robert
You could change that by patching the binary with PE Patcher for example.
Simply change Windows GUI to Windows Console and click "Save".
PS: You still need to start your executable using the -ui argument.
Robert
Re: read arguments for console application
for cgi and faceless apps, you don't use "write to x" for outputting stuff. you use "put", like this:
Code: Select all
#rev -ui
on startup
put "hello world"
end startup
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: read arguments for console application
Yes you could also use put. But in general you need to change the subsystem value in the PE header to create a console application for Windows otherwise your content will not appear.
Robert
Robert