Board logo

标题: 文件正在使用无法压缩问题 [打印本页]

作者: qwertl     时间: 2008-8-19 09:27    标题: 文件正在使用无法压缩问题

文件正在使用无法压缩成功的问题可否用批处理来解决呢?

需要压缩的是一个共享目录,VFP开发的dbf文件,程序也一起,一般是下班时批处理执行,没有工作站连接也会有dbf打开而无法压缩,要怎样可以较顺利执行呢?
作者: HAT     时间: 2008-8-19 09:30
dbf是数据库文件吧?压缩之前先把数据库restart一下,这样就可以断开所有的session了,可行吗?
作者: qwertl     时间: 2008-8-19 09:43
DBF好象无法通过停用什么服务来中止,要通过vfp的语句来关闭打开的DBF??
作者: HAT     时间: 2008-8-19 09:46
DBF是不是数据库文件?
什么进程会去访问DBF?
作者: qwertl     时间: 2008-8-19 09:55
是数据库文件,我这是通过VFP自开发的程序打开它,但有时程序都退出了,但dbf还在打开的,
作者: HAT     时间: 2008-8-19 10:51

找个VFP高手看看程序是不是有bug?
程序退出的时候没有断开数据库连接?
程序退出以后任务管理器里面还有没有相应的进程?

作者: qwertl     时间: 2008-8-28 10:18
rar.exe

开关 -DH - 打开共享的文件


--------------------------------------------------------------------------------


允许处理由其它应用程序打开来写入的文件。

如果应用程序允许度去访问文件时,这个开关有用,但是如果文件的所有访问类型都被禁止,文件打开操作仍然会失败。

此开关是有危险性的,因为它允许添加文件到压缩文件,而文件可能正由其它应用程序进行修改中。使用时请小心。

如果未指定此开关,则依据在 压缩配置 的“打开共享的文件”选项设置而定。

例子:

WinRAR a -dh dbf *.dbf
作者: HAT     时间: 2008-8-28 10:22
数据库文件不建议这样做,除非这个数据库文件你自己拿来玩玩而已的。
作者: qwertl     时间: 2008-8-28 10:52
有没有批处理语名可以将网络连接断开,执行完备份后批处理再连通网络连接??
作者: moniuming     时间: 2008-8-28 11:38


  Quote:
Originally posted by qwertl at 2008-8-28 10:52:
有没有批处理语名可以将网络连接断开,执行完备份后批处理再连通网络连接??

rasphone /?
rasdial /?
作者: qwertl     时间: 2008-8-28 11:39
现是说本地连接
作者: HAT     时间: 2008-8-28 11:46
应该是说数据库连接吧?
作者: qwertl     时间: 2008-8-28 13:30
求批处理语名可以将网卡本地连接网络连接断开,执行完备份后批处理再连通网络连接.网络连接断开了,数据库就断开了,晚上的时候也没人连接的.
作者: knoppix7     时间: 2008-8-28 13:48
找个Unlocker程序挂上.
作者: HAT     时间: 2008-8-28 13:48
转帖
@echo off
rem 适用于Win2003
rem 把Win2003的ifmon.dll拷贝到WinXP以后WinXP也可以用
rem 禁用本地连接
netsh interface set interface name="本地连接" admin=DISABLED
rem 启用本地连接
netsh interface set interface name="本地连接" admin=ENABLED

@echo off
rem 用批处理调用devcon.exe来实现
echo 请输入你的选择:(禁用网卡为N,启用为Y)
set/p SELECT=
if /i %SELECT%==Y set SELECT=ENABLE&GOTO :DO
if /i %SELECT%==N set SELECT=DISABLE
:DO
for /f "tokens=2 delims=&" %%i in ('devcon find pci\* ^| findstr "Fast Ethernet"') do devcon %SELECT% *%%i*>NUL

devcon.exe
http://upload.cn-dos.net/img/496.zip

'XP下可以用VBS来实现

Const ssfCONTROLS = 3  
sConnectionName = "本地连接"  '可改成需要控制的连接名称,如"无线网络连接"等  
sEnableVerb = "启用(&A)"  
sDisableVerb = "停用(&B)"    非xp 系统可能 是禁用
set shellApp = createobject("shell.application")  
set oControlPanel = shellApp.Namespace(ssfCONTROLS)  
set oNetConnections = nothing  
for each folderitem in oControlPanel.items  
if folderitem.name  = "网络连接" then  
   set oNetConnections = folderitem.getfolder: exit for  
end if  
next  
if oNetConnections is nothing then  
msgbox "未找到网络连接文件夹"  
wscript.quit  
end if  
set oLanConnection = nothing  
for each folderitem in oNetConnections.items  
if lcase(folderitem.name)  = lcase(sConnectionName) then  
   set oLanConnection = folderitem: exit for  
end if  
next  
if oLanConnection is nothing then  
msgbox "未找到 '" & sConnectionName & "' item"  
wscript.quit  
end if  
bEnabled = true  
set oEnableVerb = nothing  
set oDisableVerb = nothing  
s = "Verbs: " & vbcrlf  
for each verb in oLanConnection.verbs  
s = s & vbcrlf & verb.name  
if verb.name = sEnableVerb then   
   set oEnableVerb = verb   
   bEnabled = false  
end if  
if verb.name = sDisableVerb then   
   set oDisableVerb = verb   
end if  
next  
'debugging displays left just in case...  
'  
'msgbox s ': wscript.quit  
'msgbox "Enabled: " & bEnabled ': wscript.quit  
'not sure why, but invokeverb always seemed to work   
'for enable but not disable.   
'  
'saving a reference to the appropriate verb object   
'and calling the DoIt method always seems to work.  
'  
if bEnabled then  
'  oLanConnection.invokeverb sDisableVerb  
oDisableVerb.DoIt  
else  
'  oLanConnection.invokeverb sEnableVerb  
oEnableVerb.DoIt  
end if  
'adjust the sleep duration below as needed...  
'  
'if you let the oLanConnection go out of scope  
'and be destroyed too soon, the action of the verb  
'may not take...  
'  
wscript.sleep 400

作者: HAT     时间: 2008-8-28 13:50
我倒是觉得与其断网,还不如重启数据库。
作者: qwertl     时间: 2008-8-30 01:16
小工具之DEVCON.EXE

  DevCon实用工具是一种命令行实用工具,可以替代设备管理器。使用 DevCon,我们可以启用、禁用、重新启动、更新、删除和查询单个设备或一组设备。DevCon还提供与驱动程序开发人员有关、但无法在设备管理器中看到的信息。

  下面笔者以实现开关本机网卡为例进行介绍。

  第一步:通过设备管理器查询本机网卡的名称,然后在其上点鼠标右键选择“属性”。

  第二步:在打开的网卡属性窗口点“详细信息”标签,在这里我们可以看到“设备范例ID”下面显示的一行字样,在此行字样中找到DEV,然后记录后面的信息,例如笔者的是DEV_1031。

  第三步:将通过上面地址下载的devcon.exe程序复制到C:\windows\system32。

  第四步:在实际使用过程中我们通过以下命令实现对设备的开关,这些指令可以直接在命令提示窗口中输入也可以直接放到批处理文件中执行。

  devcon disable *DEV_1031* 禁用DEV1031设备

  devcon enable *DEV_1031* 启用DEV1031设备。

  实际上devcon不光可以开关网卡设备,我们应该知道在操作系统中各个设备都有一个DEV值,对于大多数设备我们可以通过设备管理器查询他的DEV值,然后通过devcon实现对其的开启与关闭。