Jump to content
Sign in to follow this  
ark

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

Recommended Posts

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?


Asus TUF X670E-PLUS | 7800X3D | G.Skill 32GB DDR @ CL30 6000MHz | RTX 4090 Founders Edition (Undervolted) | WD SNX 850X 2TB + 4TB + 4TB

Share this post


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


Bob Scott | President and CEO, AVSIM Inc
ATP Gulfstream II-III-IV-V

System1 (P3Dv5/v4): i9-13900KS @ 6.0GHz, water 2x360mm, ASUS Z790 Hero, 32GB GSkill 7800MHz CAS36, ASUS RTX4090
Samsung 55" JS8500 4K TV@30Hz,
3x 2TB WD SN850X 1x 4TB Crucial P3 M.2 NVME SSD, EVGA 1600T2 PSU, 1.2Gbps internet
Fiber link to Yamaha RX-V467 Home Theater Receiver, Polk/Klipsch 6" bookshelf speakers, Polk 12" subwoofer, 12.9" iPad Pro
PFC yoke/throttle quad/pedals with custom Hall sensor retrofit, Thermaltake View 71 case, Stream Deck XL button box

Sys2 (MSFS/XPlane): i9-10900K @ 5.1GHz, 32GB 3600/15, nVidia RTX4090FE, Alienware AW3821DW 38" 21:9 GSync, EVGA 1000P2
Thrustmaster TCA Boeing Yoke, TCA Airbus Sidestick, 2x TCA Airbus Throttle quads, PFC Cirrus Pedals, Coolermaster HAF932 case

Portable Sys3 (P3Dv4/FSX/DCS): i9-9900K @ 5.0 Ghz, Noctua NH-D15, 32GB 3200/16, EVGA RTX3090, Dell S2417DG 24" GSync
Corsair RM850x PSU, TM TCA Officer Pack, Saitek combat pedals, TM Warthog HOTAS, Coolermaster HAF XB case

Share this post


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

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

[CPL]  I9-9900K @5.0GHz HT ON, Maximus XI Hero, ASUS TUF RTX4080 OC, 32GB DDR4 3200 14, 1TB NVMe SSD, 500GB SSD, 1TB HDD, 40" Samsung 4K TV, Honeycomb Alpha & Bravo, Logitech Rudder Pedals, WIN11

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

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  
  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...