Jump to content

Help me to convert this batch file to au3, Thanks


Recommended Posts

And of course, it's not perfect (some autorun.inf is normal in some cd). BTW, can any body show me how to convert Windows variables (for example, %windir%), then use them in au3? Just for cleaning junk files under %temp% and other positions.

for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
if exist %%a:\nul del/q/f/a:h %%a:\autorun.* >nul 2>nul
if not exist %%a:\autorun.* echo "%%a doesn't exist any Autorun virus"
)
Edited by Joeson
Link to comment
Share on other sites

And of course, it's not perfect (some autorun.inf is normal in some cd). BTW, can any body show me how to convert Windows variables (for example, %windir%), then use them in au3? Just for cleaning junk files under %temp% and other positions.

for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
 if exist %%a:\nul del/q/f/a:h %%a:\autorun.* >nul 2>nul
 if not exist %%a:\autorun.* echo "%%a doesn't exist any Autorun virus"
 )
$all_drives = DriveGetDrive("All")
If NOT @error Then
    For $a = 1 To $all_drives[0]
        If FileExists($all_drives[$a] & "\autorun.*") Then
            ; This means that the file autorun exists... now you decide here what to do with it
            MsgBox(0,"Autorun file exists",$all_drives[$a])
        EndIf
    Next
EndIf

Work from there :D

As for variables @WindowsDir, @TempDir check helpfile..

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

  • 8 years later...
  • Developers

It indeed would have been better to start a new thread with the code you have and what you like to accomplish. ;)

So what do you mean with "the found unit"  as the above talks about checking for autorun files? 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

What I want is to run mountusb.exe and change the 'D' unit found in the code for the 'Y' letter.

 

$all_drives = DriveGetDrive("All")
If NOT @error Then
    For $a = 1 To $all_drives[0]
        If FileExists($all_drives[$a] & "\autorun.*") Then
            ; This means that the file autorun exists... now you decide here what to do with it
            Run('"mountusb" "$all_drives[$a] Y:"', "")
        EndIf
    Next
EndIf

In the batch code above you can set %%a as variable. I want to do the same with the 'D' unit found with Autoit code.

Edited by falconchips
Link to comment
Share on other sites

  • Moderators

You have an issue with quotes placement, your $all_drives[$a] should be outside your quotes. Try something like this:

Run('"mountusb" "' & $all_drives[$a] & 'Y:"', "")

Edit: I see I kept your double-double quotes. Jos' version is probably closer to what you need. :)

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Yeah!!! Thankyou all!!! It works as expected. The goal is to change the usb drive letter on Winpe boot (startnet.cmd) because I cannot find a way to set permanent environment variables in Winpe. It changes that letter as expected, but I cannot run the program so far:
 

STARTNET.CMD

call chngletter.exe

w:\folder\executable.exe

Winpe claims 'there is not such folder or executable' (although the letter drive has been already changed). Maybe a 'sleep' function after all autoit code?

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...