Sign in to follow this  
Followers 0
Rawox

ShellExecute

8 posts in this topic

#1 ·  Posted (edited)

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

Share this post


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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ShellExecute ( $TSPath & "ts3server_win64.exe" )

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

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


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

Share this post


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

Share this post


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

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  
Followers 0