如何为特定的.cmd文件禁用SmartScreen?

时间:2022-04-16 06:25:46

I recent made a group of .cmd files. Called, 'Node.1.cmd' and 'Node.2.cmd', the files' purpose was supposed to open each other (in a chain-like process). However, whenever I open one of the 2, it gives me a seriously annoying message:

我最近制作了一组.cmd文件。称为“Node.1.cmd”和“Node.2.cmd”,文件的目的应该相互打开(在类似链的过程中)。但是,每当我打开其中一个时,它就会给我一个非常烦人的消息:

Windows Protected your PC.

Windows SmartScreen prevented an unrecognized app from starting. Running this app may put your PC at risk.

Windows SmartScreen阻止了无法识别的应用程序启动。运行此应用程序可能会使您的PC面临风险。

I agree that this is a bit risky, but it was made for fun, not for destruction. It was just my way of showing people not to mess with my stuff. Not even did I set any LNK at my desktop to the file.

我同意这有点风险,但它是为了娱乐,而不是为了破坏。这只是我向人们展示不要弄乱我的东西的方式。甚至没有在我的桌面上将任何LNK设置为该文件。

Now, to get to the point, can I exclude this file from SmartScreen while keeping it on?

Because of this, I have problems opening it with a .vbs file
To be more specific, it opens but then automatically closes with a message: The system cannot find the path specified. Does windows SmartScreen encrypt the file or something like that? I scripted the following:

因此,我在使用.vbs文件打开它时遇到问题更具体地说,它打开但随后会自动关闭并显示一条消息:系统找不到指定的路径。 Windows SmartScreen会加密文件或类似的东西吗?我编写了以下内容:

Titre = "What would you like to do ? RookieTEC9©" 
message = "What would you like to do ?"&vbcr&vbcr&_
"1 - Launch Project Node "&vbcr&_
"2 - Launch Golden Chrome"&vbcr&_
"3 - Launch An Application"&vbcr&_
"4 - Start Windows Update"&vbcr&_
"5 - Slide2Kill" 
Default ="1"
Question = InputBox(message,Titre,Default)
Select Case Question 
Case 1 Run(1)
Case 2 Run(2)
Case 3 Run(3)
Case 4 Run(4)
Case 5 Run(5)
end Select

Sub Run(var)
Set WS = CreateObject("WScript.shell")
    Select Case var
    Case 1 WS.run("explorer.exe /e,C:\Users\Jeremi\OneDrive\Happy_files\Unsorted_Files\Project_Node.zip\Node.1.cmd")
    Case 2 ProcessNotNeeded()
    Case 3 LaunchApplication()
    Case 4 WindowsUpdate()
    Case 5 WS.run("SlideToShutDown.exe")
End select
End Sub 

Sub Kill(Process)
Set Ws = CreateObject("Wscript.Shell")
Command = "cmd /c Taskkill /F /IM "&Process&""
Execution = Ws.Run(Command,0,False)
End Sub

Sub ProcessNotNeeded()
Titre = "Killing Process Not Needed RookieTEC9© "
message = "Type the Name of the process to be killed by this script"&vbcr&_
"Example To Kill The Internet Explorer Process You should type"&vbcr&_
"iexplore.exe"
Default ="iexplore.exe"
Question = InputBox(message,Titre,Default)
Kill(Question)
End Sub

Function CmdPrompt(sCmd)
Dim sCmdLine,oWS,nRes
set oWS = CreateObject("Wscript.Shell")
sCmdLine = "cmd /c Start " & sCmd & ""
nRes = oWS.Run(sCmdLine,0,False)
CmdPrompt = nRes
End Function

Sub LaunchApplication()
Titre = "Launching an Application"
message = "Type the Name of the process to be Lanuched by this  script"&vbcr&_
"Example To Launch The Word Application You should type"&vbcr&_
"Winword.exe" 
Default ="Winword.exe"
Question = InputBox(message,Titre,Default)
CmdPrompt(Question)
End Sub

Sub WindowsUpdate()
Title = "Checking for Windows updates"
Msg = "Looking for a list of updates, So be Patient Thank you !"
Wait = "70" 'waiting 70 secondes to close the popup
Set Ws = CreateObject("Wscript.Shell")
ws.Popup Msg,wait,Title,64

Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()        
Set searchResult = updateSearcher.Search("IsInstalled=0 and    Type='Software'") 

If searchResult.Updates.Count <> 0 Then 'If updates were found
'so with this loop shows how you can list the title of each update that was found.
For i = 0 To searchResult.Updates.Count - 1
    Set update = searchResult.Updates.Item(i)
    ws.Popup update.Title,wait,Title,64
Next
End If
Ws.Run "wuauclt.exe /reportnow /detectnow",1,False
End Sub

Sorry for the long code! To be 100% honest, I didn't create this from scratch, I just edited it. I am new to VBS However, if you have any questions on HTML or CSS, I may be able to answer it. Please keep in mind that I am a 5th grader and only started coding this school year.
THX for your time and answer. P.S.
Also, the file was in a zip. Does that effect it?

对不起长代码!为了100%诚实,我没有从头开始创建这个,我只是编辑它。我是VBS的新手但是,如果您对HTML或CSS有任何疑问,我可以回答它。请记住,我是五年级学生,并且只在本学年开始编写代码。 THX为您的时间和答案。附:此外,该文件是拉链。这会影响吗?

1 个解决方案

#1


You can unblock these CMD files, it is explained here Once unblocked you should be able to run it from the console and from your script. I myself scripted a very long time in vbscript but now it is obsolete. Since you have just started to learn, I advise you to learn another scripting language like Ruby which is fun to learn or if you want to go the 'only windows' way Powershell (shiver..)

您可以取消阻止这些CMD文件,这里解释一旦解除阻止,您应该能够从控制台和脚本运行它。我自己在vbscript中编写了很长时间,但现在它已经过时了。由于你刚刚开始学习,我建议你学习另一种像Ruby这样的脚本语言,这很有趣,或者你想要以'唯一的窗口'的方式使用Powershell(颤抖......)

#1


You can unblock these CMD files, it is explained here Once unblocked you should be able to run it from the console and from your script. I myself scripted a very long time in vbscript but now it is obsolete. Since you have just started to learn, I advise you to learn another scripting language like Ruby which is fun to learn or if you want to go the 'only windows' way Powershell (shiver..)

您可以取消阻止这些CMD文件,这里解释一旦解除阻止,您应该能够从控制台和脚本运行它。我自己在vbscript中编写了很长时间,但现在它已经过时了。由于你刚刚开始学习,我建议你学习另一种像Ruby这样的脚本语言,这很有趣,或者你想要以'唯一的窗口'的方式使用Powershell(颤抖......)