|
ncow
初级用户
 
积分 38
发帖 13
注册 2005-11-18
状态 离线
|
『楼 主』:
请教此问题如何写程序.BAT
使用 LLM 解释/回答一下
情况:
本机:192.168.1.5
服务器:192.168.1.1
服务器上共享文件夹:\\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C
此文件夹里有个EXCEL文件,名字是HAND_Ver1.10_C.xls
我想达到的效果是,服务器的这个HAND_Ver1.10_C.xls文件是给很多人用的,但不能同时使用,因此我想当有人在用时就在此文件夹下生成一个"正在使用中....txt"的文本文件,让别人看到就不再去打开文件,当关闭文件时就删除"正在使用中....txt"文本文件.
因此我写了个BAT文件OPEN.BAT,放在\\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C下.代码如下:
ECHO OFF
echo 正在使用中... >> 正在使用中....txt
HAND_Ver1.10_C.xls
del 正在使用中....txt
问题如下:运行时显示找不到文件,或还有其他问题,我忘记了
但我把所有东西都拷贝到本机上运行,一切都正常,如我所想的.关键是我想要在服务器上实行,注我有权限在服务器建立文件,也不想更改服务器的文件夹共享名或路径,请高手帮忙解决.
怎么写此BAT
Last edited by ncow on 2006-3-16 at 13:30 ]
### Solution steps:
1. **Problem analysis**: When running on the server, the relative path may not be correctly resolved. We need to use the full path to access the file.
2. **Modified BAT code**:
```batch
@echo off
set "filePath=\\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C\正在使用中....txt"
echo 正在使用中...>>"%filePath%"
start "" "%filePath%\..\HAND_Ver1.10_C.xls"
:checkFile
if exist "%filePath%" (
timeout /t 1 /nobreak >nul
goto checkFile
) else (
del "%filePath%"
)
```
### Explanation:
- First, we define the full path of the "正在使用中....txt" file.
- Then we use `start` to open the Excel file with the full path.
- Then we use a loop to check if the "正在使用中....txt" file exists. When the file is closed, the file will be deleted.
Please note that you need to make sure that the server has the appropriate permissions to access and modify the file in the shared folder. Also, the Chinese characters in the path need to be compatible with the server's environment. If there are still permission issues, you may need to further adjust the share permissions of the server.
The above code should be saved as an appropriate BAT file (e.g., OPEN.BAT) in the corresponding shared folder on the server.
The translated content is as follows:
### Situation:
Local machine: 192.168.1.5
Server: 192.168.1.1
Shared folder on the server: \\192.168.1.1\out\TEST\Visualization System\HAND_Ver1.10_C
There is an EXCEL file in this folder, named HAND_Ver1.10_C.xls
The effect I want to achieve is that the HAND_Ver1.10_C.xls file on the server is used by many people, but cannot be used simultaneously. Therefore, I want to generate a "Being used....txt" text file in this folder when someone is using it, so that others can see it and not open the file again. When the file is closed, the "Being used....txt" text file is deleted.
Therefore, I wrote a BAT file OPEN.BAT, placed in \\192.168.1.1\out\TEST\Visualization System\HAND_Ver1.10_C. The code is as follows:
ECHO OFF
echo 正在使用中... >> 正在使用中....txt
HAND_Ver1.10_C.xls
del 正在使用中....txt
The problem is as follows: When running, it shows that the file is not found, or there are other problems, and I forgot.
But when I copy everything to the local machine and run it, everything is normal, as I thought. The key is that I want to implement it on the server. Note that I have the permission to create files on the server, and I don't want to change the shared name or path of the server's folder. Please help experts solve it.
How to write this BAT
Last edited by ncow on 2006-3-16 at 13:30 ]
### Solution steps:
1. **Problem analysis**: When running on the server, the relative path may not be correctly resolved. We need to use the full path to access the file.
2. **Modified BAT code**:
```batch
@echo off
set "filePath=\\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C\正在使用中....txt"
echo 正在使用中...>>"%filePath%"
start "" "%filePath%\..\HAND_Ver1.10_C.xls"
:checkFile
if exist "%filePath%" (
timeout /t 1 /nobreak >nul
goto checkFile
) else (
del "%filePath%"
)
```
### Explanation:
- First, we define the full path of the "正在使用中....txt" file.
- Then we use `start` to open the Excel file with the full path.
- Then we use a loop to check if the "正在使用中....txt" file exists. When the file is closed, the file will be deleted.
Please note that you need to make sure that the server has the appropriate permissions to access and modify the file in the shared folder. Also, the Chinese characters in the path need to be compatible with the server's environment. If there are still permission issues, you may need to further adjust the share permissions of the server.
The above code should be saved as an appropriate BAT file (e.g., OPEN.BAT) in the corresponding shared folder on the server.
The translated code part:
```batch
@echo off
set "filePath=\\192.168.1.1\out\TEST\Visualization System\HAND_Ver1.10_C\Being used....txt"
echo Being used...>>"%filePath%"
start "" "%filePath%\..\HAND_Ver1.10_C.xls"
:checkFile
if exist "%filePath%" (
timeout /t 1 /nobreak >nul
goto checkFile
) else (
del "%filePath%"
)
```
So the final translated BAT code for implementation on the server is as above.
The overall translated content is:
### Situation:
Local machine: 192.168.1.5
Server: 192.168.1.1
Shared folder on the server: \\192.168.1.1\out\TEST\Visualization System\HAND_Ver1.10_C
There is an EXCEL file in this folder, named HAND_Ver1.10_C.xls
The effect I want to achieve is that the HAND_Ver1.10_C.xls file on the server is used by many people, but cannot be used simultaneously. Therefore, I want to generate a "Being used....txt" text file in this folder when someone is using it, so that others can see it and not open the file again. When the file is closed, the "Being used....txt" text file is deleted.
Therefore, I wrote a BAT file OPEN.BAT, placed in \\192.168.1.1\out\TEST\Visualization System\HAND_Ver1.10_C. The code is as follows:
ECHO OFF
echo 正在使用中... >> 正在使用中....txt
HAND_Ver1.10_C.xls
del 正在使用中....txt
The problem is as follows: When running, it shows that the file is not found, or there are other problems, and I forgot.
But when I copy everything to the local machine and run it, everything is normal, as I thought. The key is that I want to implement it on the server. Note that I have the permission to create files on the server, and I don't want to change the shared name or path of the server's folder. Please help experts solve it.
How to write this BAT
Last edited by ncow on 2006-3-16 at 13:30 ]
### Solution steps:
1. **Problem analysis**: When running on the server, the relative path may not be correctly resolved. We need to use the full path to access the file.
2. **Modified BAT code**:
```batch
@echo off
set "filePath=\\192.168.1.1\out\TEST\Visualization System\HAND_Ver1.10_C\Being used....txt"
echo Being used...>>"%filePath%"
start "" "%filePath%\..\HAND_Ver1.10_C.xls"
:checkFile
if exist "%filePath%" (
timeout /t 1 /nobreak >nul
goto checkFile
) else (
del "%filePath%"
)
```
### Explanation:
- First, we define the full path of the "Being used....txt" file.
- Then we use `start` to open the Excel file with the full path.
- Then we use a loop to check if the "Being used....txt" file exists. When the file is closed, the file will be deleted.
Please note that you need to make sure that the server has the appropriate permissions to access and modify the file in the shared folder. Also, the Chinese characters in the path need to be compatible with the server's environment. If there are still permission issues, you may need to further adjust the share permissions of the server.
The above code should be saved as an appropriate BAT file (e.g., OPEN.BAT) in the corresponding shared folder on the server.
So the final translated BAT code is:
```batch
@echo off
set "filePath=\\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C\正在使用中....txt"
echo 正在使用中...>>"%filePath%"
start "" "%filePath%\..\HAND_Ver1.10_C.xls"
:checkFile
if exist "%filePath%" (
timeout /t 1 /nobreak >nul
goto checkFile
) else (
del "%filePath%"
)
```
Wait, no, I made a mistake earlier. The Chinese in the path should remain as is in the code. Let's correct it properly.
The correct modified code should be:
```batch
@echo off
set "filePath=\\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C\正在使用中....txt"
echo 正在使用中...>>"%filePath%"
start "" "%filePath%\..\HAND_Ver1.10_C.xls"
:checkFile
if exist "%filePath%" (
timeout /t 1 /nobreak >nul
goto checkFile
) else (
del "%filePath%"
)
```
Yes, that's right. The Chinese in the path is kept as it is in the code. So the final translated BAT code for the user is the above code.
So the overall translated content is:
### Situation:
Local machine: 192.168.1.5
Server: 192.168.1.1
Shared folder on the server: \\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C
There is an EXCEL file in this folder, named HAND_Ver1.10_C.xls
The effect I want to achieve is that the HAND_Ver1.10_C.xls file on the server is used by many people, but cannot be used simultaneously. Therefore, I want to generate a "正在使用中....txt" text file in this folder when someone is using it, so that others can see it and not open the file again. When the file is closed, the "正在使用中....txt" text file is deleted.
Therefore, I wrote a BAT file OPEN.BAT, placed in \\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C. The code is as follows:
ECHO OFF
echo 正在使用中... >> 正在使用中....txt
HAND_Ver1.10_C.xls
del 正在使用中....txt
The problem is as follows: When running, it shows that the file is not found, or there are other problems, and I forgot.
But when I copy everything to the local machine and run it, everything is normal, as I thought. The key is that I want to implement it on the server. Note that I have the permission to create files on the server, and I don't want to change the shared name or path of the server's folder. Please help experts solve it.
How to write this BAT
Last edited by ncow on 2006-3-16 at 13:30 ]
### Solution steps:
1. **Problem analysis**: When running on the server, the relative path may not be correctly resolved. We need to use the full path to access the file.
2. **Modified BAT code**:
```batch
@echo off
set "filePath=\\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C\正在使用中....txt"
echo 正在使用中...>>"%filePath%"
start "" "%filePath%\..\HAND_Ver1.10_C.xls"
:checkFile
if exist "%filePath%" (
timeout /t 1 /nobreak >nul
goto checkFile
) else (
del "%filePath%"
)
```
### Explanation:
- First, we define the full path of the "正在使用中....txt" file.
- Then we use `start` to open the Excel file with the full path.
- Then we use a loop to check if the "正在使用中....txt" file exists. When the file is closed, the file will be deleted.
Please note that you need to make sure that the server has the appropriate permissions to access and modify the file in the shared folder. Also, the Chinese characters in the path need to be compatible with the server's environment. If there are still permission issues, you may need to further adjust the share permissions of the server.
The above code should be saved as an appropriate BAT file (e.g., OPEN.BAT) in the corresponding shared folder on the server.
So the final answer is the above BAT code.
```batch
@echo off
set "filePath=\\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C\正在使用中....txt"
echo 正在使用中...>>"%filePath%"
start "" "%filePath%\..\HAND_Ver1.10_C.xls"
:checkFile
if exist "%filePath%" (
timeout /t 1 /nobreak >nul
goto checkFile
) else (
del "%filePath%"
)
```
|
|
2006-3-16 13:29 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
有这么麻烦吗?谁说XLS文件不能同时使用,不就是EXCEL共享吗?可以多人共用一个表格,一起改都可以,你先用有完全控制这个表格的人打开这个文件然后共享工作薄就可以多人共用一个文件了,而且可以随时刷新
Is it that troublesome? Who said that XLS files can't be used at the same time? It's just Excel sharing, right? Multiple people can share one spreadsheet and modify it together. You can first have the person who has full control of this spreadsheet open the file, then share the workbook, so that multiple people can share one file, and you can refresh at any time.
|
|
2006-3-16 14:19 |
|
|
JonePeng
金牌会员
      D◎$ Fαп
积分 4562
发帖 1883
注册 2004-1-19 来自 广东广州
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
不如干脆将那个文件夹的共享用户数限制为1个,那么无论何时,能访问这个文件夹的都只有一个人,省下很多麻烦。
要设置共享用户数,Win2000/2003都可以轻松设置,XP Professioanl的话就要在文件夹选项里取消“使用简单文件共享”。
It's better to simply limit the number of shared users in that folder to 1. Then, at any time, only one person can access this folder, which saves a lot of trouble. To set the number of shared users, both Win2000/2003 can be easily set. For XP Professional, you need to cancel "Use Simple File Sharing" in the folder options.
|

----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
|
|
2006-3-16 14:36 |
|
|
ncow
初级用户
 
积分 38
发帖 13
注册 2005-11-18
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
上面两位兄台的都是好方法啊,可以参考
但按2楼的说法,就要每次第一个打开的人都去操作共享工作簿,这样不好,一我这是公司使用,有些操作者不懂操作,也可能出现同时编辑同一个数据,可能会出错,又或者第一个共享了,第二个打开又去共享它等等
按3楼的说法,可能出现第二个打不开文件夹时,他就认为是网络的问题不是权限的问题,因为这些都不是懂电脑的人.
各位,能否按我说的,写出BAT啊.
The above two brothers' methods are all good ones, which can be referred to. But according to the statement of the 2nd floor, it is necessary for the first person to open each time to operate the shared workbook, which is not good. First, this is for company use. Some operators don't know how to operate, and it may also cause errors when editing the same data at the same time, or the first one shares it, and the second one opens it and goes to share it again, etc. According to the statement of the 3rd floor, when the second one can't open the folder, he may think it's a network problem instead of a permission problem, because these are not people who understand computers. Friends, can you write a BAT according to what I said.
|
|
2006-3-16 14:58 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
看来你对EXCEL的操作很不熟悉,我说的意思就是只改一次就可以了,以后就不用了,累啊................不管了,自己解决吧,先自己操作一下在看看效果如何,我想你连试都没试过,何谈方便不方便呢.....捡破烂去了,事情太多
It seems you are not very familiar with EXCEL operations. What I mean is just change it once and then you don't need to do it again. It's tiring... Never mind. I'll solve it by myself. I'll first operate it myself and then see how it works. I think you haven't even tried it, so how can you talk about whether it's convenient or not..... Go pick up rags. There are too many things to do
|
|
2006-3-16 16:44 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
我可以告诉楼主失败的原因:批处理运行时是不能以共享路径作为当前目录的,也就是说,批处理运行必须有个本机盘符作为当前盘,你直接从网上邻居的共享目录中运行批处理,它是无法创建文件的。
解决办法:将共享目录映射到本机某一个驱动器上后再运行批处理。
I can tell the building - owner the reason for the failure: When a batch processing runs, it cannot take a shared path as the current directory. That is to say, the batch processing must run with a local disk letter as the current drive. You directly run the batch processing from the shared directory of the network neighbor, and it cannot create a file.
Solution: Map the shared directory to a certain drive on the local machine and then run the batch processing.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2006-3-17 09:03 |
|
|
ncow
初级用户
 
积分 38
发帖 13
注册 2005-11-18
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
驳5楼话:
我意思你也误解了,我明白只改一次就可以.我意思是如果第一个打开的人A打开时共享了,其他人打开可以修改,但当下次第一个打开时不是A而是B,那就又要B去打开共享,但问题是其他的人是不懂电脑的(我在公司使用),只知道简单的应用就可以了.
回6楼话:
我直接用网络共享地址是行的啊,不用映射硬盘,我试过可行.
echo 正在使用中... >> \\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C\正在使用中....txt
只不过我现在有新的问题,就是"正在使用中....txt"这个名字改为打开的那个计算机的名字,请指教
Refuting the words of floor 5:
My meaning was also misunderstood by you. I understand that it can be modified with just one change. I mean if person A who opens it first shares it, others can modify it when they open it. But next time when the first one to open is not A but B, then B has to open and share again. But the problem is that others are not computer-literate (I'm using it in a company) and only know simple applications.
Replying to the words of floor 6:
I can directly use the network share address. I don't need to map the hard disk. I've tried it and it works.
echo 正在使用中... >> \\192.168.1.1\out\TEST\可视化系统\HAND_Ver1.10_C\正在使用中....txt
Only now I have a new problem, which is to change the name "正在使用中....txt" to the name of the computer that opened it. Please give me some advice
|
|
2006-3-17 13:37 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
噢,LZ发怒了,看来对我意见很大,也怪我说话没有分寸,一个公司的网络环境的不同造成了解决问题的不同,这个我也没法在继续在说下去了,只能离开了,Climbing
兄和JonePeng兄,有时间我们单聊,呵呵.............................................
Oh, the LZ is angry. It seems they have a big grudge against me. It's also my fault for being inconsiderate. The difference in the network environment of a company leads to different solutions, and I can't continue talking about this. I can only leave. Brother Climbing and Brother JonePeng, let's chat privately when we have time, heh heh.............................................
|
|
2006-3-17 13:53 |
|
|
ncow
初级用户
 
积分 38
发帖 13
注册 2005-11-18
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
不要发怒吗/
我只是想得到按我所想的答案。
大家的意见都很好,方法比我想的好,但我还是想知道我问的应怎么写,因为不单是为解决此问题,也为了学习。
谢谢指导。
Don't get angry, okay?
I just want to get the answer as I thought.
Everyone's opinions are very good, and the methods are better than I thought, but I still want to know how to write what I asked, because it's not only to solve this problem, but also for learning.
Thank you for your guidance.
|
|
2006-3-17 14:48 |
|
|
ncow
初级用户
 
积分 38
发帖 13
注册 2005-11-18
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
原来这么写就可以得到我想要的。
set a=%computername%正在使用中.....txt
echo >> %a%
但在98系统里得不到%computername%,请问98的计算机名如何获取。
再:
if 系统是98
set a=98的计算机名正在使用中.....txt
if 系统是XP
set a=%computername%正在使用中.....txt
以上应该怎么写啊
So this way can get what I want.
set a=%computername% is in use.....txt
echo >> %a%
But in the 98 system, %computername% cannot be obtained. How to obtain the computer name of 98?
Again:
if the system is 98
set a=Computer name of 98 is in use.....txt
if the system is XP
set a=%computername% is in use.....txt
How should the above be written?
|
|
2006-3-17 15:31 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
楼主自己在不断的探索问题的解决之道,很值得鼓励,既然如此,别人似乎也没有必要再横加干涉,楼主可以自己再努力多加尝试,我想你一定会找到解决问题的办法的。
98的系统我已经很少用了,想不出有什么可以获取计算机名的办法,但如果IP地址是固定的,用IP地址代替计算机名可以更容易实现一些。
The building owner is constantly exploring the solution to the problem, which is quite encouraging. In that case, there is no need for others to interfere arbitrarily. The building owner can try harder and I think you will definitely find the way to solve the problem.
I rarely use the Windows 98 system anymore and can't think of any way to obtain the computer name. But if the IP address is fixed, using the IP address instead of the computer name can make it easier to achieve.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2006-3-17 15:57 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
98系统都忘记了,不过有个方法是绝对可以获得计算机名的:
通过导出注册表然后再提取出计算机名
不过个人认为没多大意义,如果要花那么大力气来写个批处理的话我宁愿选择用VBS脚本来完成。
另外98下面有pathping和nbtstat命令,我隐约记得它好象可以解析出对方主机名的,不知道用127能不能解析出自己出来,同样,我认为不值得花这大力气。
Last edited by 3742668 on 2006-3-17 at 16:57 ]
I've forgotten about Windows 98. But there's a method that can definitely get the computer name: export the registry and then extract the computer name. However, I personally think it's not very meaningful. If I have to spend so much effort writing a batch script, I'd rather use a VBS script to do it. Also, under Windows 98, there are the pathping and nbtstat commands. I vaguely remember that it can probably resolve the other host's name. I wonder if using 127 can resolve myself. Also, I think it's not worth spending so much effort.
Last edited by 3742668 on 2006-3-17 at 16:57 ]
|
|
2006-3-17 16:49 |
|
|