Home > Blog > Run anything as service – Start a program before logon

Run anything as service – Start a program before logon

September 4th, 2009 Leave a comment Go to comments

I recently came to problem, where I needed to run a program before I do login. One solution was setting up a startscript using gpedit.msc, but this needed me to disable an option which makes Windows login much faster. So I came to another solution: Run the program as service!

This is surprisingly easy: Microsoft has added a programm, called sc.exe which does this job for you. Here is an example

sc.exe create "TrueCrypt Automount" start= "auto" binPath= "C:\automount.bat" DisplayName= "TrueCrypt Automount"
Categories: Blog Tags:
  1. The Eagle
    September 5th, 2009 at 11:32 | #1

    running aps one level higher than admin is funy too, all you had to do is to replace the system binary for the Accessibility features with cmd.exe and then run it before logon…

  2. September 5th, 2009 at 12:26 | #2

    Now I have a strange behaviour: Running the TrueCrypt mounter I wrote too early tends to Windows 7 not seeing the mounted partition – Sometimes. But I need it to work that way: Run Windows, mount before login (since apps are on these partitions) with keyfiles (the system disk is encrypted with TC too but uses a different operationmode – so keyfiles are safe). It’s strange and only seems to be an issue with the explorer: The apps on it work but I can’t access the files on it Frown

  3. September 6th, 2009 at 22:13 | #3

    It’s the windows explorer.
    TrueCrypt has a menu-option, which says “Refresh Drive Letters”. Pressing it makes the mounted HDD visible.

    Sadly, I can only trigger this by the menu (I looked at the sourcecode) and not by a commandline.

    So I have to figure out how TC “refreshes” it and recode it as a small app.

    I also noticed, inserting an USB-HDD “refreshes drive letters” too.

  4. Anne-Lise Pasch
    June 23rd, 2010 at 12:50 | #4

    I know this is an old thread, but it took me a lot of googling to find the answer to this one, so for the benefit of anyone else who googles and gets here…

    sc.exe can be used to automount truecrypt pre-login, but a startup batch with the following 2 command lines fix the explorer issues:

    devcon rescan
    (refreshes plug & play devices)
    http://support.microsoft.com/kb/311272

    nircmd shellrefresh
    (refreshes Explorer)
    http://www.nirsoft.net/utils/nircmd.html

    Good luck!

  5. June 23rd, 2010 at 17:00 | #5

    Hello Anne-Lise
    thank you for your reply.

    I could have needed that program in the past because I had exactly this problem.
    My workaround was writing this program in order to fix the missing drives bug in the Explorer. Up to know I am using my program but in the future, I will switch to another HardDisk encryption Program called DiskEncryptor because it is as fast as TrueCrypt in AES-256, faster in Serpent and TwoFish but also supports SSD optimizations and especially the ATA-TRIM command.

    Today I performed some benchmarks with an older HDD (5-6 years old) and DiskCryptor (1.0.667 – beta) was winning every single time against TrueCrypt and just dropped with the performance for data-blocks below 4 KB (about 10% less performance) where TrueCrypt was still significantly slower for blocks at and below 16 KB and there even up to 50% slower.

  6. January 17th, 2011 at 04:31 | #6

    nkqh xfjxk miasporn igiyqm g rq z xuq

  1. No trackbacks yet.

Click to Insert Smiley

SmileBig SmileGrinLaughLOLFrownBig FrownWinkKissRazzAngelAngryReally AngryConfusedNeutralThinkingChicCoolNerdSillyDrunken RazzMad RazzEvil GrinMeanPissed OffReally PissedCurseShoutGrit TeethCryWeepSide FrownWiltSmugDisdainRoll EyesSarcasmLoserTalk to the HandShyBeat UpPainShameBeautyBlushCuteLashesKissingKiss BlowKissedHeh!SmirkSnickerGiggleIn LoveDroolEek!ShockSickSuspenseTrembleDazedHypnotizedFoot in MouthMoney MouthQuietShut MouthDOH!IDKQuestionLyingStruggleSweatStopByeGo AwayWavingTime OutCall MeOn the PhoneMeetingSecretHandshakeHigh FiveHug LeftHug RightClapDanceJumpFingers CrossedVictoryYawnSleepyPrayWorshipWaitingAlienClownCowboyCyclopsDevilDoctorFemale FighterMale FighterMohawkMusicPartyPirateSkywalkerSnowmanSoldierGhostSkeletonEatStarvingVampireZombie KillerBunnyCatCat 2ChickChickenChicken 2CowCow 2DogDog 2DuckGoatHippoKoalaLionMonkeyMonkey 2MousePandaPigPig 2SheepSheep 2ReindeerSnailTigerTurtleFemaleMaleHeartBroken HeartRoseDead RosePeaceYin YangUS FlagMoonStarSunCloudyRainThunderUmbrellaRainbowMusic NoteYesNoAirplaneCarIslandAnnouncebrbBeerDrinkLiquorCakeCoffeePizzaWatermelonBowlPlateCanMailCellPhoneCameraFilmTVClockLampSearchCoinsComputerConsolePresentSoccerCloverPumpkinBombHammerKnifeHandcuffsPillPoopCigarette