0
我想寫桌面變量不能得到嵌入
當我運行PROGRAMM上,增加了給應用程序一個PROGRAMM(已完成)以及自定義網址到上下文菜單,並選擇自定義,輸入所需參數,它創建所需的啓動器批處理腳本的註冊表項,但定義名稱的變量givenName未添加,文件被稱爲「.bat」或第一個密鑰沒有生成(需要名稱)。
同樣是怎麼回事,需要保存在批處理腳本啓動所選擇的URL
的形式,其中發生這種情況這是代碼的網址:
Public Class FormCustom
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Hide()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim DirExists As Boolean = Nothing
If My.Computer.FileSystem.DirectoryExists("C:\ShortCut") Then
DirExists = True
End If
If DirExists = False Then
My.Computer.FileSystem.CreateDirectory("C:\ShortCut")
End If
Dim Position As String = Nothing
If RadioButton1.Checked Then
Position = "Middle"
Else
If RadioButton2.Checked Then
Position = "Bottom"
End If
End If
Dim givenName As String = Nothing
Dim givenURL As String = Nothing
TextBox2.Text = givenURL
TextBox1.Text = givenName
Dim sb As New System.Text.StringBuilder
sb.AppendLine("@echo off")
sb.Append("start " + givenURL)
IO.File.WriteAllText("C:\ShortCut\" + givenName + ".bat", sb.ToString())
My.Computer.Registry.ClassesRoot.CreateSubKey("DesktopBackground\Shell\" + givenName)
My.Computer.Registry.ClassesRoot.CreateSubKey("DesktopBackground\Shell\" + givenName + "\command")
My.Computer.Registry.ClassesRoot.OpenSubKey("DesktopBackground\Shell\" + givenName, True).SetValue("(Default)", "@shell32.dll")
My.Computer.Registry.ClassesRoot.OpenSubKey("DesktopBackground\Shell\" + givenName + "\command", True).SetValue("(Default)", "@shell32.dll")
My.Computer.Registry.ClassesRoot.OpenSubKey("DesktopBackground\Shell\" + givenName, True).SetValue("icon", "explorer.exe")
My.Computer.Registry.ClassesRoot.OpenSubKey("DesktopBackground\Shell\" + givenName, True).SetValue("Position", Position)
My.Computer.Registry.ClassesRoot.OpenSubKey("DesktopBackground\Shell\" + givenName + "\command", True).SetValue("(Default)", "C:\ShortCut\" + givenName + ".bat")
End Sub
End Class
我試圖用「+」添加變量,知道知道爲什麼它不接受它
[解決]菱在GitHub上:https://github.com/amir00t/LvL-up
對不起,讓你問一個新的問題,但在看到代碼之前我不可能知道問題是這麼簡單。:) –
沒問題,但我認爲我發現了另一件事,我應該先修復 – Max
我沒有,它修復了它,但批處理腳本不會保存在註冊表項的默認位置,而不是它自己創建一個 – Max