Jump to content

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


Markir
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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]

Link to comment
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]

Link to comment
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:

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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!

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...