|
-
Dec 31st, 2012, 11:45 AM
#1
Thread Starter
Member
Help with executing command from cmd
Hi,
I am trying to execute this command from cmd when a button is clicked:
Code:
wevtutil qe system "/q:*[System [(Level=2)]]" /f:text /c:5 /rd:True
The problem is that I can't execute it successfully due to the presence of the Quotations in the cmd line of code itself.
The code in Visual Studio looks somewhat like this:
Code:
Shell("cmd /c wevtutil qe system " /q:*[System [(Level=2)]]"/f:text /c:5 /rd:true >C:\Last5.txt", vbHide)
I'd really appreciate the help with this, please.
Thanks in advance...
-
Dec 31st, 2012, 11:55 AM
#2
Re: Help with executing command from cmd
You need to escape each quote mark by adding another one to it (i.e replace 1 double quote mark with 2 double quote marks)
Code:
Shell("cmd /c wevtutil qe system ""/q:*[System [(Level=2)]]""/f:text /c:5 /rd:true >C:\Last5.txt", vbHide)
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Dec 31st, 2012, 12:15 PM
#3
Thread Starter
Member
Re: Help with executing command from cmd
 Originally Posted by stanav
You need to escape each quote mark by adding another one to it (i.e replace 1 double quote mark with 2 double quote marks)
Code:
Shell("cmd /c wevtutil qe system ""/q:*[System [(Level=2)]]""/f:text /c:5 /rd:true >C:\Last5.txt", vbHide)
Thanks for the reply, the code you provided seems to solve the error i was getting due to the quote marks, but it still won't write the output to the Text File (Last5.txt)
It just creates an empty file...
-
Dec 31st, 2012, 12:23 PM
#4
Re: Help with executing command from cmd
Open the command prompt then manually type in the command and execute it... When you get the desired result, come back here and post the exact command you used...
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Dec 31st, 2012, 01:13 PM
#5
Thread Starter
Member
Re: Help with executing command from cmd
There seemed to be a minor silly mistake in my code, i had forgotten to put a blank space after a quote mark which most probably caused the line of code to be unrecognized...
it's now solved, thanks to you...
thanks alot ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|