Jump to content

Opening a drive


Recommended Posts

hi,

how can i open drive in which from my exe is running?

for example if my exe is on desktop then it should run C:\ Else any other drive.

i want it for all drives, i tried like this but it works only if the exe is in root of drive.

like in C:\ not in C:\New\1

$Z = @ScriptDir
If $Z= "C:\" Or "D:\"  Then
Run (Explorer.exe & $Z)
EndIf

Please reply as soon as possible.

thanks in advance.

[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"
Link to comment
Share on other sites

ShellExecute(StringLeft(@ScriptDir, 3))

Explanation:

ShellExecute will execute any file. If the passed parameter is a path, it will run explorer and then that path. StringLeft(@ScriptDir, 3) is saying get the first three characters in the path, which would be the root.

Tested and works.

Edited by Alienware
Link to comment
Share on other sites

but what if location of my exe is changed?

can it work if the exe is running from any folder of a drive.

it should open the main dir (root dir) of the drive.

[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"
Link to comment
Share on other sites

but what if location of my exe is changed?

can it work if the exe is running from any folder of a drive.

it should open the main dir (root dir) of the drive.

Did even you try it?

Maybe you should read the bottom of my other post too.

Tested and works.

Edited by Alienware
Link to comment
Share on other sites

Did you see the macro @ScriptDir ?

It points to the Directory in which the Script is located. the first 3 characters represent the DriveLetter with : and \ (e.g. could be A:\ or X:\ or C:\ ... )

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

this worked fine but did not maximized the window.

now this one is working fine.

Run("Explorer.exe" & (StringLeft(@ScriptDir, 3)), "", @SW_MAXIMIZE)

thanks a lot for the help!

[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"
Link to comment
Share on other sites

:)

Explorer.exe has other options too muttley

MsgBox (0, "", "Example 1")
$pid = Run ("Explorer.exe /select," & @ScriptFullPath)
Sleep (5000)
ProcessClose ($pid)
MsgBox (0, "", "Example 2")
$pid = Run ("Explorer.exe /e,/root," & @ScriptDir)
Sleep (5000)
ProcessClose ($pid)
MsgBox (0, "", "Example 3")
$pid = Run ("Explorer.exe /n," & @ScriptDir)
Sleep (5000)
ProcessClose ($pid)
MsgBox (0, "", "Example 4")
$pid = Run ("Explorer.exe /root," & @ScriptDir)
Sleep (5000)
ProcessClose ($pid)
Link to comment
Share on other sites

hey Bert, great to know about it.

thanks for the information.

you have really done a good work.

can you provide some little info about these commands?

thanks again...

Edited by zFrank
[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"
Link to comment
Share on other sites

  • 9 months later...

Hi guys,

I'm new in AutoIT world. It's been a week though and I find it very interesting.

Anyway, I have a trouble.

I've been doing my homework by searching in the forum but I didn't find a clue about

@ScriptDir
@WorkingDir

I read in the Help file but it is too simple but when I tried to understand how it works in the post above and I can't. I'm dumb i guess.

Hope someone will explain to me how it works.

thanks

Link to comment
Share on other sites

You mean how conjunctionally (wrong word :) ) they work with the explorer.exe or what? If for example @ScriptDir is "C:\Scripts" and @ScriptFullPath is "C:\Scripts\New AutoIt v3 Script.au3" then they're just like %Variable% but do not require to be expanded:

MsgBox (0, "", "Example 1")
$pid = Run ("Explorer.exe /select," & @ScriptFullPath)
; $pid = Run ("Explorer.exe /select,C:\Scripts\New AutoIt v3 Script.au3")
Sleep (5000)
ProcessClose ($pid)
MsgBox (0, "", "Example 2")
$pid = Run ("Explorer.exe /e,/root," & @ScriptDir)
; $pid = Run ("Explorer.exe /e,/root,C:\Scripts")
Sleep (5000)
ProcessClose ($pid)
MsgBox (0, "", "Example 3")
$pid = Run ("Explorer.exe /n," & @ScriptDir)
; $pid = Run ("Explorer.exe /n,C:\Scripts")
Sleep (5000)
ProcessClose ($pid)
MsgBox (0, "", "Example 4")
$pid = Run ("Explorer.exe /root," & @ScriptDir)
; $pid = Run ("Explorer.exe /root,C:\Scripts")
Sleep (5000)
ProcessClose ($pid)

Same with @WorkingDir, it's supposed to contain the @ScritpDir if run from the explorer or the current "C:\Path\Path" if run like "C:\Windows\System32>"C:\Scripts\New AutoIt v3 Script.au3" for example. Unlike @ScriptDir, it's possible to change to working directory using FileChangeDir() and then @WorkingDir contain the new working directory. .. and blah blah. :party:

Edited by Authenticity
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...