Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

cmd commands dont work when cmd was opened from program

Hello,
I am attempting to make a Windows program that clears shadow copies through cmd. The command is:
vssadmin delete shadows /all

This (and all other vssadmin commands) works perfectly when cmd is opened directly by a user. But as soon as a program creates a cmd process, that command returns an error (Class not registered). The command only works when cmd was opened by a user directly. This has been tested on multiple machines and multiple different programs.

I'm completely lost with this one. Why would the way something was opened change how cmd works? Both are being run as admin btw.

Using Qt C++:
QProcess::startDetached("cmd");

That line opens a command prompt window, but any vssadmin commands entered always return errors.
What have you tried so far?
- does it work with simpler commands, e.g. cmd dir *.exe ?
- if not, does cmd /c dir *.exe work?
To answer your question, yes. That command works fine.

Here's a better way to explain it.

If I simply do system("cmd"); a command prompt window opens. Then at that point, any vssadmin commands I type in myself produce errors. So it seems like the command or arguments themselves don't matter, but what matters is HOW cmd was opened.

To get the vssadmin commands working as expected, I would have to type cmd in the search bar and press enter. Then any commands work fine. If I open cmd directly, its perfect. I've tried running cd / for both command prompt windows, and it sets it to the root path, but it doesnt change the outcome.

Edit: Note that typing in only "vssadmin" displays a correct list of options... delete shadows, list shadows, etc. Also, if cmd was opened from a batch file, it works fine.
Weird. The error "Class not registered" is not exactly helpful. Do you get the same error when using cmd from a non-admin account? Microsoft says you need an elevated command prompt...
Thanks for the reply.

Both cmd windows are elevated. Class not registered isnt the only error I'm getting. ANYTHING to do with shadow copies will throw some sort of error (even if it isnt with vssadmin).

The issue I believe isn't so much about the errors themselves because those same commands work perfectly fine when cmd isn't opened from a program. If I open it like normal (start menu search or from a bat file) its perfect.

Figured it out. The cmd being opened was 32 bit and it needed to be the 64 bit version. In the 32 bit cmd, I navigated to c:/windows/sysnative/cmd.exe. Then I navigated to c:/windows/system32/vssadmine.exe and ran the command.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by Sir BillyAug 26, 2019 06:33 PM 1 148 Aug 26, 2019 06:33 PM
Last Post: YouthInAsia
[.NET] by KyFuJun 20, 2017 12:34 PM 1 152 Jun 20, 2017 12:34 PM
Last Post: KyFu
[.NET] by Flu0zNov 18, 2016 03:30 PM 7 251 Nov 18, 2016 03:30 PM
Last Post: Malicious Intent