Reputation: 101
I want launch my simple VBS script after PC startup (Win XP). I don't want put this script in C:\Documents and Settings\%UserName%\Start Menu\Programs\Startup
I want do it in script, it is possible?
Script:<br>
Dim oShell<br>
Set oShell = WScript.CreateObject ("WScript.Shell")<br>
oShell.run "notepad.exe c:\text.txt"
Upvotes: 10
Views: 74480
Reputation: 369
Task Scheduler Alternative
No script is needed, create a new task (Task Scheduler 1.0 (learn.microsoft.com) for instruction). Then "Create a task" and populate at least these details:
New Trigger: At Login
New Action -> Action: Start A Program
Program/Script: notepad.exe
Arguments: text.txt
Start in: c:\
Software: Windows 10, Task Scheduler 1.0
Upvotes: -1
Reputation: 636
Easy Way :
Make a bat file
WScript.exe "Path\to\your\script.vbs"
add it to startup from gpedit.msc
Upvotes: 3
Reputation:
Add this code to the start of your vbs script Change the end of myKey to whatever you want to call the registry key
Set WshShell = CreateObject("WScript.Shell")
myKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\MyVbsScript"
WshShell.RegWrite myKey,WScript.ScriptFullName,"REG_SZ"
Upvotes: 0
Reputation: 2916
In-depth
How to Automate VBScripts to run at startup.
Step 1
Start -> Run -> cmd
or Click search
and type cmd
assoc .vbs
in command prompt
Which should print .vbs=VBSFile
ftype VBSFile
in command promptwhich should print:
vbsfile="%SystemRoot%\System32\WScript.exe" "%1" %*
So, now you know that your vbscript files open with WScript by default.
In command-prompt, type:
reg query HKEY_CLASSES_ROOT\Applications\WScript.exe /s
If you do not see this:
HKEY_CLASSES_ROOT\Applications\WScript.exe
(Standard) REG_SZ "%SystemRoot%\System32\WScript.exe" "%1" %*
Then you need to do the following, if the above is what you see, then you can skip and go to step 3:
Step 2
Go to:
Start
Run
Type in:
regedit
Select regedit press enter
(or double-click regedit) and allow the
program to make changes to your computer
HKEY_CLASSES_ROOT\Applications\WScript.exe
(If WScript.exe key does not exist, right-click Applications and create new key, rename it to WScript.exe)
"%SystemRoot%\System32\WScript.exe" "%1" %*
Step 3
Go to:
Type in:
regedit
Select app, press enter and allow the program to make changes to your computer
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
"%SystemRoot%\System32\WScript.exe" "C:\Users\me\myFolder\mySub-folder\myFile.vbs" "%1" %*
Notes:
if you want to use cscript instead, In step 2 type:
reg query HKEY_CLASSES_ROOT\Applications\cscript.exe /s
...instead and proceed, taking note to replace WScript with cscript where relevant i.e. this query:
reg query HKEY_CLASSES_ROOT\Applications\cscript.exe /s
Should produce this result:
(Standard) REG_SZ "C:\Windows\System32\cscript.exe" "%1" %*
Upvotes: 6
Reputation: 1182
you can fire a vbscipt from registry or startup by
WScript C:\somefloder\somefolder2\yourscript.vbs
you can put this line in a value on
For all the users on the machine HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
for the current user HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Upvotes: -3
Reputation: 20179
You will either have to put it in the Startup folder or run it from the registry.
For all users, use registry key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
.
For the current user, use registry key HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Upvotes: 7
Reputation: 7051
Just an appoinment, everybody probalby just know already.
HKLM is for any user on the machine, because means Local Machine
HKCU is just for the current user.
Upvotes: 1