-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shell.hta
813 lines (711 loc) · 23.5 KB
/
Shell.hta
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
<html lang="zh_CN">
<head>
<title>Visual Basic Script Shell</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<HTA:APPLICATION
APPLICATIONNAME="VBScript Shell"
ID="oMSHTA"
VERSION="1.0"
INNERBORDER="no"/>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
border: 0;
padding: 0;
/*自动滚动条显示*/
overflow-y: auto;
overflow-x: auto;
/*自动换行*/
word-wrap: break-word;
word-break: break-all;
}
p {
margin: 0px;
}
#Console {
background-color: #222222;
color: white;
font-family: 'Microsoft yahei mono',Consolas,'Microsoft YaHei';
letter-spacing: 0px;
font-size: 1.2em;
line-height: 1.2em;
height: 100%;
position: relative;
margin: 0 auto;
border: 10px solid black;
padding: 0;
}
</style>
</head>
<body onClick="SetFocus()" onKeyPress="OnKeyPress()">
<div id="Console">
<span style="color: LightBlue;display: inline-block;white-space:nowrap;">
VBScript Shell
</span>
  Version: 0.4 beta
<p>Copyright 2020 OldLiu TECH_N00b 小肥羊</p>
<div Id="InputArea_0">
<span style="color: LightGreen;">
VBScript
</span>
>
<span id="SingleLineInputer_0" contentEditable="True" oncompositionend="AutoHighLight();"></span>
<div id="MultiLineInputer_0" contentEditable="False"></div>
</div>
</div>
<script>var JsCodeRunner = eval;</script>
<script language="VBScript">
'Option Explicit
Const ERR_MODULE_FILE_NOT_FOUND = 1
Const ERR_MODULE_OBJECT_COLOR_NOT_FOUND = 2
Const ERR_MODULE_COLOR_PROFILE_NOT_FOUND = 3
Const ERR_MODULE_COLOR_PROFILE_INCORRECT = 4
Rem 加载Core。
Import "TextOutPut.js"
Import "WScript.js"
Import "Preference.vbs"
ReadColorProfile "Preference\DefaultColor.crp"
Import "HighLight.vbs" '语法高亮模块
Sub Import(ByVal strScriptFilePath)
Dim objFileSystem
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Dim strHtaPath
strHtaPath = objFileSystem.GetParentFolderName(location.pathname)
Rem Libraries与Core中有同名文件时,将会载入Core中的文件。
If UCase(objFileSystem.GetExtensionName(strScriptFilePath)) = "VBS" Then
If objFileSystem.FileExists(strHtaPath & "\Libraries\VBScript\" & strScriptFilePath) Then
strScriptFilePath = strHtaPath & "\Libraries\VBScript\" & strScriptFilePath
End If
If objFileSystem.FileExists(strHtaPath & "\Core\VBScript\" & strScriptFilePath) Then
strScriptFilePath = strHtaPath & "\Core\VBScript\" & strScriptFilePath
End If
If Not objFileSystem.FileExists(strScriptFilePath) Then
Err.Raise ERR_MODULE_FILE_NOT_FOUND,"库未找到","Import未找到您指定的文件",""
Exit Sub
End If
ExecuteGlobal objFileSystem.OpenTextFile(strScriptFilePath).ReadAll
ElseIf UCase(objFileSystem.GetExtensionName(strScriptFilePath)) = "JS" Then
If objFileSystem.FileExists(strHtaPath & "\Libraries\JavaScript\" & strScriptFilePath) Then
strScriptFilePath = strHtaPath & "\Libraries\JavaScript\" & strScriptFilePath
End If
If objFileSystem.FileExists(strHtaPath & "\Core\JavaScript\" & strScriptFilePath) Then
strScriptFilePath = strHtaPath & "\Core\JavaScript\" & strScriptFilePath
End If
If Not objFileSystem.FileExists(strScriptFilePath) Then
Err.Raise ERR_MODULE_FILE_NOT_FOUND,"库未找到","Import未找到您指定的文件",""
Exit Sub
End If
JsCodeRunner objFileSystem.OpenTextFile(strScriptFilePath).ReadAll
End If
' LibFiles=LibFiles&sInstFile&vbCrLf
' FileStr=ReadAll(sInstFile)
' filearr=Split(FileStr,vbCrLf)
' Help_Str=Help_Str&sInstFile&"{"&vbCrLf
' For i=0 To UBound(filearr)
' If LCase(Trim(Left(filearr(i),9)))="function"Or LCase(Trim(Left(filearr(i),3)))="sub" Then
'
' Help_Str=Help_Str&" "&filearr(i)&vbCrLf
' End If
' Next
' Help_Str=Help_Str&"}"&vbCrLf&vbCrLf
' On Error Resume Next
' ExecuteGlobal FileStr)
' If Err.Number<>0 Then WS.Run FileStr:Exit sub
' On Error Goto 0
End Sub
Public nodeInputArea
Sub Window_OnLoad
Rem 创建InputArea的备份。
Set nodeInputArea = document.getElementById("InputArea_0").cloneNode(True)
Rem 自动进入输入模式。
Call SetFocus()
End Sub
Rem CodeInputer ID动态返回。
Public lngInputerIndex
lngInputerIndex = 0
Public strInputMode
strInputMode = "SingleLineInputer" '默认为单行代码输入模式
Function InputerID()
InputerID = strInputMode & "_" & CStr(lngInputerIndex)
End Function
Rem 点击页面时自动让CodeInputer获得焦点。
Sub SetFocus()
With document
If .selection.createRange().text = "" Then '未选中文字时
Call .getElementById(InputerID()).Focus
End If
End With
End Sub
Rem 按键处理。
Public boolInputAreaUpdate
Function OnKeyPress()
With document.getElementById(InputerID())
Rem 处理特殊按键。
Select Case window.event.keyCode
Case 13 'Enter
If strInputMode = "SingleLineInputer" Then
If .innerText = "" Then
Rem 单行输入为空并回车,切换为多行代码输入模式。
.setAttribute "contentEditable", "False"
strInputMode = "MultiLineInputer"
document.getElementById _
(InputerID()).setAttribute _
"contentEditable", "True"
Call SetFocus
window.event.keyCode = 0 '阻断按键。
OnKeyPress = False
Exit Function
Else
Rem 去掉MultiLineCodeInputer,去掉空行。
document.getElementById _
("MultiLineInputer_" & CStr(lngInputerIndex)).parentNode.removeChild _
(document.getElementById("MultiLineInputer_" & CStr(lngInputerIndex)))
Rem 执行单行输入代码。
CodeRunner .innerText
.setAttribute "contentEditable", "False" '关闭代码输入功能
window.event.keyCode = 0
OnKeyPress = False
End If
End If
Case 10 'Ctrl+Enter
If strInputMode = "MultiLineInputer" Then '只在多行代码输入模式时响应
CodeRunner .innerText
window.event.keyCode = 0
.setAttribute "contentEditable", "False"
End If
window.event.keyCode = 0
OnKeyPress = False
Case Else
boolInputAreaUpdate = True
End Select
End With
End Function
Rem 代码自动高亮。
setInterval GetRef("AutoHighLight"),100
Function AutoHighLight()
Rem 由于高亮后HTML结构改变,浏览器无法找到原先位置,会将光标移动到输入区域末尾。
Rem 这就导致光标固定在末尾无法移动,故需要手动备份光标位置。
If boolInputAreaUpdate And document.selection.createRange().text = "" Then
boolInputAreaUpdate = False
Rem 保存光标位置。
document.selection.createRange().pasteHTML("") '0x5作为光标位置标记。
Rem 代码高亮。
With document.getElementById(InputerID())
Rem 为了保存光标字符,修改了HighLight函数。
Rem 修改后的HighLight函数会无视0x5,使得其在代码中的相对位置不变。
.innerHTML = Replace(Highlight(.innerText),Chr(5),"<span id='Cursor'></span>")
End With
Rem 恢复光标位置。
Dim objCursorNode
Set objCursorNode = document.getElementById("Cursor")
With document.body.createTextRange()
.moveToElementText objCursorNode
.collapse False
.select
End With
Rem 移除光标标记。
objCursorNode.parentNode.removeChild objCursorNode
End If
End Function
Sub CodeRunner(strCode)
On Error Resume Next
ExecuteGlobal strCode
If Err.Number <> 0 Then
WScript.Echo "脚本错误"
WScript.Echo "源: " & Err.Source
WScript.Echo "描述: " & Err.Description
WScript.Echo "代码: " & CStr(Err.Number)
Err.Clear
End If
On Error Goto 0
Rem 给Console追加新的InputArea。
lngInputerIndex = lngInputerIndex + 1
nodeInputArea.setAttribute "id", "InputArea_" & CStr(lngInputerIndex)
nodeInputArea.getElementsByTagName("span")(1).setAttribute _
"id", "SingleLineInputer_" & CStr(lngInputerIndex)
nodeInputArea.getElementsByTagName("div")(0).setAttribute _
"id", "MultiLineInputer_" & CStr(lngInputerIndex)
document.getElementById("Console").appendChild nodeInputArea
Rem 备份InputArea。
Set nodeInputArea = document.getElementById _
("InputArea_" & CStr(lngInputerIndex)).cloneNode(True)
Rem 还原输入模式。
strInputMode = "SingleLineInputer"
Call SetFocus
End Sub
'以下为新合并内容,待整理
'载入必要的组件
set fso=createobject("Scripting.FileSystemObject")
set ws=createobject("WScript.Shell")
Dim LibFiles
Dim CMD_Input,IsOutPut,Help_Str,str,IsConfig,InputType,PromptStr,PromptSet,ControlNum,filepath,char,RootFolder,ScriptType,ScriptName,FuncList,file,ScriptFile,IsScript,LineCount,ScriptLine,NeedExecute
Dim Isrecv,RecvData,IsRemote'Socket变量
IsOutPut=True
IsConfig=True
InputType=1
CMD_Input="'"
ControlNum=0
CurrentDirectory=ws.CurrentDirectory'普通变量初始化
Execute("Public Const Desktop= """&WS.ExpandEnvironmentStrings("%UserProFile%\Desktop")&Chr(34))
Execute("Public Const WinDir="""&WS.ExpandEnvironmentStrings("%Windir%")&Chr(34))
Execute("Public Const Path="""&WS.ExpandEnvironmentStrings("%path%")&Chr(34))
Execute("Public Const UserProFile="""&WS.ExpandEnvironmentStrings("%Userprofile%")&Chr(34))
Execute("Public Const FLib="""&WS.ExpandEnvironmentStrings("%VBSH_FLib%")&Chr(34))
Execute("Public Const ComLib="""&WS.ExpandEnvironmentStrings("%VBSH_Dll%")&Chr(34))
Dim rIsUAC:rIsUAC=IsUAC
'初始化静态变量
Public Const NL=Null
Public Const BK=1
Public Const RT=2'重要的变量初始化
Public Const KB=1024
Public Const MB=1048576
Public Const GB=1073741824
Public Const TB=1099511627776
Public Const VersionNum="0016"
Public Const VersionName="1.0.0.16"
Public Const ProductName="VBS Shell"
Public Const LastVersiondTime="202005142100" '版本和产品信息
'该版本使用CScript解释器运行。
filearr=Split(ReadAll(WScript.ScriptFullName),vbCrLf)'初始化动态变量
For i=0 To UBound(filearr)
If LCase(Trim(Left(filearr(i),9)))="function"Or LCase(Trim(Left(filearr(i),3)))="sub" Then
Help_Str=Help_Str&filearr(i)&vbCrLf
End If
Next
Import("Coreutils.vbs")
'If WScript.Arguments.Count=1 Then
'
' Dim Islogo
' Islogo=True
' Select Case Trim(LCase(WScript.Arguments(0)))
' Case "-nl"
' Islogo=False
' Case "-re"
'
' End Select
' If fso.FileExists(WScript.Arguments(0))=True Then
' IsScript=True
' ScriptName=WSH.Arguments(0)
' Set ScriptFile=fso.OpenTextFile(WScript.Arguments(0))
' End If
'End If
'If IsScript<>True And Islogo=True Then
' WSH.Echo ProductName&" [版本 " & VersionName & "]" 已迁移
' WScript.Echo("内部版本 "& VersionNum)
' WScript.Echo("版权所有 " & Chr(60) + Chr(99) + Chr(62) & " 2019 " + "TECH_N00b&小肥羊。" + Chr(32) + "保留所有权利。")
' WScript.Echo("")
'End If
'-------------------------------input part-----------------------------------------------------
'Dim Count,ErrMode
'ErrMode=0
'InputType=1
'Do
' If ErrMode=0 Then On Error Goto 0
' If ErrMode=1 Then On Error Resume Next
'
' Select Case InputType
' Case 1
' If IsScript Then
' If ScriptFile.AtEndOfStream Then WSH.Quit()
' CMD_Input=ScriptFile.ReadLine
' Else
' If rIsUAC= True Then WScript.StdOut.Write(WS.CurrentDirectory & "#>")
' If rIsUAC<>True Then WScript.StdOut.Write(WS.CurrentDirectory & "@>")
' CMD_Input=WScript.StdIn.ReadLine
' End If
' ErrorDealing()
' Case 2
' If IsScript=False Then
' output=Null
' For i=0 To ControlNum
' output=output&"----"
' Next
' WScript.StdOut.Write output
' str=Trim(LCase(WScript.StdIn.ReadLine))
' Else
' If IsAtEnd<>True Then
' str=ScriptFile.ReadLine
' End If
' IsScript=True
' End If
' CMD_Input=str
' str=Trimpp(str)
' If InStr(str,"next")Or InStr(str,"loop")Or InStr(str,"end ")Then
' ControlNum=ControlNum-1
' End If
' If InStr(str,"do ")Or InStr(str,"if ") Or InStr(str,"for") Or InStr(str,"select")Or InStr(str,"with ") Or InStr(str,"wend") Then
' If InStr(str,"end if") Or InStr(str,"end function") Then ControlNum=ControlNum-1
' If InStr(input,"if") Then
' If(Right(Trim(LCase(input)),4)<>"then") Then ControlNum=ControlNum-1
' End If
' ControlNum=ControlNum+1
' End If
' If ControlNum=0 Then
' NotNeedCheck=True
' NeedExecute=True
' End If
' CMD_Input=str
' str=Null
' End Select
' If InputType=2 Then
' Code=Code&vbCrLf&Deal(CMD_Input)
' Else
' Code=Deal(CMD_Input)
'
' End If
' If ControlNum=0 Then
' InputType=1
' End If
' If InputType=1 And IsScript<>True Then
' '--------------------------------------execute part------------------------------------------------------------------------------
' On Error Resume next
' If ScriptType<>"bat" Then
' Code="'VBS Shell Code here:"&vbCrLf&Code
' Execute(Code)
' Else
' System(Code)
' ScriptType="vbs"
' End If
' CMD_Input=Null
' Code=Null
' If Err.Number<>0 Then
' WSH.Echo("错误:" & Err.Number)
' WScript.Echo(Err.Description)
' WScript.Echo("仅支持vbscript。您可以:")
' WScript.Echo(" 1.在搜索引擎搜索“" & Err.Description & "”")
' WScript.Echo(" 2.输入”About“以联系开发者。")
' End If
' On Error Goto 0
' '----------------------------------------execute part end -----------------------------------------------------------------------------
' End If
'Loop
'------------------------Preparing.....-------------------------------------
Function Start()
WS.Run "%windir%\system32\Cscript //nologo "&WScript.ScriptFullName
End Function
Sub GetCommand()'列出所有命令
WScript.Echo(Help_Str)'这个变量储存命令说明
End Sub
Sub GetHelp(ByVal FuncStr)
If InStr(FuncStr,"function")Or InStr(FuncStr,"sub")Then
WSH.Echo("不应有'sub'或者'function'在查询字符中。")
Exit Sub
End If
If IsActiveX(Funcstr) Then
Set TLI=CreateObject("TLI.TLIApplication")
Set O=CreateObject(Funcstr)
Set Info = tli.ClassInfoFromObject(O)
For Each Member In Info.DefaultInterface.Members
Echo Member.Name
Next
Exit Sub
End If
If FSO.FileExists(Funcstr)Then
If LCase(FSO.GetExtensionName(Funcstr))="dll"Or LCase(FSO.GetExtensionName(Funcstr))="ocx" Then
Set TLI=CreateObject("TLI.TLIApplication")
Set Info = tli.TypeLibInfoFromFile("scrrun.dll")
For Each Interface In Info.Interfaces
Echo Interface.Name
Next
Exit sub
End If
End If
StrArr=Split(Help_Str,vbCrLf)
For i=0 To UBound(StrArr)
If InStr(LCase(StrArr(i)),LCase(FuncStr)) Then
Echo(StrArr(i))
End If
Next
End Sub
Function IsActiveX(ByVal ComName)
On Error Resume Next
Dim O
Set O = CreateObject(ComName)
If Err.Number = 0 Then
IsActiveX = True
Else
IsActiveX = False
End If
Set O = Nothing
Err.Clear
On Error Goto 0
End Function
Sub CLS()
For i=0 To 2000
str=str&vbCrLf
Next
WScript.Echo str
str=Null
End Sub
Function WhichType(ByVal varname)
If varname=Null Then
WhichType="[null]"
ElseIf IsArray(varname) Then
WhichType="[Array]"
ElseIf IsObject(varname) Then
WhichType="[Object]"
ElseIf IsNumeric(varname) Then
If InStr(varname,".")Then
WhichType="[Float]"
Else
WhichType="[Int]"
End If
End If
End Function
Sub About()
WScript.Echo("《关于本程序》")
WScript.Echo("")
WScript.Echo(ProductName)
WScript.Echo("版本号:" & VersionName)
WScript.Echo("内部版本:" & VersionNum)
WScript.Echo("最后编辑时间:" & LastVersiondTime)
WScript.Echo("")
WScript.Echo(" 本程序的著作权归TECH_Noob和小肥羊所有。所有权利保留。")
WScript.Echo(" 本程序不会记录您的任何个人信息。请您放心使用。")
WScript.Echo(" 本程序也不包含任何恶意代码,但不排除被他人捆绑黑客软件的可能。请从正规渠道获取该程序。")
WScript.Echo(" 如果你需要联系本程序的开发者,请通过下列渠道:")
WScript.Echo("网站:")
WScript.Echo(" 开发者2:yangruixian.icoc.me")
WScript.Echo("邮箱:")
WScript.Echo(" TECH_N00b:[email protected]")
WScript.Echo(" 开发者2:[email protected]")
WScript.Echo("QQ:")
WScript.Echo("TECH_N00b:3464943410")
WScript.Echo("如果您还有任何疑问,欢迎和我们联系。")
End Sub
Function ReadAll(ByVal filepath)
If Not fso.FileExists(filepath) Then Exit Function
Set file=fso.OpenTextFile(filepath)
ReadAll=file.ReadAll
Set file=Nothing
End Function
Function Cat(ByVal filepath)
If Not fso.FileExists(filepath) Then Exit Function
Set file=fso.OpenTextFile(filepath)
ReadAll=file.ReadAll
Set file=Nothing
End Function
Function Trimpp(ByVal input)
str=input
strarr=Split(input,Chr(34))
For i=0 To UBound(strarr)
If Not IsInt((i+1)/2) Then
str=Replace(str,strarr(i),"")
Else
str=Replace(str,strarr(i),LCase(strarr(i)))
End If
Next
strarr=Split(str,vbCrLf)
For i=0 To UBound(strarr)
For intc=0 To Len(strarr(i))
If Right(Left(strarr(i),intc),1)="'" Then
outstr=Left(strarr(i),intc)
MsgBox(outstr)
Exit For
End If
Next
str=str&outstr&vbCrLf
Next
Trimpp=str
str=Null
End Function
Function InstallVBM(MoudlePath)
If Not FSO.FolderExists(Lib) Then WScript.Echo("Can't find the 'lib', reinstall the program can solve the problem."):Exit Function
If Not FSO.FileExists(MoudlePath) Then WScript.Echo("The Moudle file isn't exist."):Exit Function
If LCase(FSO.GetExtensionName(MoudlePath))<>"vbs"Or LCase(FSO.GetExtensionName(MoudlePath))<>"vbe"Or LCase(FSO.GetExtensionName(MoudlePath))<>"vbm" Then WScript.Echo("The ExtensionName must be 'vbs,vbe or vbm'"):Exit Function
FSO.MoveFile MoudlePath,Lib
WScript.Echo("Finish!")
End Function
Function IsInt(ByVal num)
If InStr(num,".") And IsNumeric(num)Then
IsInt=True
Else
IsInt=False
End If
End Function
Function CD(ByVal PathStr)
PathStr=Trim(PathStr)
If PathStr=Null Then
CD=WS.CurrentDirectory
Exit Function
End If
If IsNumeric(PathStr) Then
Select Case PathStr
Case 1
str=ws.CurrentDirectory
str=Left(str,InStrRev(str,"\"))
ws.CurrentDirectory=str
str=Null
Case 2
str=Left(ws.CurrentDirectory,1)
ws.CurrentDirectory=str&":\"
str=Null
Case Else
WSH.Echo("Path isn't correct.....")
End Select
Else
If FSO.FolderExists(ws.CurrentDirectory&"\"&PathStr) Then
WS.CurrentDirectory=ws.CurrentDirectory&"\"&PathStr
Exit Function
End If
If FSO.FolderExists(ws.CurrentDirectory&PathStr) Then
WS.CurrentDirectory=ws.CurrentDirectory&PathStr
CD=WS.CurrentDirectory
Exit Function
End If
If Not fso.FolderExists(PathStr) Then
WScript.Echo("Path isn't correct.....")
CD=WS.CurrentDirectory
Exit Function
Else
ws.CurrentDirectory=PathStr
End If
End If
CD=WS.CurrentDirectory
End Function
Function System(ByVal Cmd)
Set ObjCmd=WS.Exec("cmd /c "&Cmd)
Do While ObjCmd.StdOut.AtEndOfStream=False
WSH.StdOut.Writeline(ObjCmd.StdOut.Readline)
Loop
Set ObjCmd=Nothing
End Function
Function IsCommand(ByVal str)
Dim Strings
str=str&" "
char=Null
Do Until char=" "
i=i+1
char=Right(Left(str,i),1)
Strings=Left(str,i)
Loop
i=0
Strings=LCase(Trim(Strings))
If fso.FileExists(Strings) Then
IsCommand=True
Exit Function
End If
Paths=Split(ws.ExpandEnvironmentStrings("%path%"),";")
For i=0 To UBound(Paths)
If fso.FileExists(Paths(i)&"\"&Strings) Then
IsCommand=True
Exit Function
End If
If fso.FileExists(Paths(i)&"\"&Strings&".exe") Then
IsCommand=True
Exit Function
End If
Next
If InStr(str,"if") Then
If InStr(str,"/") Then IsCommand=True
If InStr(str,"%") Then IsCommand=True
If InStr(str,"then") Then IsCommand=False
If IsCommand Then Exit Function
End If
If InStr(str,"set") Then
If InStr(str,".") Then
IsCommand=False
Exit Function
End If
If InStr(str,"%") Then IsCommand=True
If Not InStr(str,"/") Then IsCommand=True
If IsCommand Then Exit Function
End If
If InStr(str,"for") Then
If InStr(str,"/") Then IsCommand=True
If InStr(str,"%") Then IsCommand=True
If InStr(str,"do") Then IsCommand=True
If IsCommand Then Exit Function
End If
If Strings="powershell" Or Strings="cmd" Or Strings="choice" Or Strings="kill"Or Strings="shutdown"Or Strings="wget" Then
IsCommand=False
Exit Function
End If
If Strings = "md" Or Strings = "setx"Or Strings = "ren" Or Strings = "xcopy" Or Strings = "copy" Or Strings = "rd" Or Strings = "format" Or Strings = "del" Or Strings = "pushd" Or Strings = "popd" Or Strings = "type" Or Strings = "color" Or Strings = "call" Or Strings = "dir" Or Strings = "erase" Or Strings = "shift" Or Strings = "ftype" Or Strings = "assoc" Then
IsCommand=True
Exit Function
End If
For i=0 To UBound(Paths)
If fso.FileExists(Paths(i)&"\"&Strings&".bat") Then
IsCommand=True
Exit Function
End If
If fso.FileExists(Paths(i)&"\"&Strings&".vbe") Then
IsCommand=True
Exit Function
End If
If fso.FileExists(Paths(i)&"\"&Strings&".vbs") Then
IsCommand=True
Exit Function
End If
Next
End Function
Function Deal(ByVal input)
If input=Null Then Exit Function
If LCase(Trim(Left(input,1)))="'" Then Exit Function
If IsCommand(input) Then
ScriptType="bat"
Else
Replace input,"wscript.scriptfullname",ScriptName
End If
On Error Resume Next
Err.Clear
If InStr(input,"=") Then
Else
TestEval=Eval(input)
End If
On Error Goto 0
If Len(TestEval)<>0 Then
WScript.Echo(TestEval)
input=" "
Else
Deal=input
End If
TestEval=null
If InStr(input,"if") Then
If(Right(Trim(LCase(input)),4)<>"then") Then Exit Function
End If
If InStr(input,"end") Then ControlNum=ControlNum-1
input=Trimpp(input)
If InputType<>2 And InStr(input,"do ")Or InStr(input,"if ")Or InStr(input,"sub ")Or InStr(input,"for ") Or InStr(input,"select ")Or InStr(input,"wend ")Or InStr(input,"function ") Then
NotNeedCheck=False
ControlNum=ControlNum+1
InputType=2
End If
input=Null
End Function
' function isuac()
' on error resume next
' fso.createfolder("c:\windows\testuac")
' isuac=true
' if err.number=70 then isuac=false
' fso.deletefolder("c:\windows\testuac")
' on error goto 0
' end function
Sub Echo(ByVal str)
If Is_Remote<>True Then
WSH.StdOut.Write(str&vbCrLf)
Else
Sock.sendData(str&vbCrLf)
End If
End Sub
' Function Input()
' If Is_Remote<>True Then
' Input=WScript.StdIn.ReadLine
' Else
' Do Until Isrecv=True
' WScript.Sleep 200
' Loop
' ExecuteGlobal("Isrecv=False")
' Input=RecvData
' RecvData=Null
' End If
' End Function
Sub Quit()
WScript.Quit
End Sub
</script>
</body>
</html>