Jump to content

Running from desktop shortcut


Recommended Posts

Hello everyone.

I am trying to create an automated install of client software and part of it includes a first run of the application by double clicking on the shortcut on the desktop then entering in a username - password - database field to connect. I thought this would be simple enough with the following:

Run(@ComSpec & ' /c "C:\Documents and Settings\All Users\Desktop\My.lnk"')

WinWait("Window Title","Text")

Sleep(1000)

ControlSend("Window Title","Text","Edit1","username")

Sleep(1000)

ControlSend("Window Title","Text","Edit2","password")

Sleep(1000)

ControlSetText("Window Title","Text","Edit3","")

Sleep(1000)

ControlSend("Window Title","Text","Edit3","database connection")

Sleep(500)

ControlClick("Window Title","Text","Button1") ;this is the OK button

This all seems to work except the program tells me it cannot connect to the database. This only happens by running the Run(@ComSpec & ' /c "C:\Documents and Settings\All Users\Desktop\My.lnk"') line. If I take that line out, run the script so it sits at the first WinWait line then physically double click the shortcut, the script takes over and works the way I need. What is the difference between physically clicking the shortcut or having autoit tell it to run? Any ideas on how to resolve this? Thanks for any help and let me know if more clarification is needed.

Link to comment
Share on other sites

1 WinWait()

Waits for that window to show before continuing

2 try this

ShellExecute("C:\Documents and Settings\All Users\Desktop\My.lnk", "", @WorkingDir)

.........check the "arguments".................................................................^^

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

What Val meant was to chceck the arguments of shellexecute. This code will launch an internet explorer shortcut on my desktop...

ShellExecute("C:\Documents and Settings\Andrew\Desktop\Internet Explorer.lnk")

Try that with your path and see what happens.

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

Yes, I did try that in place of Run(@ComSpec & ' /c "C:\Documents and Settings\All Users\Desktop\My.lnk"'). It did launch my application but still does not login like physically double clicking the shortcut.

Link to comment
Share on other sites

Thats odd... can you be more descriptive about what its doing? Is it possible the machine would have some sort of protection against a script running?

Hmm...

Try ShellExecute with the 'verb' parameter and/or some of the other options. Let us know how it goes.

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

Not sure if this makes a difference but I am trying to run an .exe on a separate server. I have tried to use different run commands, such as, Run("\\Server\Folder\Program.exe"), but trying to tell this program to run, it tells me I am unable to connect to the database, for the life of me I dont know why double clicking this shortcut works but telling it to run from autoit does not allow me to connect. I can connect correctly by going Start-Run-\\Server\Folder\Program.exe

Link to comment
Share on other sites

The only way I could ever get it to work was by having the script open the run box then filling in the text of the server and app.exe then telling it ok. I dont know what that was the only way it would work. But its doing what I need. Thanks for everyones help!!

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