Mekrel Posted August 28, 2005 Share Posted August 28, 2005 Hi allI have made a simple but nice AutoIT script which searches for my fixed drives and uses the drive letters it returns with Diskeeper via command line to defrag all my hard drives.The script is compiled and I would like a control panel link to run this script. Which I know how to do.Im trying to make the placement of the compiled script into system32, and the adding of the control panel unattended using a reg file to add the link to control panel.Doing this needs a free generated GUID which I can get from MS's guid generator. Being as its unattended, I need a new guid each time in case others change during different reformats.So using Autoit im making guid.exe generate one and paste to the clipboard and then autoit to write the reg file.I have most of this done, however im getting line breaks where I do not want them Here is my script:; Run the GUID APPRun(@ScriptDir & "\GUIDGEN.EXE"); Wait for the APP to launch and ready to send Commands toWinWait("Create GUID", 'Choose the desired format below, then select "Copy" to copy the results to the clipboard (the results can then be pasted into your source code).'); Select Registry GUID generation by check boxControlCommand("Create GUID", 'Choose the desired format below, then select "Copy" to copy the results to the clipboard (the results can then be pasted into your source code).', "Button5", "Check", ""); Create a new GUIDControlClick("Create GUID", 'Choose the desired format below, then select "Copy" to copy the results to the clipboard (the results can then be pasted into your source code).', "Button8", "left", "1"); Copy the new GUID to clipboardControlClick("Create GUID", 'Choose the desired format below, then select "Copy" to copy the results to the clipboard (the results can then be pasted into your source code).', "Button7", "left", "1"); Exit the programControlClick("Create GUID", 'Choose the desired format below, then select "Copy" to copy the results to the clipboard (the results can then be pasted into your source code).', "Button9", "left", "1")$file = FileOpen(@ScriptDir & "\CP.reg", 1); Check if file opened for writing OKIf $file = -1 Then MsgBox(0, "Error", "Unable to open file.") ExitEndIf$bak = ClipGet()FileWrite($file, "Windows Registry Editor Version 5.00" & @CRLF)FileWrite($file, "" & @CRLF)FileWrite($file, "[HKEY_CLASSES_ROOT\CLSID\" & $bak & "]" & @CRLF)FileWrite($file, '@="nFrag"' & @CRLF)FileWrite($file, '"InfoTip"="Runs a System Wide defragmentation"' & @CRLF)FileWrite($file, "[HKEY_CLASSES_ROOT\CLSID\" & $bak & "\DefaultIcon]" & @CRLF)FileWrite($file, '@="%SystemRoot%\\\\System32\\\\nFrag.exe,0"' & @CRLF)FileWrite($file, "[HKEY_CLASSES_ROOT\CLSID\" & $bak & "\Shell\Open]" & @CRLF)FileWrite($file, "[HKEY_CLASSES_ROOT\CLSID\" & $bak & "\Shell\Open\command]" & @CRLF)FileWrite($file, '@="nFrag.exe"' & @CRLF)FileWrite($file, "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\NameSpace\" & $bak & "]" & @CRLF)FileWrite($file, '@="nFrag Defragmenter"' & @CRLF)FileClose($file)and it produces:Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\CLSID\{5816954A-C354-4644-82D5-3E673DAAB415}]@="nFrag""InfoTip"="Runs a System Wide defragmentation"[HKEY_CLASSES_ROOT\CLSID\{5816954A-C354-4644-82D5-3E673DAAB415}\DefaultIcon]@="%SystemRoot%\\\\System32\\\\nFrag.exe,0"[HKEY_CLASSES_ROOT\CLSID\{5816954A-C354-4644-82D5-3E673DAAB415}\Shell\Open][HKEY_CLASSES_ROOT\CLSID\{5816954A-C354-4644-82D5-3E673DAAB415}\Shell\Open\command]@="nFrag.exe"[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\NameSpace\{5816954A-C354-4644-82D5-3E673DAAB415}]@="nFrag Defragmenter"Notice where the guid is placed {xxxxxxxxx..etc} there is a unwanted line break.I cant seem to see what is causing this? any assistance would be greatly appreciated (nologic, your never on msn when I need you ) Link to comment Share on other sites More sharing options...
Mekrel Posted August 28, 2005 Author Share Posted August 28, 2005 Nevermind, sorted it.I tried triming the string from the right by 1 charachter, but it in fact needs to be trimmed by 2 Link to comment Share on other sites More sharing options...
dman Posted August 28, 2005 Share Posted August 28, 2005 (edited) Not sure what's causing it either, but here's a workaround... Trim the crlf from the string returned by clipget()$bak = ClipGet()$bak = stringleft($bak,stringlen($bak)-2)EDIT- Ya beat me to it. Glad you sorted it out. Yeah, needs both cr and lf trimmed. Edited August 28, 2005 by dman Link to comment Share on other sites More sharing options...
Mekrel Posted August 28, 2005 Author Share Posted August 28, 2005 Thanks anyway mate but your code is abit more neat. Only just started to dab into AutoIT and I need to refine alot of my code sometimes as it can be neater / more efficient.Just like when I learnt CSS and XHTML 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