Sign in to follow this  
Followers 0
Markir

If...then... --> Fileexist

12 posts in this topic

Hello everybody,

I have a problem with the following code:

Func Export()
If GUICtrlRead($checkCN_MRS) = $GUI_CHECKED Then
    If FileExists("c:\Marc.reg") Then 
        FileMove("c:\Marc.reg", "c:\Marc.bak")
        Else
        RUN('regedit /e c:\Marc.reg "HKEY_LOCAL_MACHINE\SOFTWARE\PrintKey\PrintKey2000\5.0.3"')
MsgBox(0,'Export','Daten Exportiert')
Endif
    Endif


EndFunc

I want to realise the following project:

checkbox enabled --> save registrykey

file marc.reg exist --> rename marc.reg in marc.bak

and save the registrykey in

marc.reg

Can somebody help me?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Func Export()
If GUICtrlGetState($checkCN_MRS) = $GUI_CHECKED Then
    If FileExists("c:\Marc.reg") Then 
        FileMove("c:\Marc.reg", "c:\Marc.bak")
        Else
        RUN('regedit /e c:\Marc.reg "HKEY_LOCAL_MACHINE\SOFTWARE\PrintKey\PrintKey2000\5.0.3"')
MsgBox(0,'Export','Daten Exportiert')
Endif
    Endif


EndFunc

that should do it

edit: instead of running regedit why not use the reg functions that are already in autoit?

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

You've been right, but then I have both files ( marc.reg, marc.bak ) then it should be the following

rename marc.reg marc.bak

then regexport into the file marc.reg

and that doens't go

Share this post


Link to post
Share on other sites

oh, i understand what your doing. i guess in this case it is better not to use the built-in functions.


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

Func Export()
If GUICtrlRead($checkCN_MRS) = $GUI_CHECKED Then
    If FileExists("c:\Marc.reg") Then 
        FileMove("c:\Marc.reg", "c:\Marc.bak")
        RUN(@ComSpec & ' /c reg export "HKEY_LOCAL_MACHINE\SOFTWARE\PrintKey\PrintKey2000\5.0.3" "c:\Marc.reg"')
        MsgBox(0,'Export','Daten Exportiert')
    Endif
Endif
EndFunc

Maybe something like this? Use reg.exe instead.

:lmao:

Share this post


Link to post
Share on other sites

I think that was the result, but i want to use the regedit function

Share this post


Link to post
Share on other sites

Has somebody another idea to solve the problem without an external program?

Share this post


Link to post
Share on other sites

Can somebody help me with this problem?

Share this post


Link to post
Share on other sites

Hello everybody,

I have a problem with the following code:

Func Export()
If GUICtrlRead($checkCN_MRS) = $GUI_CHECKED Then
    If FileExists("c:\Marc.reg") Then 
        FileMove("c:\Marc.reg", "c:\Marc.bak")
        Else
        RUN('regedit /e c:\Marc.reg "HKEY_LOCAL_MACHINE\SOFTWARE\PrintKey\PrintKey2000\5.0.3"')
MsgBox(0,'Export','Daten Exportiert')
Endif
    Endif
EndFunc

I want to realise the following project:

checkbox enabled --> save registrykey

file marc.reg exist --> rename marc.reg in marc.bak

                                and save the registrykey in 

                                marc.reg

Can somebody help me?

<{POST_SNAPBACK}>

Maybe you are looking for this??? (its not really clear what you are looking for):

Func Export()
    If GUICtrlRead($checkCN_MRS) = $GUI_CHECKED Then
        If FileExists("c:\Marc.reg") Then
            FileMove("c:\Marc.reg", "c:\Marc.bak")
        EndIf
        Run('regedit /e c:\Marc.reg "HKEY_LOCAL_MACHINE\SOFTWARE\PrintKey\PrintKey2000\5.0.3"')
    EndIf
EndFunc  ;==>Export

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I have used the following code:

If GUICtrlRead($checkCN_MRS) = $GUI_CHECKED Then
        If FileExists("c:\Marc.reg") Then
            FileMove("c:\Marc.reg", "c:\Marc.bak")
        EndIf
        Run('regedit /e c:\Marc.reg "HKEY_LOCAL_MACHINE\SOFTWARE\PrintKey\PrintKey2000\5.0.3"')
EndIf

So I want to get the following function:

1.) Somebody has the checkbox enabled, the registry key will be exporting.

In that moment the program should look, if the file marc.reg exist, then

rename marc.reg in marc.bak.

2.) When I use the code at a third time, it shoulb be do this:

Rename marc.reg --> marc.bak, and then export the regkey.

Now the following function is:

marc.reg will be the newest file, that is okay, but then i used the program at a third time, the marc.bak already has the value of the first export.

I hope that would help yaou to help me.

Thank you!

Share this post


Link to post
Share on other sites

marc.reg will be the newest file, that is okay, but then i used the program at a third time, the marc.bak already has the value of the first export.

<{POST_SNAPBACK}>

ok so filemove doesn't replace the old file...

try it with : FileMove("c:\Marc.reg", "c:\Marc.bak",1)

FileMove ( "source", "dest" [, flag] )

Parameters

source The source path and filename of the file to move. (* wildcards are supported)

dest The destination path and filename of the moved file. (* wildcards are supported)

flag [optional] this flag determines whether to overwrite files if they already exist:

0 = (default) do not overwrite existing files

1 = overwrite existing files


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Okay thanks you, have a nice evening

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0