繁体   English   中英

如何打开记事本文本文件并保持在所有其他 windows 之上,直到我在 VBScript 中关闭它?

[英]How to open Notepad text file and keep on top of all other windows until i close it in VBScript?

我想创建一个 vbscript 来打开我保存的记事本文本文件,并将这个记事本文本文件放在所有其他 windows 之上,直到我最小化它或关闭它。

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

非常感谢任何帮助。

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 分钟执行一次以打开记事本最大化:


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
'---------------------------------------------------------------

奖励:编辑于 2020 年 8 月 17 日 @08:50:这是一个混合代码批处理和 Powershell,可帮助我们显示所有无 Microsoft 计划任务。

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'
#>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM