Jump to content

Recommended Posts

Posted (edited)

Hello @ all

I created a Script that start some Programms after a while when the PC is running.But because im a newbi in Programming there are some mistakes in the Code plz help me.

Option Expicit
Dim objshell
Dim intwarten
intwarten = 15000
WScript.sleep intwarten
set objshell = Wscript.Create
Object(>>WScript.shell<<)
objshell.Exec(>>C:\...<<)

Edited by PuNiC4

Posted
Hello @ all

I created a Script that start some Programms after a while when the PC is running.But because im a newbi in Programming there are some mistakes in the Code plz help me.

Option Expicit
Dim objshell
Dim intwarten
intwarten = 15000
WScript.sleep intwarten
set objshell = Wscript.Create
Object(>>WScript.shell<<)
objshell.Exec(>>C:\...<<)

1:\ You had Option Explicit spelled wrong

2:\ You can not have this (>>C:\...<<)

3:\ You can not have this Wscript.CreateObject(>>WScript.shell<<)

Try this it count down the seconds left before C:\ opens

Option Explicit
Dim i, Cnt : Cnt = 15
Dim Act : Set Act = CreateObject("Wscript.Shell")
For i = 1 To 15
Act.Popup "There is, " & Cnt -i & " seconds left before C:\ opens", 1, "Count Down", 0 + 32
Next
Act.Run("C:\")

This sleeps for 15 seconds before C:\ opens

Option Explicit
Dim Act : Set Act = CreateObject("Wscript.Shell")
WScript.Sleep 15000 : Act.Run("C:\")

Or if you want only 1 line of code

Option Explicit : WScript.Sleep 15000 : CreateObject("Wscript.Shell").Run("C:\")

Posted (edited)

After a while nobody answeriong my question.I started to write a new code.And this was the result.

Dim WshShell, oExec, intwarten
intwarten = 15000

WScript.Sleep intwarten
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\Datei.exe")

And it works :thumbup

Edited by PuNiC4
Posted

1:\ You do not have to have this intwarten = 15000

it a wasted line.

2:\ Here is another waste of a line Set oExec = WshShell.Exec("C:\Datei.exe")

I left 3 correct ways of doing your script but I gues it was to complex for you to understand.

This is the most efficent way of doing it.

Option Explicit : WScript.Sleep 15000 : CreateObject("Wscript.Shell").Run("C:\") One single line of code is all you need.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...