如何打开记事本文本文件并保持所有其他窗口的顶部,直到我在VBScript中将其关闭? [英] How to open Notepad text file and keep on top of all other windows until i close it in VBScript?

查看:60
本文介绍了如何打开记事本文本文件并保持所有其他窗口的顶部,直到我在VBScript中将其关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个vbscript来打开保存的记事本文本文件,并将此记事本文本文件保留在所有其他窗口的顶部,直到我将其最小化或关闭为止.

I would like to create a vbscript to open a notepad text file I saved and keep this notepad text file on top of all other windows either until i minimise it or close it.

我想在任务中创建一个提醒,然后每30分钟左右弹出一次提醒我,但是当我浏览时它不会在后台显示.

I want to create a reminder in tasks then so it pops up every 30 minutes or so and reminds me but so when i browse it does not go in the background.

非常感谢您的帮助.

Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "notepad.exe C:\Users\***USER***\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\TODO.txt", 1
Set oShell = Nothing  

推荐答案

我为您示例创建了一个计划任务,该任务每30分钟执行一次,以打开记事本最大化:

I made for you an example to create a schedule task to be executed each 30 minutes to open Notepad Maximized :

Option Explicit
Dim Title,fso,Ws,FilePath,TaskName,Repeat_Task,Command
Title = "Create Schedule Task"
Set fso = CreateObject("Scripting.FileSystemObject")
FilePath = "C:\Users\***USER***\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\TODO.txt"
If Not fso.FileExists(FilePath) Then
    MsgBox "File : "& chr(34) & FilePath & chr(34) & vbcrlf & vbcrlf &_
    "Does not exists ! Please check it ," & vbcrlf &_
    "before proceeding with this vbscript !",vbExclamation,Title
    Wscript.Quit(1)
End If
TaskName = "Open_Notepad"
Repeat_Task = 30
Call Create_Schedule_Task(Repeat_Task,TaskName,WScript.ScriptFullName)
Command = "CMD /C Start /MAX Notepad "& FilePath &""
Set Ws = CreateObject("Wscript.Shell")
Ws.run Command,0,True
'--------------------------------------------------------------
Sub Create_Schedule_Task(Repeat_Task,TaskName,ScriptFilePath)
Dim Task,Result
Task = "CMD /C Schtasks /Create /SC DAILY /ST 08:00 /F /RI "&_
Repeat_Task &" /DU 24:00 /TN "& TaskName &" /TR "& ScriptFilePath &""
Set Ws = CreateObject("Wscript.Shell")
Result = Ws.run(Task,0,True)
End Sub
'---------------------------------------------------------------


奖金:于17/08/2020 @ 08:50进行 这是一个混合代码批处理和Powershell,可帮助我们显示所有No Microsoft Scheduled Tasks".


Bonus : EDIT on 17/08/2020 @08:50 : This is a Hybrid code Batch and Powershell that help us to show All No Microsoft Scheduled Tasks.

Show_No-Microsoft_Tasks.bat

<# : Batch portion
@rem # The previous line does nothing in Batch, but begins a multiline comment block
@rem # in PowerShell.  This allows a single script to be executed by both interpreters.
@echo off
Title Get Schedule Tasks with a Hybrid code Batch and Powershell Script by Hackoo 2020
echo(
rem # This a Powershell command executes the hybrid portion at the bottom of this script
rem @for /f "delims=" %%I in ('powershell -noprofile "iex (${%~f0}|out-string)"') do echo %%I
>"%~dpn0.txt"  (
    @for /f "delims=" %%I in ('powershell -noprofile "iex (${%~f0}|out-string)"') do echo %%I
)
REM TimeOut /T 3 /NoBreak>nul
If Exist "%~dpn0.txt" Start "" "%~dpn0.txt" & exit /b
rem # End multi-line PowerShell comment block.  Begin PowerShell scripting.
: end Batch / begin PowerShell hybrid code #>
Function getTasks($path) {
    $out = @()
    # Get root tasks
    $schedule.GetFolder($path).GetTasks(0) | % {
        $xml = [xml]$_.xml
        $out += New-Object psobject -Property @{
            "Name" = $_.Name
            "Path" = $_.Path
            "LastRunTime" = $_.LastRunTime
            "NextRunTime" = $_.NextRunTime
            "Actions" = ($xml.Task.Actions.Exec | % { "$($_.Command) $($_.Arguments)" }) -join "`n"     
        }
    }
    # Get tasks from subfolders
    $schedule.GetFolder($path).GetFolders(0) | % {
        $out += getTasks($_.Path)
    }
    #Output
    $out
}
$tasks = @()
$schedule = New-Object -ComObject "Schedule.Service"
$schedule.Connect() 
# Start inventory
$tasks += getTasks("\")
# Close com
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($schedule) | Out-Null
Remove-Variable schedule

# To show All No Microsoft Scheduled Tasks
$tasks | ? { $_.Path -notmatch "Micro*" }
Read-Host 'Type any key to continue'
$tasks | ? { $_.Path -notmatch "Micro*" } | Out-GridView
Read-Host 'Type any key to continue'

<#
# Output all tasks
#$tasks | Out-GridView
#Read-Host 'Type any key to continue'
# To show only tasks with those extensions in their TaskPath
#$tasks | ? { $_.Actions -match "(\.vbs|\.vbe|\.cmd|\.bat|\.hta)" } | Out-GridView
#Read-Host 'Type any key to continue'
#>

这篇关于如何打开记事本文本文件并保持所有其他窗口的顶部,直到我在VBScript中将其关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆