malong Posted July 2, 2012 Share Posted July 2, 2012 Hello, First of all sorry for my English. im newbie in autoit, this is my first script. So, i have a problem when try to running autoit script from CD-rom (Script placed on CD) My script works in next order: 1) copy config files from cd to hard disk, 2) finding driveletter my cd rom 3) change config files (adding path with founded drive letter) 4) and run my programs etc Problem is my config files don't change when i run script from cd. But when i run it from hard disk all works fine. Bellow part of my script Please help me, how i can resolve this problem. Thanks DirCopy(@ScriptDir&"\data\settings\", "C:\data\settings\",1) DirCopy(@ScriptDir&"\data\language", "C:\data\language",1) FileCopy(@ScriptDir&"\data\.VirtualBox\VirtualBox.xml", "C:\data\.VirtualBox\", 9) FileCopy(@ScriptDir&"\data\.VirtualBox\Machines\test\test.vbox", "C:\data\.VirtualBox\Machines\test\", 9) Global $myPath = "C:\data\.VirtualBox\Machines\test\test.vbox" Global $cdDrive = DriveGetDrive("CDROM") for $i=1 to $cdDrive[0] If FileExists($cdDrive[$i]&"\LiesMich.txt") then $driveLetter=$cdDrive[$i] endif Next Global $oldtext = "test.vdi" Global $newtext = $driveLetter&"data\.VirtualBox\Machines\test\test.vdi" Global $oldCDPath = "D:/Distrib/ISO/ess-linux-0.1-rc8.iso" Global $newCDPath = $driveLetter&"data\.VirtualBox\Machines\test\ess-linux-0.1-rc8.iso" $myFile=FileOpen($MyPath, 0) $myText=FileRead($myFile) FileClose($myFile) $myText=StringReplace($myText, $oldtext, $newtext) $myText=StringReplace($myText, $oldCDPath, $newCDPath) $myFile=FileOpen($MyPath, 2) $myText=FileWrite($myFile,$myText) FileClose($myFile) Link to comment Share on other sites More sharing options...
AZJIO Posted July 2, 2012 Share Posted July 2, 2012 MsgBox(0, '?', $myText) Do check the variables to understand. Use the virtual CD-ROM drive. My other projects or all Link to comment Share on other sites More sharing options...
Tripredacus Posted July 2, 2012 Share Posted July 2, 2012 Why do this part? Global $cdDrive = DriveGetDrive("CDROM") If your script is on the CD, and is in the root, then @ScriptDir will give you the CD drive's letter. Twitter | MSFN | VGCollect Link to comment Share on other sites More sharing options...
malong Posted July 3, 2012 Author Share Posted July 3, 2012 i used @scriptDir in first editions, but script didn't work, then i tryed use driveGetDrive functions, but result was the same. I also tryed to run script from root directory and in subdirectories on CD. Link to comment Share on other sites More sharing options...
Tripredacus Posted July 3, 2012 Share Posted July 3, 2012 Global $myPath = "C:data.VirtualBoxMachinestesttest.vbox" ; snip $myFile=FileOpen($MyPath, 0) $myPath <> $MyPath Does it matter that one is lowercase and the other is capital? Twitter | MSFN | VGCollect Link to comment Share on other sites More sharing options...
BrewManNH Posted July 3, 2012 Share Posted July 3, 2012 There's no case sensitivity for variable names in AutoIt. $mypath = $mYpAtH as far as AutoIt is concerned. Tripredacus 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
BrewManNH Posted July 3, 2012 Share Posted July 3, 2012 These lines are incorrect: Global $newtext = $driveLetter & "data\.VirtualBox\Machines\test\test.vdi" Global $newCDPath = $driveLetter & "data\.VirtualBox\Machines\test\ess-linux-0.1-rc8.iso" You need the backslash before the word data. Global $newtext = $driveLetter & "\data\.VirtualBox\Machines\test\test.vdi" Global $newCDPath = $driveLetter & "\data\.VirtualBox\Machines\test\ess-linux-0.1-rc8.iso" From the Help file for DriveGetDrive Success: Returns an array of strings (drive letter followed by colon) of drives found. The zeroth array element contains the number of drives. Because it only returns the drive letter and a colon (D:), you need to add the backslash to the path statements. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
malong Posted July 4, 2012 Author Share Posted July 4, 2012 You need the backslash before the word data.Added backslash as you advised me, but result was same with/without backslash script wokred properly if i run it from hard disk drive or usb flash drive (CD path added to $myPath), but if i run it from cd, files just copied and didn't changed Link to comment Share on other sites More sharing options...
BrewManNH Posted July 4, 2012 Share Posted July 4, 2012 Check the file copied to make sure it isn't being copied with the Read Only setting set, which sometimes happens when copying from a CD to a HDD If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
malong Posted July 5, 2012 Author Share Posted July 5, 2012 (edited) Check the file copied to make sure it isn't being copied with the Read Only setting set, which sometimes happens when copying from a CD to a HDDIt works! Thanks, after removing attribute "read only" with FileSetAttrib function, script works correct.Thank you. Edited July 5, 2012 by malong 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