Jump to content

ark

Can't Set Affinity Mask for Active Sky with Batch File

Recommended Posts

Posted (edited)

I use a batch file to start 6 addon programs and P3Dv4.4 in a 4 core non-HT Win10 system. For each of the addons I set an affinity mask (Hex E) to keep the addon from using core 0 which is heavily used by P3D. This works fine for all the addons except Active Sky. Active Sky starts up OK, but when I use the Task Manager to check the Active Sky affinity mask it always shows all 4 cores are being assigned. I have tried everything I can think of, including running a separate batch file just for Acitve Sky, but nothing works. Everything is run as Administrator. I would appreciate any ideas on what might be preventing setting the Active Sky affinity mask.

Thanks,

Al

The batch file is:

@echo off

REM Start Voice Attack
cd "C:\Program Files (x86)\VoiceAttack"
start "" /AFFINITY E  "VoiceAttack.exe"
REM Insert 2 sec pause
TIMEOUT /T 2

REM  Start TrackIR
cd "C:\Program Files (x86)\NaturalPoint\TrackIR5"
start "" /AFFINITY E /MIN  "TrackIR5.exe"
REM Insert 2 sec pause
TIMEOUT /T 2

REM  Start LittleNavMap
cd "C:\Users\Al\Documents\Al's Flight Simulation\AddOns\Little NavMap&NavConnect\LNM Files\LittleNavmap-win-2.2.4\LittleNavmap"
start "" /AFFINITY E  "littlenavmap.exe"
REM Insert 2 sec pause
TIMEOUT /T 2

REM  Start Active Sky for P3Dv4
cd "C:\Program Files (x86)\HiFi\AS_P3Dv4"
start "" /AFFINITY E  "AS_P3Dv4.exe"
REM Insert 2 sec pause
TIMEOUT /T 2

REM  Start P3Dv4 Note Affinity Mask of Hex F
start "" /AFFINITY F  "Prepar3D.exe"
REM Insert 12 sec pause
TIMEOUT /T 10

REM  Start Kneeboard Viewer 2
cd "C:\Users\Al\Documents\Al's Flight Simulation\AddOns\KneeboardViewer\KVv2.0\KV2Files"
start "" /AFFINITY E  "KV2.exe"
REM Insert 2 sec pause
TIMEOUT /T 2

REM Start PDF Lite
cd "C:\Program Files (x86)\PDFlite"
start "" /AFFINITY E  "PDFlite.exe"

exit

Edited by ark
  • Like 1

Share this post


Link to post

Have you tried using Process Lasso instead?

Share this post


Link to post
Posted (edited)
47 minutes ago, Sethos1988 said:

Have you tried using Process Lasso instead?

Yes, I have and Process Lasso works. But I'd rather not have that running in the background, and I really want to figure out why the batch file approach does not work for Active Sky on my system (it does work for others, however).  There must be a setting somewhere (Registry?) that is blocking, or over-writing, the batch file's affinity mask for Active Sky.

Thanks for the suggestion,

Al

Edited by ark

Share this post


Link to post

Good catch. I just tested this with my own existing BAT file, which has worked correctly for years with Active Sky products (Although I can't say I've checked how it works with ASP4 in a while). My BAT file no longer works, so it's possible that HiFi now forces ASP4 to run on all cores. The only way to defeat that is to change the affinity once ASP4 is running. I do that with the replacement task manager Process Explorer. I just tried to change the affinity of ASP4 that way and it works. Project Lasso will probably work also, but I don't use it anymore.

You should ask about this on the HiFi official forums, as HiFi may have made this change to force smoother weather transitions.

Share this post


Link to post

Be sure to run your .bat file as administrator.

Mark

Share this post


Link to post
Posted (edited)
3 minutes ago, newtie said:

Be sure to run your .bat file as administrator.

Mark

Let me try that. I'm pretty sure that I do, but I use a shortcut to run the BAT file so maybe I changed something.

 

EDIT: That's it. Thanks. If ark hadn't posted this, I would have never known. Maybe I shouldn't care, since I couldn't tell the difference.

Edited by jabloomf1230
Update

Share this post


Link to post

Well, for some reason, although running a BAT file from a shortcut that is set up to "run as administrator", used to work, that approach no longer works for me (Win 10). However, there are additional lines that can be added to your the BAT file directly that assures that every app in the BAT file will be run as administrator:. See some of the response as to how add a few line to the top of the BAT file that will do the trick:

https://superuser.com/questions/788924/is-it-possible-to-automatically-run-a-batch-file-as-administrator

Share this post


Link to post

If there is an affinity mask set in the PE file header (something the developer would select as a compile-time option) then I think that overrides external processor affinity control.

We used to have to go in and set the old 3GB switch in the PE file header in the FS9.exe file the same way to get the program to work beyond the 32-bit default 2GB process VAS allocation.

It's still possible (but messy) to change those settings in the program header.  Not sure it'd be worth the trouble.

Regards

Share this post


Link to post
Posted (edited)
1 hour ago, jabloomf1230 said:

Well, for some reason, although running a BAT file from a shortcut that is set up to "run as administrator", used to work, that approach no longer works for me (Win 10).

The below seems to work for me. I put a shortcut for the bat file on my desktop, clicked on Properties, then Advanced and then Run as Administrator (see below). Active Sky now ends up with the assigned Affinity Mask as verified by the Task Manager. I also set the Active Sky exe file itself to run as Administrator in its installed location.  I had thought I'd previously set up the bat file to run in Admin mode, but I guess not. 🤔

I had originally pinned a bat file shortcut to the Task Bar, which is my preference, but I still find that to get that to run in Admin mode it seems I have to right click on it, then right click on the file name, and then select Run as Administrator (which admittedly is not the end of the world 🙂).

Why out of 6 addons only Active Sky presented this problem is still not clear to me.

Thanks all for the help!

Al

 

76c558e0ad.JPG

Edited by ark

Share this post


Link to post

It very curious, because I set up my shortcut the same way, albeit a good time ago, so maybe if I start over with a new shortcut, it might work. I'm happy with the script which assures that everything runs as administrator.  Thanks again to you for pointing this out. ASP4 sits in the background and does very little until it injects weather. Then a whole lot of stuff happens all at once. I'm speculating that HiFi forced the "all cores used" mode to make sure that the injection didn't lag.

I actually did some checking and with ASP4 setting to just one core, nothing bad happens. With it allowed to do its own thing on all cores, I get a very slight stutter when the weather is injected. This only is noticeable if the hardware is being pushed hard though.

Share this post


Link to post
Posted (edited)
38 minutes ago, jabloomf1230 said:

I'm happy with the script which assures that everything runs as administrator. 

Would you please just post that script, not sure I was able to pick out just what is needed from the linked info to make sure all runs in Admin mode.

Thanks,

Al

Edited by ark

Share this post


Link to post
Posted (edited)

I run a bat file and confirmed it was indeed setting the proper affinities, I have EVERYTHING associated with flight sim set to run as admin and UAC to never notify. I guess that's why I didn't have any issues.

 

Edited by bbuckley
  • Upvote 1

Share this post


Link to post
9 minutes ago, bbuckley said:

I have EVERYTHING associated with flight sim set to run as admin and UAC to never notify. I guess that's why I didn't have any issues.

This!

I ran the .bat file with two changes... my ASP4 (and all other addons) are installed in their own folder outside the Program Files (x86) folder and I changed the affinity to 3C, which is how I run ASP4 on my Hexacore.  It ran fine right out of the gate... started with the affinity I assigned, started ASCA (as it should), and delayed 2 seconds.

This is the script I ran:

@echo off

REM  Start Active Sky for P3Dv4
cd "C:\Prepar3d Addons\HiFi\AS_P3Dv4"
start "" /AFFINITY 3C  "AS_P3Dv4.exe"
REM Insert 2 sec pause
TIMEOUT /T 2

exit

HTH,

Greg

  • Like 1

Share this post


Link to post

Add this to the top of the BAT file:

REM --add the following to the top of your bat file--


@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------

 

Share this post


Link to post
22 minutes ago, jabloomf1230 said:

Add this to the top of the BAT file

Ah, so all that is necessary -- thank you.

Al

Share this post


Link to post

It's really a simple script. First it tries to do something that requires elevated permissions. If that fails it sets the BAT file to run as administrator. There are simpler versions without the initial check that are listed at the previous link that I posted. But why bother? The script works and doesn't delay startup of your apps.

Share this post


Link to post

Never had any issue with running AS4 via bat file on specific cores. All I had to do was verifying that AS_P3Dv4.exe, the .bat file and the shortcut on my desktop had the "run as administrator" flag set. Only one of them without the flag and it will not work. However, I did not check back for some months, I will do now.

@ark what I would not do is executing P3D itself via .bat file. Rather use the affinity mask entry inside your prepar3d.cfg...

  • Upvote 2

Share this post


Link to post

I have some bat files to set the affinity of addons. Then convert the bat file into an exe file. Run the exe as admin  Works great..

To convert into exe file, I use  http://www.f2ko.de/en/b2e.php

Free and easy to use

 

  • Upvote 1

Share this post


Link to post
7 hours ago, AnkH said:

what I would not do is executing P3D itself via .bat file. Rather use the affinity mask entry inside your prepar3d.cfg...

That makes absolutely no difference.

Share this post


Link to post
Posted (edited)

 

Now that I think about it, since I'm not trying to restrict which cores P3Dv4 uses, I probably don't need to specify an affinity mask for it.  I know P3D makes heavy use of core 0 which is why I do restrict the addons from using this core.

Al

Edited by ark

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...