Jump to content
Sign in to follow this  
FMManager

Windows autorun

Recommended Posts

Hello.

I tried to find several days answer in google and different forums but no luck. Maybe experts here can explain me how it works.

It is not a secret that a lot of people use autoit to make reinstallation of software faster by avoiding press "next", "yes" and other buttons during installation procedure. It really work great but what I noticed -  If I put any files which have path to type in autorun (of windows). It will spoil the path in terms of "shift" button.

For example:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("^o")
WinWait ("Open", "Cancel")
ControlSend("Open","","","C:\Program Files (x86)\Test.txt",1)

If i start normally. It ll be correct.  - C:\Program Files (x86)\Test.txt. If I put it in autorun and restart my win 7 (32 or 64). It ll be something like - C;|Program Files 9X86)|Test.txt

Please advice what is the solution.

Thanks in advance

Share this post


Link to post
Share on other sites

What kind of autorun are you talking about :

- autorun when CD-ROM is inserted ?

- autorun in registry ?

- autorun in Start Menu ?

- autorun as a service ?

- autorun in task scheduler ?

Edited by Nine

Share this post


Link to post
Share on other sites

Is any difference between them?

I mean normal autorun throw start menu

C:\Users\PC\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Share this post


Link to post
Share on other sites
8 hours ago, FMManager said:

Is any difference between them?

Yes, they all have their specificity.  I will try to see if i can replicate your problem using Start Menu...

Share this post


Link to post
Share on other sites

Here is the code I used : 

Run("notepad.exe")
WinWaitActive("[Class:Notepad]")
Send("^o")
$hWnd = WinWait ("Ouvrir", "", 10)
Sleep (500)
ControlSend($hWnd,"","","C:\Program Files (x86)\Test.txt",1)

I changed it a bit your code since I am using a french environment.  I had a bit of problem without the sleep (500) but it might be just a coincidence.

So it works fine when I launch it manually and it works fine on auto startup.

I compiled it x86, and copied the .exe into the startup folder.

What version of autoit are you running ?

 

Share this post


Link to post
Share on other sites

Autorun is usually referred to devices (USB, CD/DVD drives...) on insertion. Autostart is for programs that run on Windows boot.

There are three ways you can autostart a program:

  • You can create a shortcut of the program inside of the startup folder. You can get the path for all users startup folder with the @StartupCommonDir macro. Or the one for the current user with @StartupDir.
  • You can create a scheduled task with the schtasks.exe command and the ONSTART / ONLOGON parameters.
  • You can add the program's path -create a new string value- to the registry keys related to Run / RunOnce.

Share this post


Link to post
Share on other sites

@FMManager  I just realized that the wrong characters in the send are shift characters.  Exactly what I had as a problem.  Looks like some other startup apps are interfering with autoit.  You may want to add some sleeps in your code to delay the send...Or you could try using a simple Send (...) command instead.

Share this post


Link to post
Share on other sites

Thanks, Nine. Your idea with code below working great.

I tried before put it in a sleep for 10000 or even more but still it were spoiled path. But by that line it were fixed :thumbsup:

$hWnd = WinWait ("Ouvrir", "", 10)

Topic is closed. Thank to all for participating

Share this post


Link to post
Share on other sites

" Unfortunately it does not work for other PCs. "

Are these other PCs on a domain? If so, are they Windows 10? And if so, do the individual users have admin rights? Where I work, admin rights are restricted to a very few which renders a lot of scripts I wrote in the past unusable. One example of such a script would be to add a local printer - one needs admin rights to do that. In the case of your autostart issues, one needs admin rights to write to @StartupCommonDir, but admin rights are not needed to write to @StartupDir. In addition, admin rights are required to add or change data in the "C:\Program Files", "C:\Program Files (x86)" and "C:\Program Data" folders.


Who lied and told you life would EVER be fair?

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...