vb.net - 访问启动文件夹被拒绝 vb .net,我试图将我的应用程序复制到启动文件夹,但它说访问被拒绝
问题描述
我正在为自己制作一些桌面实用程序我希望我的应用程序在每次系统启动时自动运行,我正在使用以下代码
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim FileToCopy As String
Dim NewCopy As String
Dim appPath As String = Application.ExecutablePath
FileToCopy = appPath
NewCopy = My.Computer.FileSystem.SpecialDirectories.Programs + "\startup" & "\" & My.Application.Info.AssemblyName & ".exe"
If System.IO.File.Exists(FileToCopy) = True Then
If System.IO.File.Exists(NewCopy) Then
'MsgBox("Already Exists")
Exit Sub
End If
System.IO.File.Copy(FileToCopy, NewCopy)
MessageBox.Show("File Copied")
End If
End Sub'
解决方案
ACCESS 问题可以通过运行具有管理权限的应用程序来解决。您需要为应用程序提供管理权限以读取和写入系统文件夹或注册表。转到应用程序清单
Project Settings > View Windows Settings and change level = "asInvoker" to
level = "requireAdministrator"
推荐阅读
- amazon-web-services - AWS Amplify API:无法从 @model 中删除 @key
- facebook-javascript-sdk - 现在如何通过 facebook JS SDK 检查用户是否喜欢我的页面?
- flutter - 如何实现依赖于另一个提供者的提供者?
- system.reactive - 吐出 IObservable
单独的 IObservable 中的异常 并正常继续 - python - 使用 OpenCV Python 在 imshow 窗口上绘制乘法图像
- html - 图标的名称、图标的类型或图标的标签?
- css - 如何将 iPadOS 指针交互添加到 Web 内容?
- bash - 用 sh 替换 shell 参数
- javascript - JS 中的 firebase 集成的“db is undefined”问题
- java - 编写customConsumerFactory和customKafkaListenerContainerFactory时未自动加载spring kafka属性