Jump to content

Recommended Posts

Posted

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)
Posted

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.

Posted

There's no case sensitivity for variable names in AutoIt. $mypath = $mYpAtH as far as AutoIt is concerned.

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 Gude
How 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

Posted

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 Gude
How 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

Posted

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
Posted

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 Gude
How 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

Posted (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 HDD

It works! Thanks, after removing attribute "read only" with FileSetAttrib function, script works correct.

Thank you.

Edited by malong

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...