Tech-Ezo (Hokkaido PC and Network Users Group)
 Top Page  |  What's Tech-Ezo  |  Next Seminar  |  Seminar Log  |  Seminar Plan  |  Tips  |  life  |  Link  |
Scr.002 �t����WSH(VBScript)�T���v���W �| ���̑���Tips��(029�`038)
[WSH�T���v���W�֖߂�n

�� ���̑���Tips��(029�`038)


�� WSH.029 ����t�H���_�����擾����(�f�X�N�g�b�v�̎��̂Ȃ�) �߂�

�� �������g�p���̃f�X�N�g�b�v�̃t�H���_����\������

Set ws = WScript.CreateObject("WScript.Shell")
WScript.Echo ws.SpecialFolders("Desktop")

�� ���̂ق��̏��

�v���p�e�B �Ӗ� ��L�̗�ŕ\������������
AllUsersDesktop �f�X�N�g�b�v(����) C:\Documents and Settings\All Users\�f�X�N�g�b�v
AllUsersStartMenu �X�^�[�g���j���[(����) C:\Documents and Settings\All Users\�X�^�[�g ���j���[
AllUsersPrograms �X�^�[�g���j���[���́u�v���O�����v�t�H���_(����) C:\Documents and Settings\All Users\�X�^�[�g ���j���[\�v���O����
AllUsersStartUp �X�^�[�g���j���[���́u�X�^�[�g�A�b�v�v�t�H���_(����) C:\Documents and Settings\All Users\�X�^�[�g ���j���[\�v���O����\�X�^�[�g�A�b�v
Desktop �f�X�N�g�b�v C:\Documents and Settings\TechEzo\�f�X�N�g�b�v
Favorits ���C�ɓ��� �@
Fonts �t�H���g C:\WINNT\Fonts
MyDocuments �}�C�h�L�������g C:\Documents and Settings\TechEzo\My Documents
NetHood �}�C�l�b�g���[�N C:\Documents and Settings\TechEzo\NetHood
PrintHood �v�����^ C:\Documents and Settings\TechEzo\PrintHood
Programs �X�^�[�g���j���[���́u�v���O�����v�t�H���_ C:\Documents and Settings\TechEzo\�X�^�[�g ���j���[\�v���O����
Recent �ŋߎg�����t�@�C�� C:\Documents and Settings\TechEzo\Recent
SendTo ���郁�j���[ C:\Documents and Settings\TechEzo\SendTo
StartMenu �X�^�[�g���j���[ C:\Documents and Settings\TechEzo\�X�^�[�g ���j���[
Startup �X�^�[�g���j���[���́u�X�^�[�g�A�b�v�v�t�H���_ C:\Documents and Settings\TechEzo\�X�^�[�g ���j���[\�v���O����\�X�^�[�g�A�b�v
Templates �e���v���[�g C:\Documents and Settings\TechEzo\Templates

�� ��L�ȊO�̃t�H���_(�C���X�g�[����A�V�X�e���t�H���_�A�e���|�����t�H���_)

Set fso = CreateObject("Scripting.FileSystemObject")
Set sf = fso.GetSpecialFolder(0)   '  Windows �C���X�g�[����
WScript.Echo sp.Path
Set sf = fso.GetSpecialFolder(1)   '  Windows �V�X�e���t�H���_
WScript.Echo sp.Path
Set sf = fso.GetSpecialFolder(2)   '  �e���|�����t�H���_
WScript.Echo sp.Path

�� WSH.030 �R���s���[�^�����擾���� �߂�

�� �g���Ă���PC�̃R���s���[�^����\������

Set net = CreateObject("WScript.Network")
WScript.Echo net.ComputerName   ' �R���s���[�^��
WScript.Echo net.UserDomain     ' �Q�����̃h���C����
WScript.Echo net.UserName       ' �h���C���ɓ������Ƃ��̃��[�U�[��

�� WSH.031 �l�b�g���[�N�h���C�u�̊��蓖�� �߂�

�� �t�@�C���T�[�o��̃z�[���f�B���N�g�����s�h���C�u�Ƃ��Ċ��蓖�Ă�

Set net = WScript.CreateObject("WScript.Network")
strName = net.UserName
net.MapNetworkDrive "T:", "\\fileserver\FileServer\home\TechEzo"

�� WSH.032 �V���[�g�J�b�g���쐬���� �߂�

�� �d��̃V���[�g�J�b�g���f�X�N�g�b�v��ɍ쐬����

Set fso = CreateObject("Scripting.FileSystemObject")
Set winF = fso.GetSpecialFolder(1)    ' �V�X�e���t�H���_�擾
Set ws = CreateObject("WScript.Shell")
desktopF = ws.SpecialFolders("Desktop") ' �f�X�N�g�b�v�t�H���_�擾
' �V���[�g�J�b�g�쐬
Set shortcut = ws.CreateShortcut(desktopF & "\calc.lnk")
With shortcut
    .TargetPath = winF & "\calc.exe"
    .WorkingDirectory = desktopF
    .Save
End With

�� WSH.033 �A�v���P�[�V�������N������ �߂�

�� �������𗧂��グ��

set ws = CreateObject("WScript.Shell")
ws.Run "Notepad"

�� WSH.034 �A�v���P�[�V�����𑀍삷��i�L�[���͂̎������j �߂�

�� �������𗧂��グ�e�L�X�g����͂���

set ws = CreateObject("WScript.Shell")
ws.Run "Notepad"       ' �������̗����グ
WScript.Sleep 100      ' �����オ��܂Ŏ኱�҂�
ws.AppActivate "����"  ' ���������A�N�e�B�u�ɂ���
ws.SendKeys "Welcome Tech-Ezo Round23"

�� WSH.035 Excel�𑀍삷�� �߂�

�� Excel�𗧂��グ�Z���Ƀe�L�X�g����͂���

Set xl = CreateObject("Excel.Application")
xl.Visible = True          ' �����オ����Excel��������悤�ɂ���
xl.Workbooks.Add           ' ���[�N�u�b�N��V�K�ɒlj�
xl.Range("A1") = "�悤����! Tech-Ezo Round 23 ��"

�� WSH.036 �R�}���h���C���p�����^���擾���� �߂�

�� �R�}���h���C���Ɏw�肳�ꂽ�p�����^��S�ĕ\������

Set arg = WScript.Arguments
For i = 0 to arg.Count - 1
    WScript.Echo arg(i)
Next
�� �h���b�N&�h���b�v�����l�̃X�N���v�g�Ŏ擾�ł���

�� WSH.037 Windows�̃o�[�W����(NT�n)��\������ �߂�

�� Windows�̃o�[�W����(NT�n)��\������

Set ws = CreateObject("Wscript.Shell")
Wscript.Echo ws.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\Curren
tVersion\CurrentVersion")

�� IE�́u�z�[���y�[�W�v��ύX����

Set ws = CreateObject("WScript.Shell")
ws.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start
Page", "http://www.techezo.jp/"

�� WSH.038 �C�x���g���O�ւ̏������� �߂�

�� �X�N���v�g�̏I�����(����A�ُ�)���C�x���g���O�ɏ�������

Set ws = CreateObject("WScript.Shell")
ws.LogEvent 0, "����I��"
ws.LogEvent 1, "�ُ�I��"
�� WindowsNT�n��OS�ł̓C�x���g���O�ɏ������܂�邪�AWindows 95�n��OS�ł̓V�X�e���t�H���_��WSH.log�ɏ������܂��B

[WSH�T���v���W�֖߂�n
-
���S�Ă͎��ȐӔC�ł��肢���܂��B �ŏI�X�V�� 2004.3.9