本帖最后由 pcl_test 于 2015-5-17 10:17 编辑
回复 16# 7016427
分别运行下面两段代码,看看是否都能获取到日期- @echo off
- for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value') do set "t=%%a"
- set "y=%t:~0,4%"
- set "m=%t:~4,2%"
- if %m:~,1% equ 0 set "m=%m:~-1%"
- set d=%t:~6,2%
- if %d:~,1% equ 0 set "m=%d:~-1%"
- set "getdate=%y%/%m%/%d%"
- echo 当前系统日期为%getdate%
- pause
复制代码 表格的存放路径要正确D:\aa\542.xls- ' 2>nul 3>nul&@echo off&cls
- '&for /f "delims=" %%b in ('cscript -nologo -e:vbscript "%~fs0"') do set "xlsdate=%%b"
- '&echo xls表格的日期为%xlsdate%
- '&pause&exit
- Dim oExcel,oWb,oSheet
- Set oExcel= CreateObject("Excel.Application")
- Set oWb = oExcel.Workbooks.Open("D:\aa\542.xls")
- Set oSheet = oWb.Sheets("Sheet1")
- Wscript.echo oSheet.Range("E2").Value
复制代码
|