MSConfig not seeing startup entry

Windows specific forum
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

MSConfig not seeing startup entry

Post by Dude »

Hi dudes. :)

I added my exe to "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" and it works great -- it runs at logon as expected. Good stuff; happy days.

But when I open MSConfig and go to the "Startup" tab, it's NOT listed there, even after a reboot. :( Anyone know why? Surely it should be appearing there?

Here's some screenshots: https://i.imgur.com/ZrODZrC.png

My exe, starting with "A", should be there?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: MSConfig not seeing startup entry

Post by RASHAD »

Try

Code: Select all

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
Egypt my love
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: MSConfig not seeing startup entry

Post by Dude »

Hi Rashad, no need to try that because my exe needs to run from a limited account, which can't write to HKEY_LOCAL_MACHINE.

So even if it appears there in MSConfig for HKEY_LOCAL_MACHINE, it won't help with HKEY_CURRENT_USER.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: MSConfig not seeing startup entry

Post by RASHAD »

OK
Try next snippet

Code: Select all

  listptr=0
  result$=Space(270)
  SHGetSpecialFolderLocation_(0,#CSIDL_STARTUP,@listptr)
  SHGetPathFromIDList_(listptr,@result$)
  Path$ = Trim(result$)
  
  Linkn$ = "RASHAD.LNK"                               ;Link Name(Your Program Name)
  Prog$ = "C:\PB_Player\PB_Player.exe"                ;Programme Name (With Full Path)
  WorkDir$ = "C:\PB_Player\"                          ;Working Directory
  
  If OpenFile(0,Path$+"\temp.vbs")
    CloseFile(0)
    DeleteFile(Path$+"\temp.vbs")
  EndIf  
  DeleteFile(Path$+"\RASHAD.LNK")

If CreateFile(0, GetHomeDirectory()+"temp.vbs",#PB_File_SharedRead)
  WriteStringN(0, "Set oWS = WScript.CreateObject("+Chr(34)+"WScript.Shell"+Chr(34)+")")
  WriteStringN(0, "sLinkFile = "+Chr(34)+Path$+"\"+Linkn$+Chr(34))
  WriteStringN(0, "Set oLink = oWS.CreateShortcut(sLinkFile)")
  WriteStringN(0, "oLink.TargetPath = "+Chr(34)+Prog$+Chr(34))
  WriteStringN(0, "oLink.IconLocation = "+Chr(34)+Prog$+", 0"+Chr(34))
  WriteStringN(0, "oLink.WindowStyle = "+Chr(34)+"1"+Chr(34))                   ;#SW_SHOWNORMAL = 1 ,#SW_SHOWMINIMIZED = 2 ,#SW_SHOWMAXIMIZED = 3
  WriteStringN(0, "oLink.WorkingDirectory = "+Chr(34)+WorkDir$+Chr(34))
  WriteStringN(0, "oLink.Save")
  CloseFile(0)
Else
  MessageRequester("Error", "Error: can't write the file", 0)
EndIf

;RunProgram("WScript.exe"," "+GetHomeDirectory()+"temp.vbs","",#PB_Program_Wait| #PB_Program_Hide)
RunProgram(GetHomeDirectory()+"temp.vbs","","", #PB_Program_Wait|#PB_Program_Hide)
DeleteFile(GetHomeDirectory()+"temp.vbs")
Egypt my love
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: MSConfig not seeing startup entry

Post by RASHAD »

Danilo ---> ts-soft ---> RASHAD
Using code

Code: Select all


Macro DEFINE_GUID(Name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
  CompilerIf Defined(Name, #PB_Variable)
    If SizeOf(Name) = SizeOf(GUID)
      Name\Data1    = l
      Name\Data2    = w1
      Name\Data3    = w2
      Name\Data4[0] = b1
      Name\Data4[1] = b2
      Name\Data4[2] = b3
      Name\Data4[3] = b4
      Name\Data4[4] = b5
      Name\Data4[5] = b6
      Name\Data4[6] = b7
      Name\Data4[7] = b8
    Else
      Debug "Error - variable not declared as guid"
    EndIf
  CompilerEndIf
EndMacro


Procedure CreateShortcut(Path.s, Link.s, WorkingDir.s = "", Argument.s = "", ShowCommand.l = #SW_SHOWNORMAL, Description.s =  "", HotKey.l = #Null, IconFile.s = "|", IconIndex.l = 0)
  Protected psl.IShellLinkW, ppf.IPersistFile, Result
  Protected.GUID CLSID_ShellLink, IID_IShellLink, IID_IPersistFile
  
  DEFINE_GUID(CLSID_ShellLink, $00021401, $0000,$0000, $C0, $00, $00, $00, $00, $00, $00, $46) ; {00021401-0000-0000-C000-000000000046}
  DEFINE_GUID(IID_IShellLink, $000214F9, $0000,$0000, $C0, $00, $00, $00, $00, $00, $00, $46)  ; {000214F9-0000-0000-C000-000000000046}
  DEFINE_GUID(IID_IPersistFile, $0000010B, $0000,$0000, $C0, $00, $00, $00, $00, $00, $00, $46); {0000010b-0000-0000-C000-000000000046}
  
  If IconFile = "|" : IconFile = Path : EndIf

  CoInitialize_(0)
  If CoCreateInstance_(@CLSID_ShellLink, 0, 1, @IID_IShellLink, @psl) =  #S_OK

    Set_ShellLink_preferences:
    psl\SetPath(Path)
    psl\SetArguments(Argument)
    psl\SetWorkingDirectory(WorkingDir)
    psl\SetDescription(DESCRIPTION)
    psl\SetShowCmd(ShowCommand)
    psl\SetHotkey(HotKey)
    psl\SetIconLocation(IconFile, IconIndex)
    ShellLink_SAVE:
    If psl\QueryInterface(@IID_IPersistFile, @ppf) = #S_OK
      ppf\Save(Link, #True)
      result = 1
      ppf\Release()
    EndIf
    psl\Release()
  EndIf
  CoUninitialize_()
  ProcedureReturn result
EndProcedure


listptr = 0
result$=Space(270)
SHGetSpecialFolderLocation_(0,#CSIDL_STARTUP,@listptr)
SHGetPathFromIDList_(listptr,@result$)
Path$ = Trim(result$)

CreateShortcut("C:\pb_player\pb_player.exe",Path$+"\rashad.lnk","","",#SW_SHOWMAXIMIZED,"",#Null,"%SystemRoot%\system32\SHELL32.dll",12)
Egypt my love
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: MSConfig not seeing startup entry

Post by Dude »

Hi Rashad, both your examples didn't put anything in the Startup tab of MSConfig for me. Thanks for trying. BTW, I'm using Win 7.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: MSConfig not seeing startup entry

Post by RASHAD »

The 2nd snippet works as expected with Windows 7,8,10
Egypt my love
Post Reply