WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Start Menu - TaskBar

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Disable Startup Folder

Keywords: 

Question:

Does anyone have any ideas on how to disable the running of programs in the Startup Folders programmatically through WinBatch or a registry key? I know I can hold down SHIFT during login, but the whole point is I'm not going to be sitting at the workstation. I need to push out something to disable it temporarily, then re-enable it after I'm done. Any ideas from the gurus out there?

Answer:

  1. I think there is a registry key someplace. Are you dealing with Windows 95/98 or NT.

  2. You could investigate the 95 or NT resource kit and/or the Policy editor.

  3. Why not just move all the links out of Startup and put them back when you're done?

    Don't forget to check in your profile and in the all_users profile.

  4. You may be able to do something with this:
    
    RegQueryValue(@REGCURRENT,"software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders[Startup]")
    
    I don't know if changing it will affect the actual startup. Also, another trick I tried with limited success was renaming all of the links to *.xyz, and then having a Winbatch close all the "Open With" boxes that pop up when Windows doesn't recognize the extensions. Good luck!

    We make a winbatch script consisting of one line....

    
    ;---snip---
    exit
    ;---snip---
    
    Then we pick a filetype, say *.xyz and associate xyz files with this script. Say it is compiled to xyz.exe

    To associate...

    
    rkey=RegOpenKey(@REGCLASSES,"")
    RegSetValue(rkey, ".xyz", "xyz_auto_file")
    RegSetValue(rkey,"xyz_auto_file\shell\open\command","c:\someplace\xyz.exe")
    RegSetValue(rkey,"%a%_auto_file","XYZ File")
    RegClosekey(rkey)
    
    Then to knock out the startup group. something like
    
    startup=ShortCutDir("startup")
    DirChange(startup)
    FileMove("*.lnk","*.xyz",0)
    
    then to restore the startup group
    
    startup=ShortCutDir("startup")
    DirChange(startup)
    FileMove("*.xyz","*.lnk",0)
    
    This will work if there are only LNK files in the startup group. If there are real exe's or data files it will keel over.

    Then you can associate exe's to xy1 and com's to xy2 and so on. Just so you keep track to change them back. But then there are also "BAT" and "CMD" and it is even possible to define other exe extensions.

  5. Don't try renaming the startup folder, it won't work. If you rename StartUp, Window's just digs out the old values (from the last successful boot?) and uses those.

    Pointing to an empty directory works in 9x I don't know about NT. You have to search the registry and point all your users to this empty directory. Unless there's something in NT that prevents moving the contents of the StartUp folders, I think its a better bet (you're only reading the registry, not modifying it).

    When you read the Registry, you'll need to trap your query:

    
    kPath = 'Software\Microsoft\windows\CurrentVersion\Explorer\User Shell Folders'
    kUser = regopenkey(@REGCURRENT, kPath)
    errormode(@off)
    lasterror()
    userVal = regqueryexpsz(kUser, '[StartUp]')
    errormode(@cancel)
    if lasterror() != 1233 then goto Cancel
    regclosekey(kUser).
    
    "[StartUp]" may not exist for the current user and the script will error out.

Article ID:   W14406
Filename:   Disable Startup Folder.txt
File Created: 2001:01:31:10:43:04
Last Updated: 2001:01:31:10:43:04