Sign in to follow this  
Followers 0
blinkdt

Problem Running Command Line Utility

8 posts in this topic

I am encountering parsing issues when trying to include a variable in a command line. I am using a command line tool called RemoveDrive.exe to eject a removable drive from the machine. It would be great if the removable drive could be identified using a variable at the beginning of my longish script, and this tact works well throughout the script excepting the command line.

This works...

RunWait( @ScriptDir & "\TOOLS\RemoveDrive F:")

...as part of the eject function...

Dim $RemovableDrive1 = "F:";<=== set location of removable drive 

_eject()

Func _eject()
    DriveGetLabel($RemovableDrive1 & "\")
    If @error Then;check whether backup device is attached and powered on
        MsgBox(16, "Backup Operation", "The removable drive is not connected to the system!")
    Else;proceed with eject operation if backup device is attached and powered on
        RunWait( @ScriptDir & "\TOOLS\RemoveDrive F:", "", @SW_HIDE);<=======
        While 1
            DriveGetLabel($RemovableDrive1 & "\")
            If @error Then;check whether backup device is attached and powered on
                MsgBox(64, "Backup Operation", "You may now power off and replace the removable drive!")
            EndIf
            ExitLoop
        Sleep(1000)
        Wend
    EndIf
EndFunc

...but it would work better as something like this:

RunWait( @ScriptDir & '"'\TOOLS\RemoveDrive & $RemovableDrive1'"')

I have been searching for examples for a few days now with no success, and at this point I am just guessing at a solution that might include @ComSpec or some elaborate combination of quote marks with predictable, frustrating result. I need to get this pig working by Monday in the AM. Any help would be greatly appreciated.


"No peace for the wicked, no rest for the good."

Share this post


Link to post
Share on other sites



Sweet mother of god... it was just that easy. No, I clearly am not using SciTE right :">

Thank you, JdeB.


"No peace for the wicked, no rest for the good."

Share this post


Link to post
Share on other sites

Sweet mother of god... it was just that easy. No, I clearly am not using SciTE right :">

Reason for mentioning SciTE is that the Colors of the Syntax highlighting would have shown you that you had an error in your single and double qoutes .....

:lmao:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yep, I just installed SciTE about a week ago (but have been fumbling around with AutoIt for years now) and have been using it as a simple text editor. Clearly, it's a heck of a lot more than that.

On that subject, is there a simple way to select a block of text and decrease the indent, a la NotePad2? Easy enough to increase the indent with a TAB stroke, but I can't find anything on the menu that does the job. Did I miss it, as well? :lmao:

Also, where the heck is the "donate" button? EDIT: yeah, lower right corner.

EDIT/EDIT: and thanks for those tips in the post below, real time savers and much appreciated.

Edited by blinkdt

"No peace for the wicked, no rest for the good."

Share this post


Link to post
Share on other sites

Yep, I just installed SciTE about a week ago (but have been fumbling around with AutoIt for years now) and have been using it as a simple text editor. Clearly, it's a heck of a lot more than that.

On that subject, is there a simple way to select a block of text and decrease the indent, a la NotePad2? Easy enough to increase the indent with a TAB stroke, but I can't find anything on the menu that does the job. Did I miss it, as well? :lmao:

Decrease the indent of a block is done with Shift+Tab, but when you want to Tidy your code its easier to run Tidy.... Ctrl+T .... It does all the Proper casing/Indenting for you at the push of 2 buttons.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

if i am reading your intentions correctly....

RunWait( @ScriptDir & "\TOOLS\RemoveDrive F:", "", @SW_HIDE);<=======
        While 1
            DriveGetLabel($RemovableDrive1 & "\")
            If @error Then;check whether backup device is attached and powered on
                MsgBox(64, "Backup Operation", "You may now power off and replace the removable drive!")
            EndIf
            ExitLoop
        Sleep(1000)
        Wend

you would want to chage this.....

RunWait( @ScriptDir & "\TOOLS\RemoveDrive F:", "", @SW_HIDE);<=======

to this

Run( @ScriptDir & "\TOOLS\RemoveDrive F:", "", @SW_HIDE);<=======

to get into the While loop

( not sure, just a note )

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I haven't looked into it in detail, but I suspect the command line utility RemoveDrive works in conjunction with Windows' "Safely Remove Hardware" feature. However, there is a pregnant pause between the time that RemoveDrive reports success and the device is actually removed, per Windows. Any way you slice it, the script does enter the loop using either the 'Run' or 'RunWait' functions, but a straightforward 'Run' makes more sense. Thanks for that, Valuater.

Edit: Actually, after testing (must remember: test...then post :lmao: ), just the opposite is true. The script executes successfully using Run but does not enter the loop to produce the Message Box. RemoveDrive is a nifty utility and I applaud the author, but the readme file is basic and I do not understand its inner workings. It takes several seconds to execute. When used with this script, it's as though 'Run' and 'Runwait' functionality is reversed.

Edit/Edit: I abandoned RemoveDrive after spotty results and went with UNMOUNT to eject the drive:

Func Eject();eject the removable drive
    DriveGetLabel($TargetDrive1 & '\')
    If @error Then;check whether removable drive is attached and powered on
        MsgBox(16, 'Backup Operation', 'The removable drive is not connected to the system!', 5)
    Else;unmount the removable drive
        TraySetState (4);flash the tray icon
        RunWait(@ScriptDir & '\TOOLS\UNMOUNT -bal ' & $TargetDrive1, '', @SW_HIDE)
        While 1;confirm that drive has been unmounted
            DriveGetLabel($TargetDrive1 & '\')
            If @error Then;check whether removable drive is attached and powered on
                MsgBox(64, 'Backup Operation', 'You may now power off and replace the removable drive!', 5)
            EndIf
            ExitLoop
        Wend
        TraySetState (8);stop tray icon flashing
    EndIf
EndFunc
Edited by blinkdt

"No peace for the wicked, no rest for the good."

Share this post


Link to post
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
Sign in to follow this  
Followers 0