Page 1 of 1 1
Topic Options
#198360 - 2010-04-08 01:52 AM Cant get ReadValue to work
Redback Offline
Getting the hang of it

Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
I'm trying to read a registry value, but ReadValue wont work for no reason that I can determine.

Heres my code
 Code:
$DPrinter = ReadValue("HKEY_LOCAL_MACHINE\Software\BrewsterWalsh" , "Printer")

If @ERROR=0
	? "Default Printer Selection is $DPrinter"
	If SetDefaultPrinter ("$DPrinter") = 0
		? "Default Printer Sucessfully Set To $DPrinter"
	Else
		? "Failed to Set Default Printer to $DPrinter" ? @error "," @serror
	EndIf
Else
	? "Failed to read default printer from registry" ? @error "," @serror
EndIf


Permissions on the key are fine, the error spat out by @serror is 'The system cannot find the file specified.'

What stupid and obvious-to-everyone-but-me thing have I done here?

Top
#198361 - 2010-04-08 02:47 AM Re: Cant get ReadValue to work [Re: Redback]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Probably x64 OS. See SetOption("WOW64AlternateRegView", "ON") in the manual
_________________________
(... better days ahead)

Top
#198362 - 2010-04-08 02:48 AM Re: Cant get ReadValue to work [Re: Redback]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
If you are running on a 64-bit system, review the release notes regarding 64-bit file and registry redirection.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#198363 - 2010-04-08 04:05 AM Re: Cant get ReadValue to work [Re: Glenn Barnas]
Redback Offline
Getting the hang of it

Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
Does it on XP as well as 7 32 and 64
Top
#198364 - 2010-04-08 06:01 AM Re: Cant get ReadValue to work [Re: Redback]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
What results do you get with this?

 Code:
? readvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Shell")
? @serror
? ReadValue("HKEY_LOCAL_MACHINE\Software\BrewsterWalsh" , "Printer")
? @serror
_________________________
(... better days ahead)

Top
#198366 - 2010-04-08 07:31 AM Re: Cant get ReadValue to work [Re: Allen]
Redback Offline
Getting the hang of it

Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
 Code:
explorer.exe
The operation completed successfully.

The system cannot find the file specified.


/boggle


Edited by Redback (2010-04-08 07:32 AM)

Top
#198367 - 2010-04-08 09:01 AM Re: Cant get ReadValue to work [Re: Redback]
Redback Offline
Getting the hang of it

Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
Delete the key, recreated it exactly the same, now it works

*shrug*

Top
#198368 - 2010-04-08 09:46 AM Re: Cant get ReadValue to work [Re: Redback]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Looks like Permission problem to me.
Top
#198371 - 2010-04-08 01:19 PM Re: Cant get ReadValue to work [Re: Redback]
Redback Offline
Getting the hang of it

Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
 Originally Posted By: Redback
Permissions on the key are fine

Top
#198374 - 2010-04-08 04:46 PM Re: Cant get ReadValue to work [Re: Redback]
BillBarnard Offline
Starting to like KiXtart

Registered: 2007-03-14
Posts: 141
Loc: Leighton Buzzard, Bedfordshire...
What do you get from the following code?

 Code:
$index=0
$key = "HKLM\Software\BrewsterWalsh"
$valname = Enumvalue($key, $index)
While @error=0
   $valname ?
   $index = $index + 1
   $valname = Enumvalue($key, $index)
Loop


Regards,
_________________________
Bill

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1013 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.059 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org