• 0

Batch File to run .VBS on startup


Question

I want to run a xxx.vbs script on startup. How do i make a batch file which will run the .vbs file on startup ( every time i boot into windows)

I just cant add the shortcut to .VBS to startup because I want to run the xx.vbs and give a certain value after it ...

example in the run command i would type

c:\xxx.vbs 1234567890

If i just run the .VBS i will get an error saying cant run without the argument. So i need a batch file which will run

c:\xxx.vbs 1234567890

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

You could do this:

Create batch file:

startit.bat

@echo off
start c:\xxx.vbs 1234567890

Then create .reg file and merge it to your registry:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"My VBS Script"="C:\\my scripts\\startit.bat"

Quick'n'dirty. :)

Link to comment
Share on other sites

  • 0

You could do this:

Create batch file:

startit.bat

@echo off
start c:\xxx.vbs 1234567890

Then create .reg file and merge it to your registry:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"My VBS Script"="C:\\my scripts\\startit.bat"

Quick'n'dirty. :)

Lose the batch file. It's not needed. (Besides, you get a black window as a result of using it)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]

"My VBS Script"="C:\\myscript.vbs"

or

"My VBS Script"="wscript.exe C:\\myscript.vbs"

or place a shortcut to your VBS file in the Startup folder.

Link to comment
Share on other sites

  • 0

Yeah I'd just make a shortcut to the script and put the arguments in the shortcut properties? That's what I did for my machine because I have to run a uh, vbs file that also gets a string of numbers and letters at startup ;)

Link to comment
Share on other sites

  • 0

Add this as the last thing in the VBS script

CreateObject("Wscript.Shell").run("%comspec% /c Taskkill /F /IM wmiprev.exe"),0,true 
Link to comment
Share on other sites

  • 0

This is how the script ends

if err <> 0 then

WScript.Echo Err.Description, "0x" & Hex(Err.Number)

Err.Clear

end if

Next

so where do i add it ?

Link to comment
Share on other sites

  • 0

You could do this:

Create batch file:

startit.bat

@echo off
start c:\xxx.vbs 1234567890

Then create .reg file and merge it to your registry:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"My VBS Script"="C:\\my scripts\\startit.bat"

Quick'n'dirty?. smile.gif

This was the last key to my puzzle, in which I was trying to use a vbs script to set a default login on a Windows 7 machine on a domain. My script wasn't working via a local GPO but your solution nailed it.

Thanks!

Tom

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.