load command prompt from ie9 - asp.net

How can i execute a command prompt command from ie9?
I know that this:
file:///c:\windows\system32\cmd.exe
loads it up but how to add a command to that?

The IE is not actually execute the command, is just transfer it to the windows shell - meaning that Microsoft have merge IE with Windows Shell to make the user interface more friendly - so calling this from the url, you are not actually do something with the browser.
This commands may execute only interactivity on the browser url and can not be call them programmatically for obvious reasons... like that:
file:///c:\windows\system32\cmd.exe del c:\*.*

Related

Ranorex scripting; how do I send commands to the browser?

Ranorex scripting; how do I send commands to the browser?
I would like to send a command string to the browser, i.e. instead of using the browser developer tools console input
I agree with theDarse. Take a look at the following website:
http://www.ranorex.com/support/user-guide-20/web-testing/samples.html#c1986
The following code should work.
webDocument.ExecuteScript("history.back();");

Programmatically creating PDF from webpage

I have my resume online in an html page (www.mysite.com/resume.html). Every time I need a PDF version of it, I use Google Chrome's print dialog to save it as a PDF, which uses my print CSS stylesheet.
I want to be able to navigate to www.mysite.com/resume.pdf to always have an up to date PDF version without having to go through Google Chrome manually. Is there a way to programmatically and automatically create a resume.pdf from resume html? If I can write a script that runs once every 24 hours or something like that, that would be good.
PhantomJS is perfect for this. It invokes an instance of WebKit from the command line which can then be used to output to file such as PDF.
PhantomJS:
http://phantomjs.org/
Specific instructions for exporting screen output to a file:
http://phantomjs.org/screen-capture.html
e.g.:
phantomjs rasterize.js 'http://www.example.com/resume.html' resume.pdf
Chrome has started headless program.
With that, we can create a pdf. e.g. for windows navigate your commandline to
C:\Users\{{your_username}}\AppData\Local\Google\Chrome SxS\Application>
Then hit the command:
chrome --headless --print-to-pdf="d:\\{{path and file name}}.pdf" https://google.com
If you are looking to do this server-side via PHP might I recommend the Browsershot library which leverages the Puppeteer (NodeJS package) and Chrome / Chromium headless browser?
It works really well. Way easier to install and get going than wkhtmltopdf (which is another option that doesn't rely on a NodeJS package nor the Chrome/Chromium headless browser. Personally, I recommend Browsershot solution since wkhtmltopdf has some issues depending on the type of server (Linux distro and version) you're running. That is, the only reliable way to install wkhtmltopdf that I've found is to download and compile from source on the server that you're running and not through a package manager).
Also, if you happen to be needing a solution specifically while working on a Laravel project then there's a wrapper library for Browsershot available.
Check out this tutorial to get started.

iMacros-like program that can run from the command line to automate browser actions?

Here's what I would like to do:
Cron execute an iMacro (or iMacro-like) script on a headless unix server - essentially doing my browser interactions for me.
Is this possible?
I'm sure cURL won't be able to traverse the DOM and trigger user events. iMacros would be perfect if I could run it in unix CLI, which you can, but I run a headless server without Xorg and obviously FF requires Xorg. iMacro with Lynx would be good but I doubt iMacro works with Lynx.
Anyone got any ideas?
Old question, but I was looking for about the same thing, and I found this post on Google. Here the answser :
There is some headless browser which can run on an Unix system without Xorg. You can try CasperJS, PhantomJS or Zombie by example.

QProcess::startDetached blocked by UAC (running an updater)

I have an update function in my app - it downloads and verifies the installer (a setup.exe, created with NSIS). To actually kick off the update, I have simply been doing:
QString path = .. absolute path to the downloaded file ...
QProcess::startDetached(path, QStringList());
This works fine on XP - but on Vista and Win7, nothing happens once the download completes. If I browse to the downloaded update and run it manually, it works fine. I assume what's happening is that UAC is blocking the installer at CreateProcess time, but this is where my knowledge runs out.
Additional complication - when I'm running a debug build from the command line, the steps above work - I get the UAC prompt and can run the installer. It's the release builds, started form the start menu/shortcut, which have the issue - I assume there's a difference in the auth token when running from a command shell.
You can also use
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
Might be surprising and counterintuitive, but it works and is more cross-platform
If you are not admin and you call CreateProcess() on a .exe with a "Vista" manifest (or no manifest, but a .exe that windows detects as an installer (This includes NSIS)) the call fails, you need to use ShellExecute[Ex](). ShellExecute will trigger UAC prompt if required...
This seems to be a Qt bug, see QTBUG-9761 , the correct workaround is to use ShellExecute with lpOperation set to runas.
Another alternative is to prepend your execution with cmd.exe /C. This effectively routes your execution through the shell, so you do get the UAC prompt. The downside is that if your process fails you probably won't get as much information had you gone through ShellExecute[Ex], but on the plus side you will get all the facilities of QProcess that you miss if you use QDesktopServices::openUrl, where you have no idea if things worked or not.

Tool or IDE to debug VB Script code

I need any tool or IDE environment to debug and test the vb scripts code. Please suggest any free ones. My vb scripts are standalone (vbs extenstion).
VBSEdit
Not free, but has an unlimited trial period with a nag screen.
Sadly not free....How to debug Windows Script Host, VBScript, and JScript files
I think you'll have a hard time finding a free tool that supports real VBS debugging. But I've used this "poor man's technique" in the past. Create a variable at the beginning of your script
blnDebug=False
Then throughout your script add lines to echo what the script is doing or the value of different variables:
if blnDebug Then wscript.echo "Now starting script strFoo=" & strFoo
When you set blnDebug=True then all your debug messages will be written to the console (I always use CScript when running this). By adding these debug messages as you write your script, you can have debugging available simply by changing the bldDebug value.
Certainly commercial editors like PrimalScript include a debugger. SAPIEN also has a standalone debugger, http://www.primalscope.com/, that while not free is a relatively inexpensive option. You can download an eval copy to try it out.
There is a really old tool called Script Debugger for Windows NT 4.0 and Later. It is designed for VBScripts running in web pages but you can attach it to a vbs script easy enough.
You can download it from here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&displaylang=en
The name says NT 4.0 I know but I am currently running it on Windows 7 x64 and hod no problems opening the debugger.
Simply install the above tool then run your script from the commandline like:
wscript.exe myscript.vbs //d //x
Once the debugger opens you can step through code and even open a command window where you can check variable values by typeing ? Varname.

Resources