Page 1 of 1 1
Topic Options
#176929 - 2007-06-12 04:03 PM write some registry setting in a text file
Enterprise1808 Offline
Lurker

Registered: 2007-06-12
Posts: 2
Loc: Netherlands
Hello, I am just a beginner but maybe you can help me.

I am looking for the following scripts

Script 1:
write some registry settings in to a text file on the c drive

Script 2:
read some registry from a text file and write this in to the registry

Can someone helpme with this?

With kind regards

Top
#176930 - 2007-06-12 04:06 PM Re: write some registry setting in a text file [Re: Enterprise1808]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Script 1
ReadValue - http://www.kixtart.org/manual/Functions/ReadValue.htm
Open - http://www.kixtart.org/manual/Functions/Open.htm
WriteLine - http://www.kixtart.org/manual/Functions/Writeline.htm
Close - http://www.kixtart.org/manual/Functions/Close.htm

Script 2
Open - http://www.kixtart.org/manual/Functions/Open.htm
ReadLine - http://www.kixtart.org/manual/Functions/Readline.htm
WriteValue - http://www.kixtart.org/manual/Functions/WriteValue.htm
Close - http://www.kixtart.org/manual/Functions/Close.htm

_________________________
Today is the tomorrow you worried about yesterday.

Top
#176946 - 2007-06-13 11:02 AM Re: write some registry setting in a text file [Re: Gargoyle]
Enterprise1808 Offline
Lurker

Registered: 2007-06-12
Posts: 2
Loc: Netherlands
Thanks for the information

This is what i got for script 1

; ===========================================================================================
;
; Script Information
;
; Title:Write Default Printer Registry setting to defaultprinter1.txt file
; Author:
; Description:Write Default Printer Registry setting to defaultprinter1.txt file
;
;
; ===========================================================================================
;Read value from the registry and place this in variable $defaultprinter

$defaultprinter = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\Currentversion\Windows", "Device")

If @ERROR = 0

? "Default printer: $defaultprinter"

EndIf

;Open file and write value $defaultprinter into txt file
If Open(3, "H:\windows\defaultprinter1.txt",5)=0
$x = WriteLine(3, "$defaultprinter")

Else
Beep
? "Failed to open file, error code: ["+ @ERROR + "]"
EndIf

;Close File
If Close(3)
Beep
? "Error Closing file!"
EndIf

ONE Problem, the script adds the information to the text file but it should overwrite the information in the text file. Any thoughts?

Top
#176947 - 2007-06-13 11:10 AM Re: write some registry setting in a text file [Re: Enterprise1808]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
You could add a check in the script to see if the file exist and delete it if it does exist.

Add this just above the line where you open the file.

 Code:
If Exist ("H:\windows\defaultprinter1.txt")
	Del "H:\windows\defaultprinter1.txt"
EndIf


If you want each machine to only overwrite it own section then you could use an ini file and writeprofilestring and readprofilestring or create separate files for each computer.

BTW: please use code tags when posting code.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#176948 - 2007-06-13 11:28 AM Re: write some registry setting in a text file [Re: Enterprise1808]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I assume that you try to read the default printer before deleting all printers and reconnect them at logon, and set that again after it... Correct?

If so you may also use this one : GetDefaultPrinter()

store the result in a variable, do the delete and addprinter stuff, and finally use the variable as SetDefaultPrinter() argument
_________________________



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 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.092 seconds in which 0.065 seconds were spent on a total of 14 queries. Zlib compression enabled.

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