I created an application that needed to run on startup, and needed to run as admin, and do it all on XP. The post about it was started a while back, but is yet to come – once it’s finished proving itself worthy. However, when executed on certain machines there have been issues where the startup process for the OS wasn’t finished in time for the application launch. These issues resulted in permissions errors. These errors didn’t occur if you closed and reopened the application seconds later.
The simple solution became obvious after a few moments of consideration. I simply needed to delay the startup of the application. To do this I crafted a very simple VBScript and placed it in the all user’s startup folder, replacing the shortcut that my installer had placed there previously.
Note: To simplify the example below uses calculator as the application to launch, and it assumes the Windows Directory is c:windows. In the real implementation this was simply the same path that was referenced by the original shortcut.
'Define a couple of variables
appPath = """c:windowssystem32calc.exe"""
delayMs = 6000
'Establish an object for the script
Set wShell = WScript.CreateObject("WScript.Shell")
'Commit and execute
And that is it. A very simple script that solved a major problem. After the delay, the application starts every time without issue. This small endeavor was the first time that I’d every truly realized the potential in visual basic scripting in a Windows environment. I’ve used PowerShell, and Batch files, and Console applications many times, but this scenario