Jump to content

Getting working directory


 Share

Recommended Posts

I'm creating an autoinstall CD-rom for some apps on new workstations the AU script reads an .ini for program locations to step through the installs.

EXAMPLE:

[PyYAML]

PyYAML=g:\apps\OpenRTM\PyYAML-3.05.win32-py2.4.exe

[OpenRTM]

OpenRTM=g:\apps\OpenRTM\OpenRTM-aist-0.4.2_vc8.msi

How can I get my script to run from the root of the DVD without having to modify the .ini program locations.

EXAMPLE:

[PyYAML]

PyYAML=OpenRTM\PyYAML-3.05.win32-py2.4.exe

[OpenRTM]

OpenRTM=OpenRTM\OpenRTM-aist-0.4.2_vc8.msi

Link to comment
Share on other sites

You can just put your script at the root of the disk and use @WorkingDir to get the path. Or you can just use FileChangeDir and use however many '..\' it takes to get to the root of the disk from wherever you stuck your script. If you want to set the working directory for whatever program or other script your script runs, just provide the working directory parameter for Run or RunWait.

Link to comment
Share on other sites

The macro @ScriptDir points to where the script was run from. If run from the root of the CD it would return "D:\" for example.

Note that @ScriptDir only contains the trailing backslash for root. If run from "\apps" on the CD for example it would return "D:\apps" without a trailing backslash.

So, if you ran from the root of a CD at D:, then you might get:

; Get script dir without trailing backslash (special case for root)
$sRunDir = @ScriptDir
If StringRight($sRunDir, 1) = "\" Then $sRunDir = StringTrimRight($sRunDir, 1) ; Remove '\' for root

$sIniFile = $sRunDir & "\Your_Ini_File.ini"
$sExePath = $sRunDir & IniRead($sIniFile, "PyYAML", "PyYAML")

; ===>>  $sExePath = D:\OpenRTM\PyYAML-3.05.win32-py2.4.exe

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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