Jump to content

Hel with create simple AutoIt replacement for .bat file.


Recommended Posts

Hi.

Some time ago i create this bat file:

@echo off
FOR /F "tokens=2* delims=   " %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRar.exe" /v "Path"') DO SET WinRarInstallDir=%%B
xcopy *.* "%WinRarInstallDir%" /y /q /e
echo "%WinRarInstallDir%"
exit

but due some unknown reason, it don't work on VISTA/7. I try to solve this but I'm unable to do it.

It is possible to write AutoIt replacement for such simple .bat file ?

What this .bat file do:

1. Read registry and check what is in "Path" in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppPaths\WinRar.exe"

2. Set WinRarInstallDir as what is in "Path"

3. Copy all files with current dir to %WinRarInstallDir%

I don't have experience with AutoIt. Can someone help me with this ?

Edited by ALIENQuake
Link to comment
Share on other sites

$s_path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppPaths\WinRar.exe", "path?")
FileCopy(@SCriptDir & "\*", $s_path)

For RegRead you'll need the registry path and the "key" you want to read. FileCopy supports Wildcards.

Edit:

Oh, welcome to the AutoIT forum!

And:

A good place to start with AutoIT is the very useful helpfile. :unsure:

Edited by Hannes123
Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Ok, i was able to compile it but it don't work :unsure: Files in current dir (with i execute compiled script) aren't copied to WinRar dir and i get this strange file with chines letters

Posted Image

And how i can get rid of this:

Posted Image

in VISTA/7 ?

Edited by ALIENQuake
Link to comment
Share on other sites

1. You should test / check whether your script really can read the registry value, just do a MsgBox(0,"regread:", $value_or_whatever)

2. Check the return code of FileCopy() e.g. $returncode = FileCopy($x, $y), read the help file for a list of returnvalues

Maybe you can find a solution then.

I can't help you with the the Vista/7 error message, because I can't read it. :unsure:

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Try putting #RequireAdmin at the top of the script.

@Hannes123

You don't need to be able to read that dialog. It's easily recognized as being the UAC prompt window.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

#RequireAdmin
$var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
MsgBox(4096, "Program files are in:", $var)
$var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppPaths\WinRar.exe", "Path")
MsgBox(4096, "WinRar.exe is in:", $var)
FileCopy(@SCriptDir & "\*", $var)

Fist command works, we can see C:\Program files in message box. Second command shows empty window !

Why ? It's is the same script, only with different parameters :unsure:

Edited by ALIENQuake
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...