Monday 23 December 2019

How can I make a VB script execute every time Windows starts up?


My goal is to copy INI.file each time Windows XP is started up or rebooted.


The following VB script copies INI.file from a local directory to C:\INI_DIR.


I tried to copy the VB script to C:\WINDOWS\system32\config\systemprofile\Start Menu\Programs\Startup, but it doesn't get activated. Is it not the right path? How can I make it execute on startup/reboot?


The script:


   Dim currDir 
Const OverwriteExisting = True

Set fso = CreateObject("Scripting.FileSystemObject")

currDir = fso.GetParentFolderName(Wscript.ScriptFullName)




Set objFSO = CreateObject("Scripting.FileSystemObject")


objFSO.CopyFile currDir & "\INI.file" , "C:\INI_DIR" , OverwriteExisting


' Release the objFSO objects
Set objFSO = Nothing


' Release the fso objects
Set fso = Nothing

Answer



That's the wrong path. That's the login profile for the system account (Couldn't find any direct documentation, but this makes mention of that fact). That's the account that system servers will run, but it won't run for interactive users.


The startup folder for your account is in:


c:\Documents And Settings\{Your User Name}\Start Menu\Programs\Startup

Or if you want it to run for all logins, but it into:


c:\Documents And Settings\All Users\Start Menu\Programs\Startup

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...