user790870
user790870

Reputation:

Windows Script Host cannot find the file on startup

I am having here a vbs-file which starts a batch script. The batch should run invisible, so i use this vbs-script:

WScript.CreateObject( "WScript.Shell" ).Run "loop.bat",0,0

The vbs is registered to the run-key in the registry-

Everytime on startup it tells me that he cannot find the specified file. Maybe the Windows Script Host is starting to late for my vbs-script?

What should I do?

vbs with delayed start? This needs another loop, but my script shall be invisible.

vbs in the startupfolder? Better taking the registry. For other reasons I cannot use the startupfolder.

Thanks for your answers :)

Upvotes: 1

Views: 6344

Answers (1)

SmithMart
SmithMart

Reputation: 2811

I know it's old... But i thought I'd put this in in case anyone stumbles here.

if you add something to run, when it starts unless otherwise specified it's working directory is C:\Windows\System32 so if you point to a file, "mybat.bat" it will assume it's in c:\windows\system32\mybat.bat

that's why you need to specify the whole path in the vbs.

if you are in a bat file then add this to the top of your file:

PUSHD %~dp0

Martyn

Upvotes: 2

Related Questions