Показать полную графическую версию : [решено] Возврат на уровень
TERMINAL
30-09-2011, 11:05
Добрый день !
Возможно ли вернуться на предыдущий уровень папок от места стартующено AutoIT.
К примеру, файл AutoIT стартует в папке С:\1\2\3\test1.exe, тоесть путь мне известен при помощи @ScriptDir и из этого (С:\1\2\3\test1.exe) скрипта мне нужно запустить другой скрипт, который находиться уже в папке С:\1\2\test2.exe.
Заранее спс.
madmasles
30-09-2011, 11:42
TERMINAL,
Попробуйте так:#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <File.au3>
$TestPath = @ScriptDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@scriptdir)
$iCount = 0
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, 0, $TestPath)
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$iCount -= 1
$TestPath = _PathFull (http://dundats.mvps.org/help/html/libfunctions/_pathfull.htm)($TestPath & '\..')
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, $iCount, $TestPath)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) StringLen (http://www.autoitscript.com/autoit3/docs/functions/StringLen.htm)($TestPath) < 3 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) ExitLoop (http://www.autoitscript.com/autoit3/docs/keywords.htm#ExitLoop)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
К примеру, файл AutoIT стартует в папке С:\1\2\3\test1.exe, тоесть путь мне известен при помощи @ScriptDir и из этого (С:\1\2\3\test1.exe) скрипта мне нужно запустить другой скрипт, который находиться уже в папке С:\1\2\test2.exe. »
Проще сделать это через рег. выражения:
$sParent_Path = StringRegExpReplace(@ScriptDir, "\\[^\\]*$", "")
$sApp_Path = $sParent_Path & "\test2.exe"
MsgBox(64, "", $sParent_Path & @CRLF & $sApp_Path)
Либо сразу использовать относительный путь:
$sApp_Path = @ScriptDir & "\..\test2.exe"
Run($sApp_Path)
madmasles
01-10-2011, 08:11
Либо сразу использовать относительный путь »Не знал про такой способ, спасибо.
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.