Jump to content

ShellExecute


Recommended Posts

Hi,

I wanted to create a really simple script for an upcoming LAN-party.

I already set up a LAN TeamSpeak 3 Server and when I run 'ts3server_win64.exe' it's up and running. (opens cmd and works)

But whenever I try

ShellExecute ( $TSPath & "ts3server_win64.exe" )
The cmd pops up for a split second and disappears, which also causes the fact the server doesn't run -.-'

Why is this?

Thanks in advance, Rawox

Note: ts3server_win64.exe needs permission from an adminstrator, but it gets it.

Edited by Rawox
Link to comment
Share on other sites

You can add #RequireAdmin to your script or use RunAs. You will want to use /K when instead of /C when using RunAs.

I'm not sure if @SW_MAXIMIZE = Maximized window will work with ShellExecute as when the program terminates, it will disappear. The /K with RunAs will keep the cmd window open after the program has terminated.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Either $TSPath has to end with a backslash, or the string (ts3server_win64.exe) has to begin with one.

That already is :idea:

Global          $TSPath = "C:\Program Files (x86)\TeamSpeak 3 Server\"

RunAs will also not work because this does the same... I don't have to think about admin rights because I set the properties of the executable to always run as administrator.

And this also doesn't work:

ShellExecute ( $TSPath & "ts3server_win64.exe", "", "", "", @SW_MAXIMIZE )

It just pops up and goes away immediatly

Edited by Rawox
Link to comment
Share on other sites

That already is :idea:

Global          $TSPath = "C:\Program Files (x86)\TeamSpeak 3 Server\"

RunAs will also not work because this does the same... I don't have to think about admin rights because I set the properties of the executable to always run as administrator.

And this also doesn't work:

ShellExecute ( $TSPath & "ts3server_win64.exe", "", "", "", @SW_MAXIMIZE )

It just pops up and goes away immediatly

Try something like this

Global          $TSPath = '"C:\Program Files (x86)\TeamSpeak 3 Server\"'

Run (@ComSpec & " /K " & "ts3server_win64.exe", $TSPath)

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Try something like this

Global          $TSPath = '"C:\Program Files (x86)\TeamSpeak 3 Server\"'

Run (@ComSpec & " /K " & "ts3server_win64.exe", $TSPath)

Thanks man! Never got that @ComSpec, seems it's quite useful.

It only displays another cmd prompt but I'll just hide that :idea:

Link to comment
Share on other sites

Thanks man! Never got that @ComSpec, seems it's quite useful.

It only displays another cmd prompt but I'll just hide that :mellow:

If you don't want the cmd window to persist put in /C instead of /K. Go to a cmd window and type "cmd /?" to find out more.

I suspect adding the extra quotes fixed the root cause of your issues.

@ComSpec is defined in the help file.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

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