2022年5月
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        
無料ブログはココログ

« 2011年1月 | トップページ | 2011年3月 »

2011年2月25日 (金)

「ウィンドウを切り替える」ショートカットを作る。

Window Switcher.VBS

Set wShell=CreateObject("WScript.Shell")
Set Link=wShell.CreateShortCut("Window Switcher.lnk")
Link.TargetPath="shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257}"
Link.IconLocation="%SystemRoot%\explorer.exe,-258"
Link.Description="ウィンドウを切り替える"
Link.Save

アイコンはVistaの場合なので、Windows7では違うかも。

2011年2月22日 (火)

バッチファイルから64/32bitで起動する。

64/32bit osで、cmd.exeを64bitで起動する。(32bit osでは32bitで起動されます。)

if exist "%systemroot%\sysnative\" (
%systemroot%\sysnative\cmd.exe
) else (
%systemroot%\system32\cmd.exe
)

または、

set path64=%systemroot%\sysnative\;%systemroot%\system32\
for %%I in ("cmd.exe") do "%%~f$path64:I"

64/32bit osで、cmd.exeを32bitで起動する。

if exist "%systemroot%\syswow64\" (
%systemroot%\syswow64\cmd.exe
) else (
%systemroot%\system32\cmd.exe
)

または、

set path32=%systemroot%\syswow64\;%systemroot%\system32\
for %%I in ("cmd.exe") do "%%~f$path32:I"

2011年2月20日 (日)

バッチファイルで64/32bitが違っていたら起動し直す。

もし、64bit osで32bitで起動されたら、自身を64bitで起動し直す。

if exist "%systemroot%\sysnative\" (
%systemroot%\sysnative\cmd.exe /c "%~0" %*
exit
)

もし、64bit osで64bitで起動されたら、自身を32bitで起動し直す。

if exist "%systemroot%\syswow64\" (
if not exist "%systemroot%\sysnative\" (
%systemroot%\syswow64\cmd.exe /c "%~0" %*
exit
))

2011年2月19日 (土)

バッチファイルで64/32bitを区別する。起動する。

if exist "%systemroot%\sysnative\" (
echo 32bit on 64bit
) else if exist "%systemroot%\syswow64\" (
echo 64bit on 64bit
) else (
echo 32bit on 32bit
)

64bit osで、
if exist "%systemroot%\syswow64\" (echo 64bit os) else echo 32bit os

32/64bit exeから、32bit exeを起動するには、
%systemroot%\syswow64\cmd.exe

32bit exeから、64bit exeを起動するには、
%systemroot%\sysnative\cmd.exe

64bit exeから、64bit exeを起動するには、
%systemroot%\system32\cmd.exe

2011年2月18日 (金)

WSHスクリプトを64/32bitが違っていたら起動し直す。

もし、64bit osで32bitで起動されたら、自身を64bitで起動し直す。

If InStr(LCase(WScript.FullName),"syswow64") Then
  CreateObject("WScript.Shell").Run """" & Replace(LCase(WScript.FullName),"syswow64","sysnative") & """ """ & WScript.ScriptFullName & """"
  WScript.Quit
End If

もし、64bit osで64bitで起動されたら、自身を32bitで起動し直す。

If InStr(LCase(WScript.FullName),"system32") Then If CreateObject("Scripting.FileSystemObject").FileExists(Replace(LCase(WScript.FullName),"system32","syswow64")) Then
  CreateObject("WScript.Shell").Run """" & Replace(LCase(WScript.FullName),"system32","syswow64") & """ """ & WScript.ScriptFullName & """"
  WScript.Quit
End If

引数を渡すなら、それぞれ、

If InStr(LCase(WScript.FullName),"syswow64") Then
  CommandLine="""" & Replace(LCase(WScript.FullName),"syswow64","sysnative") & """ """ & WScript.ScriptFullName & """"
  For Each Arg In WScript.Arguments
    CommandLine=CommandLine & " """ & Arg & """"
  Next
  CreateObject("WScript.Shell").Run CommandLine
  WScript.Quit
End If

If InStr(LCase(WScript.FullName),"system32") Then If CreateObject("Scripting.FileSystemObject").FileExists(Replace(LCase(WScript.FullName),"system32","syswow64")) Then
  CommandLine="""" & Replace(LCase(WScript.FullName),"system32","syswow64") & """ """ & WScript.ScriptFullName & """"
  For Each Arg In WScript.Arguments
    CommandLine=CommandLine & " """ & Arg & """"
  Next
  CreateObject("WScript.Shell").Run CommandLine
  WScript.Quit
End If

2011年2月15日 (火)

.VBSを.ps1でラップしてCScriptで起動する。(vbs2ps1)

.VBSを.cmdでラップする(vbs2cmd)と、どうしてもコマンドエコーが出ます。.ps1でラップすると、出ません。

'';CScript.exe //E:VBS //NoLogo "$($MyInvocation.MyCommand.Path)" $args;exit;<#
' ここにVBScriptコードを書く。
rem #>

2011年2月12日 (土)

IEのコンテキストメニューに「日本語(JIS)」を追加する。

IEのエンコーディングのメニューに「日本語(JIS)」がありません。なんで!

C:\どこかのフォルダ\jis.htm

<script defer>
external.menuArguments.setTimeout("document.charset='iso-2022-jp';location.reload()",0,"javascript");
</script>

jis.reg

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\日本語(JIS)]
@="C:\\どこかのフォルダ\\jis.htm"

« 2011年1月 | トップページ | 2011年3月 »