How to run file . vbs on Windows Start

Asked

Viewed 1,575 times

0

As I could run a file . vbs when windows start, I can make a file . bat run by regedit.

I already put a . bat to open . vbs, I did so

cscript "C:\teste.vbs"
exit
  • @Henry even called the vbs by bat, but he got the cmd open(even though I put Exit at the end)

  • @Henrique Pronto, I updated

  • Try to change the cscriptfor start.

2 answers

1


Update Responding:

The command that adds an entry in the record, instructing the execution of a commando / filing cabinet at each system startup via commando / bat:

rem :: Obs.: O \" é para "escapar" as aspas no comando Reg Add adicionando no registro::
Reg Add "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v Run_VBS /t reg_sz /d "\"C:\teste.vbs\"" 

To rule out / undo the entry by the line of commando /bat:

delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v Run_VBS /f


Update Relevant additional information & example of use/application:

Add instructions for running a vbs script in windows startup, will imply choosing two things:

1) Where to add ?

2) How remove after are no longer needed?


About the Where:

As a suggestion, the code below was written to use the Key: HKCU\Software\Microsoft\Windows\CurrentVersion\Run

You can edit to meet your needs by observing the explanations below...


About the Removal:

The very one bat removes the entrances/values added by him to key, it identifies whether the values in the registration to make the removal.

Running once, he will create the entries/values needed in the registration, however, when run again, and he takes care to remove the keys/values of the entries by he added in the first execution... The very one bat will create a VBS as a test...

StartUP_VBS.cmd

@echo off & setlocal enabledelayedexpansion 

rem :: aqui vc pode editar a variável "_hkl_run" conforme lhe atende considerando o comanentário abaixo ::
set _hkl_run_=HKCU\Software\Microsoft\Windows\CurrentVersion\Run

( 
>"%temp%\_vbs_exemplo_teste.vbs" echo/ msgbox "VBS Boot Teste" ,4, "O que me diz, funciona?" 
) && ( set "_vbs_=%temp%\_vbs_exemplo_teste.vbs"
) || ( echo/ Erro criando vbs^!!
) 
timeout /t -1
>nul ((
reg query "!_hkl_run_!" | findstr /l /c:"Run_VBS" 2>nul >nul
) && (
reg delete "!_hkl_run_!" /v Run_VBS /f 
) || (
reg add "!_hkl_run_!" /v Run_VBS /t reg_sz /d "\"!_vbs_!\"" 
)) 2>nul 

rundll32.exe USER32.DLL,UpdatePerUserSystemParameters 1, True

Qual chave devo fazer uso e quando usar?

HKCU or HKLM and yet, Runonce or Run

Operates for the Current user ==> HKCU

Opera for all Users ==> HKLM

Opera once and is excluded from the Register ==> Runonce

Opera permanently and is on the record ==> Run


Obs.:#1 The key Run remains in the Registering for permanent execution during the boot!

Obs.:#2 The key Runonce fades from Registering before being executed, only runs once!


For execution only on the next boot and to any user, use that key: HKLM SOFTWARE Microsoft Windows Currentversion Runonce


For execution only next boot and only for the current user, use: HKCU Software Microsoft Windows Currentversion Runonce


For the execution continuous/permanent, only current user, use: HKCU Software Microsoft Windows Currentversion Run


For the execution continuous/permanent, and to any user, use: HKLM SOFTWARE Microsoft Windows Currentversion Run


Obs.: To use a which creates a , it is necessary to use when the characters not in quotes: Example: ^(, ^), ^{, ^}, ^&, ^>, ^<, etc...

That one bat will generate a VBS and add an entry in the log needed to after restarting the computer, it run the VBS. Running open this window below: tela após reiniciar


To undo/remove/revert without rotating the bat again, just use/run the commando down below:

reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v Run_VBS /f

0

If the file runs normally after running the bat just copy it to

C: Users Your User Appdata Roaming Microsoft Windows Start Menu Programs Startup\

Don’t forget to edit the path for the script in bat

Browser other questions tagged

You are not signed in. Login or sign up in order to post.