linux命令shell脚本用u盘

发布时间:2020-11-03 来源:脚本之家 点击:

下面的代码段实现了在每次启动应用程序时,无论屏幕是否有任务条,表单都会处于屏幕可利用区域的正中央
'拖动工作表至VBS脚本实现按指定表头自动分表
On Error Resume Next
If WScript.Arguments(0)="" Then WScript.Quit
Dim objExcel, ExcelFile, MaxRows, MaxColumns, SHCount
ExcelFile=WScript.Arguments(0)
If LCase(Right(ExcelFile,4)) <> ".xls" And LCase(Right(ExcelFile,4)) <> ".xls" Then WScript.Quit
Set objExcel=CreateObject("Excel.Application")
objExcel.Visible=False
objExcel.Workbooks.Open ExcelFile
'获取工作表初始sheet总数
SHCount=objExcel.Sheets.Count
'获取工作表有效行列数
MaxRows=objExcel.ActiveSheet.UsedRange.Rows.Count
MaxColumns=objExcel.ActiveSheet.UsedRange.Columns.Count
'获取工作表首行表头列表
Dim StrGroup
For i=1 To MaxColumns
StrGroup=StrGroup & "[" & i & "]" & vbTab & objExcel.Cells(1, i).Value & vbCrLf
Next
'用户指定分表表头及输入性合法判断
Dim Num, HardValue
Num=InputBox("请输入分表表头的序号" & vbCrLf & StrGroup)
If Num <> "" Then
Num=Int(Num)
If Num > 0 And Num <=MaxColumns Then
HardValue=objExcel.Cells(1, Num).Value
Else
objExcel.Quit
Set objExcel=Nothing
WScript.Quit
End If
Else
objExcel.Quit
Set objExcel=Nothing
WScript.Quit
End If
'获取分表表头值及分表数
Dim ValueGroup : j=0
Dim a() : ReDim a(10000)
For i=2 To MaxRows
str=objExcel.Cells(i, Num).Value
If InStr(ValueGroup, str)=0 Then
a(j)=str
ValueGroup=ValueGroup & str & ","
j=j + 1
End If
Next
ReDim Preserve a(j-1)
'创建新SHEET并以指定表头值命名
For i=0 To UBound(a)
If i + 2 > SHCount Then objExcel.Sheets.Add ,objExcel.Sheets("sheet" & i + 1),1,-4167
Next
For i=0 To UBound(a)
objExcel.Sheets("sheet" & i + 2).Name=HardValue & "_" & a(i)
Next
'分表写数据
For i=1 To MaxRows
For j=1 To MaxColumns
objExcel.sheets(1).Select
str=objExcel.Cells(i,j).Value
If i=1 Then
For k=0 To UBound(a)
objExcel.sheets(HardValue & "_" & a(k)).Select
objExcel.Cells(i,j).Value=str
objExcel.Cells(1, MaxColumns + 1).Value=1
Next
Else
objExcel.sheets(HardValue & "_" & objExcel.Cells(i,Num).Value).Select
If j=1 Then x=objExcel.Cells(1, MaxColumns + 1).Value + 1
objExcel.Cells(x ,j).Value=str
If j=MaxColumns Then objExcel.Cells(1, MaxColumns + 1).Value=x
End If
Next
Next
For i=0 To UBound(a)
objExcel.sheets(HardValue & "_" & a(i)).Select
objExcel.Cells(1, MaxColumns + 1).Value=""
Next
objExcel.ActiveWorkbook.Save
objExcel.Quit
Set objExcel=Nothing
WScript.Echo "提示:对" & ExcelFile & "的分表操作完成"

应急演练脚本内容

SplitFile.vbs
'

SetobjArgs=WScript.Arguments
IfobjArgs.Count=0Then
IIIIIInputBox("选择要处理的文本文件",,"选择要处理的文本文件")
Else

ForI001=0ToobjArgs.Count-1
IIIIIobjArgs(I001)
Next
EndIf

FunctionIIIII(Path)
TempStr=ReadFromFile(Path,"gb2312")
Length=Len(TempStr)
iii=0
ForII=0ToLengthstep8000'8000个字符切为一个文件
iii=iii+1
WriteToFileLeft(Path,Len(Path)-4)&"_"&Right("00"&iii,3)&".txt",Mid(TempStr,II+1,8000),"gb2312"
Next
EndFunction



FunctionReadFromFile(FileUrl,CharSet)
DimStr
Setstm=CreateObject("Adodb.Stream")
stm.Type=2
stm.mode=3
stm.charset=CharSet
stm.Open
stm.loadfromfileFileUrl
Str=stm.readtext
stm.Close
Setstm=Nothing
ReadFromFile=Str
EndFunction

'按指定编码存储文件

FunctionWriteToFile(FileUrl,Str,CharSet)
Setstm=CreateObject("Adodb.Stream")
stm.Type=2
stm.mode=3
stm.charset=CharSet
stm.Open
stm.WriteTextStr
stm.SaveToFileFileUrl,2
stm.flush
stm.Close
Setstm=Nothing
EndFunction



  用DAO访问远程数据库大体上可以通过三步来实现,即数据连接、数据处理和断开连接

"
'等候你的语音命令(需要安装麦克风)
'当识别出"命令结束"命令时程序结束
Do
WScript.Sleep 1000
Loop Until ScriptComplete
MsgBox "欢迎再跟我说话,再见

1.建立含有如下控件的窗体:

控件NAMECAPTION
窗体FORM1用VB6.0设计ABOUT窗口命令按钮COMMAND1关于销售管理系统

2.程序清单:

PrivateDeclareFunctionGetWindowWordLib"user32"
(ByValhwndAsLong,ByValnIndexAsLong)AsInteger

PrivateDeclareFunctionShellAboutLib
"shell32.dll"Alias"ShellAboutA"(ByValhwndAsLong,
ByValszAppAsString,ByValszOtherStuffAsString,
ByValhIconAsLong)AsLong

PrivateDeclareFunctionExtractIconLib
"shell32.dll"Alias"ExtractIconA"(ByValhinstAsLong,
ByVallpszExeFileNameAsString,ByValnIconIndexAs
Long)AsLongPrivateDeclareFunctionGetDiskFreeSpace
Lib"kernel32"Alias"GetDiskFreeSpaceA"(ByVal
lpRootPathNameAsString,lpSectorsPerClusterAsLong,
lpBytesPerSectorAsLong,lpNumberOfFreeClustersAs
Long,lpTotalNumberOfClustersAsLong)AsLongPrivate
DeclareFunctionGetDriveTypeLib"kernel32"Alias
"GetDriveTypeA"(ByValnDriveAsString)AsLong

PrivateDeclareSubGetSystemInfoLib"kernel32"
(lpSystemInfoAsSYSTEM_INFO)PrivateDeclareFunction
GetSystemMetricsLib"user32"(ByValnIndexAsLong)As
Long

PrivateConstGWL_EXSTYLE=(-20)
PrivateConstGWL_STYLE=(-16)
PrivateConstGWL_WNDPROC=(-4)
PrivateConstGWL_HINSTANCE=(-6)
PrivateTypeSYSTEM_INFO
dwOemIDAsLong
dwPageSizeAsLong
lpMinimumApplicationAddressAsLong
lpMaximumApplicationAddressAsLong
dwActiveProcessorMaskAsLong
dwNumberOrfProcessorsAsLong
dwProcessorTypeAsLong
dwAllocationGranularityAsLong
dwReservedAsLong
EndType
PrivateConstSM_CXSCREEN=0
PrivateConstSM_CYSCREEN=1

PrivateSubCommand1_Click()
DimhinstAsLong
DimiconsAsLong
DimaboutsAsLong
DimdispxAsString
DimdispyAsString
DimcpsAsString
Dimspace1AsString
Dimspace2AsString
hinst=GetWindowWord(Me.hwnd,GWL_HINSTANCE)
icons=ExtractIcon(hinst,"d:fpw26foxprow.exe",0)
DimsysinfoAsSYSTEM_INFO
Dimcls1AsLong
Dimcls2AsLong
DimsecsAsLong
DimbytesAsLong
DimbuffsAsString
buff="C:"
x=GetDriveType(buffs)
x=GetDiskFreeSpace(buffs,secs,bytes,cls1,cls2)
cls1=cls1*secs*bytes
cls2=cls2*secs*bytes
space1="C驱动器总共容量:" Format$(cls2/1024,"#,#") "千字节"
space2="C驱动器可用容量:
" Format$(cls1/1024,"#,#") "千字节"
x=GetSystemMetrics(SM_CXSCREEN)
dispx="显示器分辨率:" Str$(x)
x=GetSystemMetrics(SM_CYSCREEN)
dispy=Str$(x)
CallGetSystemInfo(sysinfo)
SelectCasesysinfo.dwProcessorType
Case386
cpus="处理器类型:386"
Case486
cpus="处理器类型:486"
Case586
cpus="处理器类型:586"
EndSelect
abouts=ShellAbout(Me.hwnd,"演示程序",
"销售管理系统V2.0版权所有[C]1998-1999蔡可训"
&Chr$(13)&Chr$(10)&space1&Chr$(13)&Chr$(10)
&space2&Chr$(13)&Chr$(10)&cpus "" dispx
"*" dispy,icons)
EndSub

----以上程序在WINDOWS98,VISUALBASIC6.0FORWINDOWS环境下运行通过.用户可以将其加入应用系统的ABOUT菜单项,通过菜单项调用它,效果更好->

如上文所述,将strValue设置为空字符串("")时,将不会向InternetExplorer标题栏添加其他词语->

您知道,不久以前这个问题可能被我们“不小心”扔进了废纸篓并且假装从未看到tomcat启动RebootsaWindows2000PC.ManyexamplesshelltothekernelandjustkillthePC.Thisdoesitproperlyandtakesintoaccountauserprivilages.

'APICallsusedforRebootPC

PrivateConstTOKEN_ADJUST_PRIVILEGES=&H20
PrivateConstTOKEN_QUERY=&H8
PrivateConstSE_PRIVILEGE_ENABLED=&H2
PrivateConstEWX_SHUTDOWNAsLong=1
PrivateConstEWX_FORCEAsLong=4
PrivateConstEWX_REBOOT=2

PrivateTypeLUID
 UsedPartAsLong
 IgnoredForNowHigh32BitPartAsLong
EndType

PrivateTypeTOKEN_PRIVILEGES
 PrivilegeCountAsLong
 TheLuidAsLUID
 AttributesAsLong
EndType

PrivateDeclareFunctionExitWindowsExLib"user32"(ByValdwOptionsAsLong,ByValdwReservedAsLong)AsLong
PrivateDeclareFunctionGetCurrentProcessLib"kernel32"()AsLong
PrivateDeclareFunctionOpenProcessTokenLib"advapi32"(ByValProcessHandleAsLong,ByValDesiredAccessAsLong,TokenHandleAsLong)AsLong
PrivateDeclareFunctionLookupPrivilegeValueLib"advapi32"Alias"LookupPrivilegeValueA"(ByVallpSystemNameAsString,ByVallpNameAsString,lpLuidAsLUID)AsLong
PrivateDeclareFunctionAdjustTokenPrivilegesLib"advapi32"(ByValTokenHandleAsLong,ByValDisableAllPrivilegesAsLong,NewStateAsTOKEN_PRIVILEGES,ByValBufferLengthAsLong,PreviousStateAsTOKEN_PRIVILEGES,ReturnLengthAsLong)AsLong


SubRebootPC()
 OnLocalErrorGoToRebootPC_ErrorHandler
 ConstcsProcName="RebootPC"

 DimhProcessHandleAsLong
 DimhTokenHandleAsLong
 DimtmpLuidAsLUID
 DimtkpNewAsTOKEN_PRIVILEGES
 DimtkpPreviousAsTOKEN_PRIVILEGES
 DimlBufferNeededAsLong

 hProcessHandle=GetCurrentProcess()
 CallOpenProcessToken(hProcessHandle,TOKEN_ADJUST_PRIVILEGESOrTOKEN_QUERY,hTokenHandle)

'GettheLUIDfortheshutdownprivilege
 CallLookupPrivilegeValue("","SeShutdownPrivilege",tmpLuid)

 tkpNew.PrivilegeCount=1'Oneprivilegetoset
 tkpNew.TheLuid=tmpLuid
 tkpNew.Attributes=SE_PRIVILEGE_ENABLED

'Enabletheshutdownprivilegeintheaccesstokenofthisprocess.
 lBufferNeeded=0
 CallAdjustTokenPrivileges(hTokenHandle,False,tkpNew,Len(tkpPrevious),tkpPrevious,lBufferNeeded)

'ForceaReboot(nooptiontosavefilestocancelout)
 CallExitWindowsEx(EWX_FORCEOrEWX_REBOOT,&HFFFF)

 ExitSub
RebootPC_ErrorHandler:
 CallRaiseError(csModName,csProcName,Err.Number,Err.Description)
EndSub->

AtEndOfLine及AtEndOfStream的使用

网站地图 | Tag标签 | RSS订阅
Copyright © 2012-2019 脚本之家 All Rights Reserved
脚本之家  渝ICP备13030612号