VBS版URLEncode

Function URLEncode(strURL)
    For I = 1 To Len(strURL)
        If Asc(Mid(strURL, I, 1)) < 0 Then
            tempStr = "%" & Right(CStr(Hex(Asc(Mid(strURL, I, 1)))), 2)
            tempStr = "%" & Left(CStr(Hex(Asc(Mid(strURL, I, 1)))), Len(CStr(Hex(Asc(Mid(strURL, I, 1))))) - 2) & tempStr
            URLEncode = URLEncode & tempStr
        ElseIf (Asc(Mid(strURL, I, 1)) >= 65 And Asc(Mid(strURL, I, 1)) <= 90) Or (Asc(Mid(strURL, I, 1)) >= 97 And Asc(Mid(strURL, I, 1)) <= 122) Or (Asc(Mid(strURL, I, 1)) >= 48 And Asc(Mid(strURL, I, 1)) <= 57) Then
            URLEncode = URLEncode & Mid(strURL, I, 1)
        Else
            URLEncode = URLEncode & "%" & Hex(Asc(Mid(strURL, I, 1)))
        End If
    Next
End Function
 
Function URLDecode(strURL)
    If InStr(strURL, "%") = 0 Then
        URLDecode = strURL
        Exit Function
    End If
    For I = 1 To Len(strURL)
        If Mid(strURL, I, 1) = "%" Then
            If Eval("&H" & Mid(strURL, I + 1, 2)) > 127 Then
                URLDecode = URLDecode & Chr(Eval("&H" & Mid(strURL, I + 1, 2) & Mid(strURL, I + 4, 2)))
                I = I + 5
            Else
                URLDecode = URLDecode & Chr(Eval("&H" & Mid(strURL, I + 1, 2)))
                I = I + 2
            End If
        Else
            URLDecode = URLDecode & Mid(strURL, I, 1)
        End If
    Next
End Function

, ,

怎样用程序方式显示所有文件和系统文件

windows 的文件夹选项参数是保存在注册表中的,我们可以通过程序直接更改,例如显示隐藏文件
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
“Hidden”=dword:00000001

使用WMI重启计算机

试试这个命令,主要是熟悉语法,当然我们一般就是用shutdown 命令来重启

set win32_OS=getobject("winmgmts:{(Shutdown)}//./root/cimv2").execQuery("select * from win32_operatingsystem where primary=true")
for each OS in win32_OS
    OS.win32shutdown(6)
next
set win32_OS=nothing

, ,

更改文件夹所有者以显示ntfs权限

有时我们发现win2003系统中有些文件夹属性-安全选项卡里的,添加删除是灰色的,这证明所者被改过了,可以手工点开高级按钮,所有者那儿选择administrator然后确定后即可。但程序怎么实现呢,这儿教你一个takeown命令

Dim WshShell:set WshShell = CreateObject("wscript.Shell")
WshShell.run "cmd /c echo y|takeown /f D:\down /A /R",0,true
WshShell.run "cmd /c echo y|cacls ""D:\down"" /T /C /P administrator:R",0,True
set WshShell=nothing
Dim objWMIFileSecSetting 
Set objWMIFileSecSetting = GetObject("winmgmts:Win32_LogicalFileSecuritySetting.path='D:\\awstats'") 
 
intRetVal = objWMIFileSecSetting.GetSecurityDescriptor(wmiSecurityDescriptor) 
If Err.Number = 0 Then 
Dim wmiAce 
For Each wmiAce In wmiSecurityDescriptor.DACL 
wscript.echo "Access Mask: " & wmiAce.AccessMask 
wscript.echo "Trustee Name: " & wmiAce.Trustee.Name 
wscript.echo ""
Next 
Else 
MsgBox Err.Number & " " & Err.Description 
End If

用fso怎样给文件加上隐藏

Set fso = Server.CreateObject("scripting.filesystemobject") 
set f=fso.Getfile("//./" & Server.MapPath("/myfile.jpg"))
f.Attributes=1+2+4

, , , , ,

用VBS挂载Hyper-V磁盘VHD文件

VHD = "D:\vps\diskD.vhd"
Set WMIService = GetObject("winmgmts:\\.\root\virtualization") 
Set VHDService = WMIService.ExecQuery("SELECT * FROM Msvm_ImageManagementService").ItemIndex(0) 
VHDService.Mount(VHD)

这样就挂好vhd文件了,打开磁盘管理可以看到一个新的区出来,右击它设定一个盘符
用完当然要删除,把最后一句改为 VHDService.unMount(VHD) 即可。

, , ,

hyper-v电源操作脚本vbs

	Set VmWMI=GetObject("winmgmts:\\.\root\virtualization")
	set vmSets=VmWMI.ExecQuery("select * from msvm_ComputerSystem where ElementName='" & vmName & "'")
	If vmSets.count=1 then
		Set oVM=vmSets.ItemIndex(0)
		Set inPara=oVM.Methods_("RequestStateChange").InParameters.SpawnInstance_()
		inPara.RequestedState=3	'2电源开,3电源关,10重启
		inPara.TimeoutPeriod=null
		Set outParm=oVM.ExecMethod_("RequestStateChange",inPara)
	Else
		WScript.Echo "NOT FOUND THIS VM!"
	End If
 
	oVM.EnabledState'得到当前VM主机状态2正在运行3已关闭32768已暂停32774正在停止32773正在保存32769已保存32770正在启动

,

用WMI结束指定任务通过命令行

Sub CloseProcessBycmd(byval cmdstr)
	Dim wmiobj,colFiles,m,strline
	Set wmiobj = GetObject("winmgmts:\\.\Root\cimv2")
	Set colFiles = wmiobj.execQuery("Select * from CIM_Process")
	For each m in colFiles
		strline = lcase(m.commandline)
		If instr(strline,lcase(cmdstr))>0 then
    		'wscript.echo m.Handle & chr(9) & strline
    		m.Terminate
		End if
	Next
End Sub

, , , , ,

用vbs监视新创建进程并结束

k=",kugoo.exe,qqmusic.exe,kgdaemon.exe,"
Set wm = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2"):Set cs = wm.ExecNotificationQuery("select * from __instancecreationevent within 1 where TargetInstance isa 'Win32_Process'"):Do:Set ob = cs.NextEvent:p=LCase(ob.TargetInstance.Name):If InStr(k,p)>0 Then:Call ob.TargetInstance.Terminate:End If:Loop

, , ,

shopex后台不能开启伪静态解决方法

windows主机安装shopex4.8.5,后台营销优化–SEO优化处开启伪静态会报错,说不是apahce不支持htaccess文件,其实windows上面是可以实现的,我们需要改个文件跳过验证。
\core\admin\controller\sale\ctl.tools.php
第426行附近 $svinfo->test_fake_html(false,$msg);
找到后打个回车粘贴下面两行
$this->system->setConf(‘system.seo.emuStatic’,'true’);
return true;
保存后去后台设置就不会有提示了,然后在自己站点上加载isapi筛选器和规则吧,规则本站有

, , , , ,