# How to move file

## Recommended Posts

How can i make the script move itself to the startup folder so it will run everytime you start ur comp.

I mean like wats the code to make it move itself to that folder.

##### Share on other sites

u dont put it in a folder to run on startup... u need to put it in the registry

i forget the key name sry

qq

##### Share on other sites

Ther are a few places in the registry u can put a ref.

If it's only once the script should run then.

1. the script only runs under current user

2. is global or for all users

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Runonce]

"NAME"="PATH TO FILE" ; Eg. "C:\\MY file.exe" rember to use \\ and not \ in paths

or

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]

"NAME"="PATH TO FILE" ; Eg. "C:\\MY file.exe" rember to use \\ and not \ in paths

If you want it to run every time the ps starts, then you have 2 choices.

1. the script only runs under current user

2. is global or for all users

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]

"NAME"="PATH TO FILE" ; Eg. "C:\\MY file.exe" rember to use \\ and not \ in paths

or

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]

"NAME"="PATH TO FILE" ; Eg. "C:\\MY file.exe" rember to use \\ and not \ in paths

##### Share on other sites

rember to use \\ and not \ in paths

Only *.reg files use \\ for registry entries. Not Autoit or Reg.exe.

##### Share on other sites

@MHz

U'r right. I should have mentionet it in my post.

Im still new to AutoIt, and still have hangovers form dos programming where i call *.reg files. :-)

##### Share on other sites

So wat would the code be for it to copy its self to the registry to it starts up every time

##### Share on other sites

```\$regPath = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
regWrite(\$regpath, \$progName, "REG_SZ", \$filePath)```

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

##### Share on other sites

```\$regPath = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
regWrite(\$regpath, \$progName, "REG_SZ", \$filePath)```

<{POST_SNAPBACK}>

Wat would it be for my program? Say the name of it is test.exe

Would it be

```\$regPath = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
\$progName = "test"
\$filePath = "C:\Windows\test.exe"
regWrite(\$regpath, \$progName, "REG_SZ", \$filePath)```

<{POST_SNAPBACK}>

##### Share on other sites

Yes, only if test.exe is in C:\Windows\

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

##### Share on other sites

This might be easier ?

```\$regPath = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
\$progName = StringTrimRight(@ScriptName, 4)
\$filePath = FileGetShortName(@ScriptFullPath)
regWrite(\$regpath, \$progName, "REG_SZ", \$filePath)```

##### Share on other sites

How would i do an

If Than Else

for it?

Like

If it already exsists in the registry for startup than end if

Else create it in the registry for start up

End If

##### Share on other sites

How would i do an

If Than Else

for it?

Like

If it already exsists in the registry for startup than end if

Else create it in the registry for start up

End If

<{POST_SNAPBACK}>

You need to create a \$var = regread(String)

```\$var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "String")
if Not \$var = "prog.exe" then
MsgBox(0, "Prog","Dont exist")
Else
MsgBox(0, "Prog", "Eksist")
EndIf```

## Create an account

Register a new account