Link to home
Start Free TrialLog in
Avatar of npcs
npcs

asked on

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

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.
ASKER CERTIFIED SOLUTION
Avatar of graye
graye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of npcs
npcs

ASKER

Thank you so much! Solved it straight away.
Avatar of npcs

ASKER

While your here, is there any way in VB.net or shell to take a jpg screen shot?