Previous Thread
Next Thread
Print Thread
Rate This Thread
Hop To
#4507180 - 02/12/20 03:10 PM Load a Target Script on Windows Startup  
Joined: May 2001
Posts: 468
Joao Muas Offline
Member
Joao Muas  Offline
Member

Joined: May 2001
Posts: 468
Portugal
Is it possible?

I mean, we can run Target on Windows startup, but can we get it to automatically load a script?

Inline advert (2nd and 3rd post)

#4507232 - 02/13/20 06:17 AM Re: Load a Target Script on Windows Startup [Re: Joao Muas]  
Joined: Jul 2016
Posts: 61
Drakoz Offline
Junior Member
Drakoz  Offline
Junior Member

Joined: Jul 2016
Posts: 61
Yes. You can run TARGET .tmc scripts directly using TARGETGUI.exe. I mean running it using a CMD prompt such as the following:

Code
TARGETGUI.exe -r Myscript.tmc


or using full path names: (for files in their default locations. %USERNAME% will default to your user name)

Code
"c:\Program Files (x86)\Thrustmaster\TARGET\x64\TARGETGUI.exe" -r c:\Users\%USERNAME%\AppData\Roaming\Thrustmaster\TARGET\Scripts\Myscript.tmc



You can see a list of the command line options for TARGETGUI.exe by typing the following in a CMD prompt:

Code
"c:\Program Files (x86)\Thrustmaster\TARGET\x64\TARGETGUI" -help



Note, quotes above are because of spaces in the path names.


Yes, TARGETGUI.exe is the GUI version of TARGET, but if you use the -r option on a command line, it bypasses the GUI part and immediately compiles and runs the script. The GUI compiler window pops up and runs the script. Console messages are displayed in the compiler for any printf() commands in your script.

The easiest way to use this is create a Windows shortcut to TARGETGUI.exe (copy the icon created for the GUI when you installed TARGET, or create a new shortcut for TARGETGUI.exe). Then right click and select Properties to bring up the shortcut options. Change the options as follows (use the exact text given, including quotes, replacing anything to match your path names or file name of course):

Code
Target:      "C:\Program Files (x86)\Thrustmaster\TARGET\x64\TARGETGUI.exe" -r "MyScript.tmc"
Start In:     C:\Users\Mike\AppData\Roaming\Thrustmaster\TARGET\Scripts


Click OK to close the dialog. Now you have an icon that will compile and run your script when you double click on it.

To use this to run a script at Windows startup, put the shortcut in your Startup Folder. All programs or shortcuts in this folder are run at boot. Here is the path to the StartUp folder.

Code
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp



Unfortunately, you can't run a script and have it exit. I mean, you can exit any script with the Abort(); function (immediately stops the script - see Abort() in hid.tmh for more info), but this won't exit the TARGETGUI.exe program window. Also, if you try to run another script by double clicking on another shortcut icon intended to run a script, it won't work until you manually close the previous script window. To solve this, you could probably use the TARGET system() command to run a windows CMD prompt command to kill the TARGETGUI process. This will stop the script and kill the TARGET GUI compiler. See this site for an explanation on how to use taskkill to do this:
https://www.wikihow.com/Kill-a-Process-in-Command-Prompt

Also, there is some more discussion at the DCS forums about using nircmdc.exe along with the above ideas to hide the TARGETGUI.exe program. See here:
https://forums.eagle.ru/showthread.php?t=144584

NirCMD can be found here. There are a variety of other useful programs at Nirsoft.net which may be useful to run from a TARGET script using system(). For example, NirCmd can change the computer's sound volume.
https://www.nirsoft.net/utils/nircmd.html

#4507242 - 02/13/20 01:48 PM Re: Load a Target Script on Windows Startup [Re: Drakoz]  
Joined: May 2001
Posts: 468
Joao Muas Offline
Member
Joao Muas  Offline
Member

Joined: May 2001
Posts: 468
Portugal
Exactly what I was looking for.
By running a single script with various profiles I don't need the TARGET GUI anymore, so I want to have it to start automatically and keep it hidden and have the desktop clean.
I will probably do the same for my TrackIR (with a delay because somehow TIR doesn't like to start before TARGET), then I'm ready to fly...

Thanks!!


Moderated by  RacerGT 

Quick Search
Recent Articles
Support SimHQ

If you shop on Amazon use this Amazon link to support SimHQ
.
Social


Recent Topics
Dickey Betts was 80
by Rick_Rawlings. 04/19/24 01:11 AM
Exodus
by RedOneAlpha. 04/18/24 05:46 PM
Grumman Wildcat unique landing gear
by Coot. 04/17/24 03:54 PM
Peter Higgs was 94
by Rick_Rawlings. 04/17/24 12:28 AM
Whitey Herzog was 92
by F4UDash4. 04/16/24 04:41 PM
Anyone can tell me what this is?
by NoFlyBoy. 04/16/24 04:10 PM
10 Years ago MV Sewol
by wormfood. 04/15/24 08:25 PM
Pride Of Jenni race win
by NoFlyBoy. 04/15/24 12:22 AM
It's Friday: grown up humor for the weekend.
by NoFlyBoy. 04/12/24 01:41 PM
OJ Simpson Dead at 76
by bones. 04/11/24 03:02 PM
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.

Powered by UBB.threads™ PHP Forum Software 7.6.0