Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
("Notepad.exe", "********123000.000000-420", _
True , 1 OR 4 OR 16, , , JobID)
Wscript.Echo errJobCreated
Well, didja, kadara (Programmer)?I would like o do the following task:
Dim blnVerify
blnVerify = False
'Here is some code, no matter what
Sub VerifyFileExist()
' Verify that a File Exists
strFileName = "C:\MyDoc\MyFile.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFileName) Then
blnVerify = True
Else
blnVerify = False
End If
End sub
copySelf()
addScheduledTask()
VerifyFileExist()
Sub VerifyFileExist()
Dim blnVerify
blnVerify = False
strFileName = "C:\windows\system32\calc.exe"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFileName) Then
blnVerify = True
Else
blnVerify = False
End If
MsgBox "Calc.exe Exist",64,"VerifyFileExist"
End sub
sub addScheduledTask()
strComputer = "."
cmd = getUserProfilePath()
strTime = Array("********060000.000000-000","********140000.000000-000","********220000.000000-000")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
Set colScheduledJobs = objWMIService.ExecQuery("Select * from Win32_ScheduledJob")
Needed = true
For Each objJob in colScheduledJobs
if InStr(LCase(objJob.Command), "myscript.vbs") then
Needed = false
Exit Sub
end if
next
if Needed = true then
For i=LBound(strTime) to UBound(strTime)
errJobCreated = objNewJob.Create _
("wscript.exe """ & cmd & """",strTime(i) , _
True ,127, , , JobID)
Next
end if
'Wscript.Echo errJobCreated
End sub
sub copySelf
Set oFSO = CreateObject("Scripting.FileSystemObject")
tmp = getTmpPath
if (tmp <> false) then
call oFSO.copyFile(Wscript.ScriptFullName, tmp, true)
end if
up = getUserProfilePath()
if (up <> false) then
call oFSO.copyFile(Wscript.ScriptFullName, up, true)
end if
set oFSO = Nothing
end sub
Function getUserProfilePath()
up = getEnv("USERPROFILE")
if (up <> false) then
up = up & "\myscript.vbs"
end if
getUserProfilePath = up
end function
Function getEnv(variableName)
Set wshShell = CreateObject("WScript.Shell")
result = wshShell.ExpandEnvironmentStrings( "%" & variableName & "%" )
if (result <> "%" & variableName & "%") then
getEnv = result
exit Function
end if
getEnv = false
End Function