1 / 22

WSH による NT Administration

WSH による NT Administration. Japan Windows NT Users Group 安納 順一. 概説. Windows Scripting Host. Windows Scripting Host. WSH とは … .. 言語に依存しないActiveXスクリプティングホスト 標準で VBScript(VBS) と Jscript(JS) をサポート Windows NT , 9x のコマンドライン機能を拡張 95 , NT 4.0 はセットアップが必要 98 , NT 5.0 には標準でインプリメント.

bern
Download Presentation

WSH による NT Administration

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WSH による NT Administration Japan Windows NT Users Group 安納 順一

  2. 概説

  3. Windows Scripting Host

  4. Windows Scripting Host WSHとは….. 言語に依存しないActiveXスクリプティングホスト 標準でVBScript(VBS)とJscript(JS)をサポート Windows NT,9x のコマンドライン機能を拡張 95,NT 4.0 はセットアップが必要 98,NT 5.0 には標準でインプリメント

  5. ActiveX Scripting コンポーネント ActiveX Scripting Hosts Internet Explorer Internet Information Server(ASP) Windows Scripting Host ActiveX Scripting engines スクリプトを実行する OLE COM オブジェクト 標準で VBScript,JScript を提供 その他サードベンダーより提供

  6. ActiveX Scripting の詳細は... http://msdn.microsoft.com/developer/sdk/ inetsdk/help/compdev/scripting/scripting.htm

  7. 2つのホストプログラム Wscript.exe(Default) Windows上でスクリプトを実行 Cscript.exe コマンドプロンプト上でスクリプトを実行 WSHの実行環境の変更にも使用する

  8. WSH実行環境の変更 Cscript.exe [ScriptFile] [Option] //I 非バッチモード (既定値) //B バッチモード //logo 起動ロゴ表示 (既定値) //nologo 起動ロゴ非表示。 //H:Cscript or Wscript 標準ホストの指定(既定値 Wscript.exe) //T:nn スクリプトの最大実行時間 • .WSHファイル PIF ファイルのようなもの 特定のスクリプトファイルの実行環境を指定 [ScriptFile] Path=C:\WINNT\WSH\showprop.vbs [Options] Timeout=0 DisplayLogo=1 BatchMode=0

  9. WSHのオブジェクトモデル WScript WshArgument WshShell WshEnvironment WshShortvut WshUrlShortvut WshSpecialFolder WshNetwork WshCollection

  10. PerlScript

  11. ActivePerl 505(1998.10.22現在) Perl 5.005_02 コア Perl for Win32 (Build 505) Perl for ISAPI PerlScript Perl Package Manager 必要システム Alpha、Pentium、i486 Windows NT 4.0 (service pack 3) Windows 9x(DCOM for Windows 95)

  12. Perl for Win32 3xx からの変更点 記述変更 OLE → Win32::OLE Win32::Reg* → Win32::Registry Win32::OpenEventLog → Win32::EventLog::OpenEventLog 等 削除 Win32::PerlVersion → $] Win32::GetArchName → $ENV{PROCESSOR_ARCHITECTURE} Win32::GetChipName → $ENV{PROCESSOR_IDENTIFIER} use Win32; が必要なもの Win32::LookupAccountName Win32::LookupAccountSID Win32::InitiateSystemShutdown 等 use Win32; が必要なくなったもの Win32::GetCwd Win32::SetCwd Win32::GetNextAvailDrive 等 詳細はリリースノート(release.htm)を参照

  13. PerlScript PerlScriptとは PerlのためのActiveXスクリプティングエンジン 拡張子は .pls ActiveStateより入手可能(ActivePerl 505) http://www.activestate.com/

  14. .pls のためのレジストリ plsファイルのアイコンを設定 [HKEY_CLASSES_ROOT\PLSFile\DefaultIcon] @="C:\\winnt\\system32\\wscript.exe,2" ポップアップメニューに「編集」を追加 [HKEY_CLASSES_ROOT\PLSFile\Shell\Edit] @=“編集" [HKEY_CLASSES_ROOT\PLSFile\Shell\Edit\Command] @="C:\\winnt\\Notepad.exe %1” その他 [HKEY_CLASSES_ROOT\PLSFile\Shell\Open] @=“&Wscriptで実行" [HKEY_CLASSES_ROOT\PLSFile\Shell\Open\Command] @="C:\\winnt\\system32\\WScript.exe " %1 [HKEY_CLASSES_ROOT\PLSFile\Shell\Open2] @=”&Cscriptで実行" [HKEY_CLASSES_ROOT\PLSFile\Shell\Open2\Command] @="C:\\winnt\\system32\\CScript.exe " %1

  15. PerlScriptの基礎 Win32::OLE と同等 メソッド $WshNetwork = $WScript->CreateObject('Wscript.Network'); プロパティ $WScript->Echo($strUserName = $WshNetwork->{UserName}); コレクションオブジェクト $WScript->Echo($WshSystem->Item("ComSpec"))

  16. 留意点 標準出力への print は使用不可 → WScript オブジェクトの Echo メソッド $WScript->Echo('Hello World !');

  17. 実践

  18. ユーザ管理 Win32::NetAdmin ADSI(Active Directry Services Interface) LDAP NDS NWCOMPAT NTDS GetDomainController GetAnyDomainController UserCreate UserDelete UserGetAttributes UserSetAttributes LocalGroupCreate LocalGroupDelete LocalGroupGetAttributes LocalGroupSetAttributes LocalGroupAddUsers LocalGroupDeleteUsers LocalGroupIsMember LocalGroupGetMembers GroupAddUsers GroupDeleteUsers GroupIsMember GroupGetMembers GroupCreate GroupDelete GroupGetAttributes GroupSetAttributes GroupAddUsers

  19. Win32::EventLog STMAdmin フリーのCOMコンポーネント Open, Backup, Clear, OpenBackup, Records, Close, RepordEvent イベントビューア OpenEventLog BackupEventLog ClearEventLog CloseEventLog GetNumberOfEventLogRecords ReadEventLog WriteEventLog

  20. レジストリ Win32::Registry Open, Create, SetValue, QueryValue, QueryKey, GetKeys, GetValues, Load WSHShellオブジェクト RegDelete, RegRead, RegWrite

  21. Win32::NetResource WshNetworkオブジェクト ネットワークリソース %Share_Info, NETRESOURCE GetSharedResource AddConnection CancelConnection WNetGetLastError GetError GetUNCName NetShareAdd NetShareCheck NetShareDel NetShareGetInfo NetShareSetInfo AddPrinterConnection EnumNetworkDrives EnumPrinterConnection MapNetworkDrive SetDefaultPrinter RemoveNetworkDrive RemovePrinterConnection

  22. その他便利なエクステンション Win32::LoginName Win32::DomainName Win32::NodeName Win32::GetShortName Win32::GetNextAvailDrive Win32::IsWinNT or Win32::IsWin95 Win32::Service Win32::GetCwd or Win32::SetCwd Win32::InitiateSystemShutdown or AbortSystemShutdown

More Related