coucou Posted May 20, 2011 Share Posted May 20, 2011 Hi,Anyone can help me converting the following batch file commands into AutoIt commands?Regardsfile .batattrib -R "%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Settings.ini" /S /D COPY /Y "%~dp0Settings.ini" "%userprofile%\AppData\Local\Microsoft\Windows Sidebar\" SET KEY=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce REG ADD %KEY%\001 /V 1 /D "%systemdrive%\Program Files\Windows Sidebar\sidebar.exe" /ffile.au3$path = "userprofile%\AppData\Local\Microsoft\Windows Sidebar" If Not FileSetAttrib($path & "\Settings.ini", "-R", 1) Then FileCopy($path & "\Settings.ini", "%userprofile%\AppData\Local\Microsoft\Windows Sidebar\") EndIf RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "1", "REG_SZ", "%systemdrive%\Program Files\Windows Sidebar\sidebar.exe") Link to comment Share on other sites More sharing options...
sleepydvdr Posted May 20, 2011 Share Posted May 20, 2011 The first line of your code, you forgot to put a '%' before 'userprofile'. It should look like: $path = "%userprofile%\AppData\Local\Microsoft\Windows Sidebar" I have a question about the second line. You are doing an IF statement, which makes me think you are trying to read the attribute and based on the results, you will do one thing or another (you would use FileGetAttrib in that case). If that's not the case, then get rid of the IF statement and just run the FileSetAttrib command. #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
sleepydvdr Posted May 20, 2011 Share Posted May 20, 2011 Also, I just noticed that you are copying the file to the location it already is at. What is the purpose of that? #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
MHz Posted May 21, 2011 Share Posted May 21, 2011 (edited) Hi coucou, Using "%userprofile%" in a string may not expand into a path with FileCopy() in the above code. You may need to use Opt() to set expand environmental variables or use EnvGet() to expand them. This is my untested attempt at conversion $path = EnvGet("userprofile") & "\AppData\Local\Microsoft\Windows Sidebar" ;attrib -R "%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Settings.ini" /S /D FileSetAttrib($path & "\Settings.ini", "-R") ;COPY /Y "%~dp0Settings.ini" "%userprofile%\AppData\Local\Microsoft\Windows Sidebar\" FileCopy(@ScriptDir & "\Settings.ini", EnvGet("userprofile") & "\AppData\Local\Microsoft\Windows Sidebar\") ;SET KEY=HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce $key = "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce" ;REG ADD %KEY%\001 /V 1 /D "%systemdrive%\Program Files\Windows Sidebar\sidebar.exe" /f RegWrite($key & "\001", "1", "REG_EXPAND_SZ", '"%systemdrive%\Program Files\Windows Sidebar\sidebar.exe"') "%%" are removed from the environmental variable when you use EnvGet(). "%~dp0" is where the CMD script exists and @ScriptDir is where the AutoIt script exists, so use @ScriptDir to replace the use of "%~dp0" in the AutoIt script. "REG_EXPAND_SZ" is used though it is perhaps not required to expand "%systemdrive%" in the current usage. Added quotes to the RegWrite() data string as you have some whitespace with in the string. I notice that you do not reverse the read only attribute on the settings file after the file is copied. Something for you to consider. Edited May 21, 2011 by MHz Link to comment Share on other sites More sharing options...
coucou Posted May 22, 2011 Author Share Posted May 22, 2011 (edited) TNX sleepydvdr and my savior MHZ @MHZ that script is a tweak for Windows 7: gadgets customize then sidebar restartThe only test be done during Win 7 installation. I'll give a try later.Regards Edited May 22, 2011 by coucou Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now