N
neksodebe
Hello,
I've been working on a "Operating System Simulator" named RimontOS, and I wanted it to be searchable in the search menu.
So I tried using a VBS script to create a shortcut in the "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\RimontOS" directory. The problem is that it shows this error:
Unable to save shortcut "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\RimontOS\RimontOS.lnk"
Code: 80070005
I don't know how to fix it.
The code looks like this:
[COLOR=rgba(212, 212, 212, 1)]
[COLOR=rgba(86, 156, 214, 1)]Dim[/COLOR] [COLOR=rgba(156, 220, 254, 1)]WshShell, strCurDir[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] WshShell = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"WScript.Shell"[/COLOR])
strCurDir = [COLOR=rgba(156, 220, 254, 1)]WshShell[/COLOR].[COLOR=rgba(156, 220, 254, 1)]CurrentDirectory[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] WshShell =[COLOR=rgba(86, 156, 214, 1)] Nothing[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] objFSO = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"Scripting.FileSystemObject"[/COLOR])
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] f = [COLOR=rgba(156, 220, 254, 1)]objFSO[/COLOR].[COLOR=rgba(220, 220, 170, 1)]OpenTextFile([/COLOR]strCurDir + [COLOR=rgba(206, 145, 120, 1)]"\apppath.txt"[/COLOR])
apppath = [COLOR=rgba(156, 220, 254, 1)]f[/COLOR].[COLOR=rgba(156, 220, 254, 1)]ReadLine
f[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Close[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] fb = [COLOR=rgba(156, 220, 254, 1)]objFSO[/COLOR].[COLOR=rgba(220, 220, 170, 1)]OpenTextFile([/COLOR]strCurDir + [COLOR=rgba(206, 145, 120, 1)]"\dir.txt"[/COLOR])
dir = [COLOR=rgba(156, 220, 254, 1)]fb[/COLOR].[COLOR=rgba(156, 220, 254, 1)]ReadLine
fb[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Close[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] oShell = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]( [COLOR=rgba(206, 145, 120, 1)]"WScript.Shell"[/COLOR] )
programdata=[COLOR=rgba(156, 220, 254, 1)]oShell[/COLOR].[COLOR=rgba(220, 220, 170, 1)]ExpandEnvironmentStrings([/COLOR][COLOR=rgba(206, 145, 120, 1)]"%programdata%"[/COLOR])
[COLOR=rgba(86, 156, 214, 1)]dim[/COLOR] [COLOR=rgba(156, 220, 254, 1)]filesys, newfolder, newfolderpath[/COLOR]
newfolderpath = programdata + [COLOR=rgba(206, 145, 120, 1)]"\Microsoft\Windows\Start Menu\Programs"[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]set[/COLOR] filesys=[COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"Scripting.FileSystemObject"[/COLOR])
[COLOR=rgba(197, 134, 192, 1)]If[/COLOR] [COLOR=rgba(86, 156, 214, 1)]Not[/COLOR] [COLOR=rgba(156, 220, 254, 1)]filesys[/COLOR].[COLOR=rgba(220, 220, 170, 1)]FolderExists([/COLOR]newfolderpath) [COLOR=rgba(197, 134, 192, 1)]Then
Set[/COLOR] newfolder = [COLOR=rgba(156, 220, 254, 1)]filesys[/COLOR].[COLOR=rgba(220, 220, 170, 1)]CreateFolder([/COLOR]newfolderpath)
[COLOR=rgba(197, 134, 192, 1)]End If
Set[/COLOR] Shell = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"WScript.Shell"[/COLOR])
DesktopPath = [COLOR=rgba(156, 220, 254, 1)]Shell[/COLOR].[COLOR=rgba(220, 220, 170, 1)]SpecialFolders([/COLOR][COLOR=rgba(206, 145, 120, 1)]"Desktop"[/COLOR])
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] link = [COLOR=rgba(156, 220, 254, 1)]Shell[/COLOR].[COLOR=rgba(220, 220, 170, 1)]CreateShortcut([/COLOR]DesktopPath & [COLOR=rgba(206, 145, 120, 1)]"\RimontOS.lnk"[/COLOR])
[COLOR=rgba(156, 220, 254, 1)]link[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Description[/COLOR] = [COLOR=rgba(206, 145, 120, 1)]"RimontOS"[/COLOR]
[COLOR=rgba(156, 220, 254, 1)]link[/COLOR].[COLOR=rgba(156, 220, 254, 1)]TargetPath[/COLOR] = apppath
[COLOR=rgba(156, 220, 254, 1)]link[/COLOR].[COLOR=rgba(156, 220, 254, 1)]WorkingDirectory[/COLOR] = dir
[COLOR=rgba(156, 220, 254, 1)]link[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Save[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] Shell2 = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"WScript.Shell"[/COLOR])
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] link2 = [COLOR=rgba(156, 220, 254, 1)]Shell2[/COLOR].[COLOR=rgba(220, 220, 170, 1)]CreateShortcut([/COLOR]programdata + [COLOR=rgba(206, 145, 120, 1)]"\Microsoft\Windows\Start Menu\Programs\RimontOS"[/COLOR] & [COLOR=rgba(206, 145, 120, 1)]"\RimontOS.lnk"[/COLOR])
[COLOR=rgba(156, 220, 254, 1)]link2[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Description[/COLOR] = [COLOR=rgba(206, 145, 120, 1)]"RimontOS"[/COLOR]
[COLOR=rgba(156, 220, 254, 1)]link2[/COLOR].[COLOR=rgba(156, 220, 254, 1)]TargetPath[/COLOR] = apppath
[COLOR=rgba(156, 220, 254, 1)]link2[/COLOR].[COLOR=rgba(156, 220, 254, 1)]WorkingDirectory[/COLOR] = dir
[COLOR=rgba(156, 220, 254, 1)]link2[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Save[/COLOR]
[/COLOR]
The dir.txt file has the working directory of the file I want to create a shortcut to and the apppath.txt file has the path to the file.
I searched it up and it's a permission issue (Access denied), so I also accept code to run the file as administrator (with the prompt)
Continue reading...
I've been working on a "Operating System Simulator" named RimontOS, and I wanted it to be searchable in the search menu.
So I tried using a VBS script to create a shortcut in the "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\RimontOS" directory. The problem is that it shows this error:
Unable to save shortcut "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\RimontOS\RimontOS.lnk"
Code: 80070005
I don't know how to fix it.
The code looks like this:
[COLOR=rgba(212, 212, 212, 1)]
[COLOR=rgba(86, 156, 214, 1)]Dim[/COLOR] [COLOR=rgba(156, 220, 254, 1)]WshShell, strCurDir[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] WshShell = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"WScript.Shell"[/COLOR])
strCurDir = [COLOR=rgba(156, 220, 254, 1)]WshShell[/COLOR].[COLOR=rgba(156, 220, 254, 1)]CurrentDirectory[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] WshShell =[COLOR=rgba(86, 156, 214, 1)] Nothing[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] objFSO = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"Scripting.FileSystemObject"[/COLOR])
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] f = [COLOR=rgba(156, 220, 254, 1)]objFSO[/COLOR].[COLOR=rgba(220, 220, 170, 1)]OpenTextFile([/COLOR]strCurDir + [COLOR=rgba(206, 145, 120, 1)]"\apppath.txt"[/COLOR])
apppath = [COLOR=rgba(156, 220, 254, 1)]f[/COLOR].[COLOR=rgba(156, 220, 254, 1)]ReadLine
f[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Close[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] fb = [COLOR=rgba(156, 220, 254, 1)]objFSO[/COLOR].[COLOR=rgba(220, 220, 170, 1)]OpenTextFile([/COLOR]strCurDir + [COLOR=rgba(206, 145, 120, 1)]"\dir.txt"[/COLOR])
dir = [COLOR=rgba(156, 220, 254, 1)]fb[/COLOR].[COLOR=rgba(156, 220, 254, 1)]ReadLine
fb[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Close[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] oShell = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]( [COLOR=rgba(206, 145, 120, 1)]"WScript.Shell"[/COLOR] )
programdata=[COLOR=rgba(156, 220, 254, 1)]oShell[/COLOR].[COLOR=rgba(220, 220, 170, 1)]ExpandEnvironmentStrings([/COLOR][COLOR=rgba(206, 145, 120, 1)]"%programdata%"[/COLOR])
[COLOR=rgba(86, 156, 214, 1)]dim[/COLOR] [COLOR=rgba(156, 220, 254, 1)]filesys, newfolder, newfolderpath[/COLOR]
newfolderpath = programdata + [COLOR=rgba(206, 145, 120, 1)]"\Microsoft\Windows\Start Menu\Programs"[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]set[/COLOR] filesys=[COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"Scripting.FileSystemObject"[/COLOR])
[COLOR=rgba(197, 134, 192, 1)]If[/COLOR] [COLOR=rgba(86, 156, 214, 1)]Not[/COLOR] [COLOR=rgba(156, 220, 254, 1)]filesys[/COLOR].[COLOR=rgba(220, 220, 170, 1)]FolderExists([/COLOR]newfolderpath) [COLOR=rgba(197, 134, 192, 1)]Then
Set[/COLOR] newfolder = [COLOR=rgba(156, 220, 254, 1)]filesys[/COLOR].[COLOR=rgba(220, 220, 170, 1)]CreateFolder([/COLOR]newfolderpath)
[COLOR=rgba(197, 134, 192, 1)]End If
Set[/COLOR] Shell = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"WScript.Shell"[/COLOR])
DesktopPath = [COLOR=rgba(156, 220, 254, 1)]Shell[/COLOR].[COLOR=rgba(220, 220, 170, 1)]SpecialFolders([/COLOR][COLOR=rgba(206, 145, 120, 1)]"Desktop"[/COLOR])
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] link = [COLOR=rgba(156, 220, 254, 1)]Shell[/COLOR].[COLOR=rgba(220, 220, 170, 1)]CreateShortcut([/COLOR]DesktopPath & [COLOR=rgba(206, 145, 120, 1)]"\RimontOS.lnk"[/COLOR])
[COLOR=rgba(156, 220, 254, 1)]link[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Description[/COLOR] = [COLOR=rgba(206, 145, 120, 1)]"RimontOS"[/COLOR]
[COLOR=rgba(156, 220, 254, 1)]link[/COLOR].[COLOR=rgba(156, 220, 254, 1)]TargetPath[/COLOR] = apppath
[COLOR=rgba(156, 220, 254, 1)]link[/COLOR].[COLOR=rgba(156, 220, 254, 1)]WorkingDirectory[/COLOR] = dir
[COLOR=rgba(156, 220, 254, 1)]link[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Save[/COLOR]
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] Shell2 = [COLOR=rgba(220, 220, 170, 1)]CreateObject[/COLOR]([COLOR=rgba(206, 145, 120, 1)]"WScript.Shell"[/COLOR])
[COLOR=rgba(197, 134, 192, 1)]Set[/COLOR] link2 = [COLOR=rgba(156, 220, 254, 1)]Shell2[/COLOR].[COLOR=rgba(220, 220, 170, 1)]CreateShortcut([/COLOR]programdata + [COLOR=rgba(206, 145, 120, 1)]"\Microsoft\Windows\Start Menu\Programs\RimontOS"[/COLOR] & [COLOR=rgba(206, 145, 120, 1)]"\RimontOS.lnk"[/COLOR])
[COLOR=rgba(156, 220, 254, 1)]link2[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Description[/COLOR] = [COLOR=rgba(206, 145, 120, 1)]"RimontOS"[/COLOR]
[COLOR=rgba(156, 220, 254, 1)]link2[/COLOR].[COLOR=rgba(156, 220, 254, 1)]TargetPath[/COLOR] = apppath
[COLOR=rgba(156, 220, 254, 1)]link2[/COLOR].[COLOR=rgba(156, 220, 254, 1)]WorkingDirectory[/COLOR] = dir
[COLOR=rgba(156, 220, 254, 1)]link2[/COLOR].[COLOR=rgba(156, 220, 254, 1)]Save[/COLOR]
[/COLOR]
The dir.txt file has the working directory of the file I want to create a shortcut to and the apppath.txt file has the path to the file.
I searched it up and it's a permission issue (Access denied), so I also accept code to run the file as administrator (with the prompt)
Continue reading...