Joeson

Help me to convert this batch file to au3, Thanks

11 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

Well, thanks very much. But I think I can't use the variables like "@WindowsDir\Cursors", it won't work.

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

Share this post


Link to post
Share on other sites

Well, thanks very much. But I think I can't use the variables like "@WindowsDir\Cursors", it won't work.

You can. But you need to do it like @WindowsDir & "\Cursors"


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

Sorry to ask about to a so old thread, but I find the above code very useful, but I cannot figure out how to use the unit info into a new command. What I want to do is take the found unit to pass to this utility (Mountusb D: Y:):

mountusb "found Unit" Y:

 

 

Share this post


Link to post
Share on other sites

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


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

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#10 ·  Posted

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?

Share this post


Link to post
Share on other sites

#11 ·  Posted

SOLVED!!!!

In winpeshl.ini I I run startnet.cmd and it calls autoitprogram.exe (now with sleep (3000) after the code) and in the next line of Winpeshl.ini I wrote the route to the new letter drive and it works.

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