Deleting a registry key using system()

Was "Just need some help = )"

Page 1 of 1

5 Replies - 1461 Views - Last Post: 31 October 2011 - 06:06 PM Rate Topic: -----

#1 n0pr0bl3m  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-October 11

Deleting a registry key using system()

Posted 31 October 2011 - 12:24 PM

When im trying to delete a registry key with that code :

system("REG DELETE HKLM\\Software\\Microsoft\\Windows NT");

... just an example

I get this error : "Invalid command-line parameters"
Ive noticed that its because of the space in it but i cant figure out how to fix my problem thats why im posting here.

sorry if here isnt the right place to post that but im new (just registered)

Is This A Good Question/Topic? 0
  • +

Replies To: Deleting a registry key using system()

#2 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1623
  • View blog
  • Posts: 5,710
  • Joined: 03-August 09

Re: Deleting a registry key using system()

Posted 31 October 2011 - 01:31 PM

you have a space in the "Windows NT" directory. it get's parsed as a separate command line parameter not as part of the file path.
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6106
  • View blog
  • Posts: 23,654
  • Joined: 23-August 08

Re: Deleting a registry key using system()

Posted 31 October 2011 - 02:47 PM

Please don't use titles like "Just need some help = )". We KNOW you need help, or you wouldn't have registered and posted! Use a descriptive title like that to which I've changed yours.
Was This Post Helpful? 0
  • +
  • -

#4 OLH064  Icon User is offline

  • Junior bit compressor

Reputation: 20
  • View blog
  • Posts: 725
  • Joined: 06-June 11

Re: Deleting a registry key using system()

Posted 31 October 2011 - 02:51 PM

use \" to make those double quotes that Windows programs seem to love so much.
it will be "HKLM\\Software\\Microsoft\\Windows NT" to the program, and parsed as one parameter.

Before anybody says a thing about system(), note this; he's working with the Windows registry.

This post has been edited by ishkabible: 31 October 2011 - 04:37 PM
Reason for edit:: fixed code tag that showed nothing

Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6106
  • View blog
  • Posts: 23,654
  • Joined: 23-August 08

Re: Deleting a registry key using system()

Posted 31 October 2011 - 06:02 PM

I would venture to say n00bs should not be deleting registry keys, especially in the Windows subsystem, through system.
Was This Post Helpful? 3
  • +
  • -

#6 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,383
  • Joined: 10-May 07

Re: Deleting a registry key using system()

Posted 31 October 2011 - 06:06 PM

This is a horrible way to use the C/C++ language. Why not use the Windows API & remove the registry key the way it was meant to be accomplished?
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1