?
Solved

sc query > [filename] not working as a shell command in VB .NET... help?

Posted on 2008-06-17
3
Medium Priority
?
856 Views
Last Modified: 2010-04-21
The command I am trying to run in VB .net is as follows:

Shell("sc query > " & Chr(34) & "C:\Dir Name\ServicesRunning.txt" & Chr(34))

The Directory name has spaces and needs to keep them. I have output that code to a label and it reads exactly as it should:

sc query > "C:\Dir Name\ServicesRunning.txt"

Why Isn't it working? I really don't want to resort to my stop gap solution of running an external batch file to execute the command.
0
Comment
Question by:npcs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
graye earned 2000 total points
ID: 21823372
The redirection feature is really part of the command shell... so you need to alter your statement to look like  this:

Shell("cmd /c sc query > " & Chr(34) & "C:\Dir Name\ServicesRunning.txt" & Chr(34))
0
 

Author Comment

by:npcs
ID: 21827052
Thank you so much! Solved it straight away.
0
 

Author Closing Comment

by:npcs
ID: 31468226
While your here, is there any way in VB.net or shell to take a jpg screen shot?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question