這裏是通過分批和VBS混合桌面的手動改變。它並不完美,但它提供了移入和移出目錄以選擇要更新的目錄之間的一個很好的界面。 這使用我想用其他東西貶低的taskkill。
這是最初的批處理腳本...
@echo off
setlocal enableextensions
::Below computes the desktop location that the program will reference
for /f %%a in ('cscript //nologo C:\HighestPrivelege\DesktopTools\findDesktop.vbs') do set "fold=%%a"
echo %fold%
::this loop will allow users to input new locations for the desktop by
moving through a terminal. Wildcards and autotab completion is usable are
and lack of input results in continuation of script
:loop
echo ################## %fold%
dir %fold% /A:D /B
echo _________________________
set loc=
set /p loc=[New Location?]
cd %fold%\%loc%
set fold=%cd%
IF [%loc%]==[] (goto cont) ELSE (goto loop)
:cont
::Below is the program that runs the regedit rewrite of the desktop variable
for the current user. It passes the decided folder value from earlier as the
new desktop.
cscript //nologo C:\HighestPrivelege\DesktopTools\setdesktop.vbs %fold%
::This restarts explorer.exe in order to reboot the newly created desktop
location. I wish i didnt have to kill explorer.exe forcefully in the process
but so far its the only way to make this program work.
taskkill /F /IM explorer.exe
explorer.exe
endlocal
pause
exit
和下面的VBS腳本...
Option Explicit
'variable invocation
Dim objShell, strDesktop, strModify, strDelete, fso, f, File, content, parthe, args, arg1
Set args = WScript.Arguments
set objShell = CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
'this will take in the new desktop location.
set file= fso.OpenTextFile("C:\HighestPrivelege\DesktopTemporary.txt")
content = file.ReadAll
arg1 = args.Item(0)
parthe = ""&arg1&""
'The actual rewrite of the registry file containing the script lies below.
strDesktop = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop"
strModify = objShell.RegWrite(strDesktop,parthe,"REG_EXPAND_SZ")
激活批處理腳本會提示用戶輸入他們希望在哪裏將其桌面重定位到,並將該變量傳遞到VBscript中以重新編寫到註冊表中。在VBScript完成後,Windows資源管理器將自行重新啓動,以重新初始化新的桌面位置。
直到我可以得到一個工作模型,我必須做的是點擊/與文件夾進行初始化程序的交互,本手冊將不得不做。
我認爲你正在尋找的術語是「shell擴展」,但我不確定是否可以覆蓋任何類型的桌面文件夾的默認行爲(打開)。 – Filburt
'如果我能找到在註冊表編輯器中傳遞了什麼變量'是什麼讓您認爲註冊表與打開桌面上的文件夾有關? –
我可能會做一個廉價的修復,一旦資源管理器打開文件,有一個腳本複製該路徑,並在關閉Windows資源管理器時在其周圍重新創建vbs文件。 至於我「假設」它與註冊表有關,有一些explorer.exe在註冊表中被調用的實例,這是用於在程序中可視化移動的同一個可執行文件。如果你願意,我可以告訴你這些我感興趣的實例和這個話題。 – Jouster500