本文整理汇总了PHP中COM::CreateShortcut方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::CreateShortcut方法的具体用法?PHP COM::CreateShortcut怎么用?PHP COM::CreateShortcut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COM
的用法示例。
在下文中一共展示了COM::CreateShortcut方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: relocateShortcut
private static function relocateShortcut()
{
$WshShell = new COM('WScript.Shell');
$desktop = $WshShell->SpecialFolders('Desktop');
$startmenu = $WshShell->SpecialFolders('Programs');
$startmenu .= DIRECTORY_SEPARATOR . 'XAMPP for Windows';
$links = array();
$links[realpath($desktop . DIRECTORY_SEPARATOR . 'XAMPP Control Panel.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'Description' => 'XAMPP Control Panel');
$links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Control Panel.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'Description' => 'XAMPP Control Panel');
$links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Setup.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_setup.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Setup');
$links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Shell.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_shell.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Shell');
$links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Uninstall.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'uninstall_xampp.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Uninstall');
foreach ($links as $shortcut => $value) {
if (is_int($shortcut)) {
continue;
}
$oldfileperm = fileperms($shortcut);
if (!chmod($shortcut, 0666) && !is_writable($shortcut)) {
throw new XAMPPException('File \'' . $shortcut . '\' is not writable.');
}
$ShellLink = $WshShell->CreateShortcut($shortcut);
$ShellLink->TargetPath = $value['TargetPath'];
$ShellLink->WorkingDirectory = $value['WorkingDirectory'];
$ShellLink->WindowStyle = $value['WindowStyle'];
$ShellLink->IconLocation = $value['IconLocation'];
$ShellLink->Description = $value['Description'];
$ShellLink->Save();
$ShellLink = null;
chmod($shortcut, $oldfileperm);
}
$WshShell = null;
return;
}
示例2: relocateShortcut
private static function relocateShortcut()
{
$WshShell = new COM('WScript.Shell', null, CP_UTF8);
$FSO = new COM('Scripting.FileSystemObject', null, CP_UTF8);
$desktop = $WshShell->SpecialFolders('Desktop');
$startmenu = $WshShell->SpecialFolders('Programs');
$startmenu = $FSO->BuildPath($startmenu, utf8_encode('XAMPP for Windows'));
$xampppath = utf8_encode(self::$xampppath);
$links = array();
$links[$FSO->BuildPath($desktop, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
$links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
$links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Setup.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_setup.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Setup'));
$links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Shell.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_shell.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Shell'));
$links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Uninstall.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('uninstall_xampp.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Uninstall'));
foreach ($links as $shortcut => $value) {
if (!$FSO->FileExists($shortcut)) {
continue;
}
try {
$shortcut_file = $FSO->GetFile($shortcut);
$oldfileperm = $shortcut_file->attributes;
if (($oldfileperm & 1) == 1) {
$shortcut_file->attributes += -1;
}
} catch (Exception $e) {
throw new XAMPPException('File \'' . utf8_decode($shortcut) . '\' is not writable.');
}
$ShellLink = $WshShell->CreateShortcut($shortcut);
$ShellLink->TargetPath = $value['TargetPath'];
$ShellLink->WorkingDirectory = $value['WorkingDirectory'];
$ShellLink->WindowStyle = $value['WindowStyle'];
$ShellLink->IconLocation = $value['IconLocation'];
$ShellLink->Description = $value['Description'];
$ShellLink->Save();
$ShellLink = null;
$shortcut_file->attributes = $oldfileperm;
$shortcut_file = null;
}
$FSO = null;
$WshShell = null;
return;
}
示例3: COM
<?php
$wsh = new COM('WScript.Shell') or die;
$shortcut = $wsh->CreateShortcut(dirname(__FILE__) . '/test.lnk');
$shortcut->TargetPath = 'shortcut.php';
$shortcut->Save();
$wsh = null;