例如:
我希望cd到另一个目录,该目录是"其中xxx"
的输出所以,我输入:
其中xxx | CD
但这不起作用,cd是cmd.exe的内置命令
答案 0 :(得分:0)
以下是您可以做的事情:
go2.bat
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "irprops.lib")
#include <stdio.h>
#include <string>
#include <WinSock2.h>
#include <cstring>
#include <fstream>
#include <ws2bth.h>
#include <BluetoothAPIs.h>
#include <bthdef.h>
#define SCK_VERSION2 0x0202
#define WIN32_LEAN_AND_MEAN
#define MAX_NAME 248
typedef ULONGLONG BT_ADDR;
using namespace std;
int main()
{
WSADATA wsadata_bt;
WSAQUERYSET sokBT;
WSAQUERYSET *hittadeBTresultat;
WORD wsadata_version;
DWORD bufferLangdBT;
DWORD namnrymd;
HANDLE hittaBT;
BYTE bufferBT[4096];
BT_ADDR adressBT;
LPTSTR BT;
int wsa_ansluten;
int bt_ansluten;
int enheter_hittade;
//Deklarera värden för wsa och aktivera wsa och BT
wsadata_version = MAKEWORD(2, 2);
wsa_ansluten = WSAStartup(MAKEWORD(2, 2), &wsadata_bt);
memset(&sokBT, 0, sizeof(WSAQUERYSET));
bt_ansluten = WSALookupServiceBegin(&sokBT, LUP_CONTAINERS, &hittaBT);
memset(bufferBT, 0, sizeof(bufferBT));
bufferLangdBT = sizeof(bufferBT);
hittadeBTresultat = (WSAQUERYSET*) &bufferBT;
//Skapa BT-värden
sokBT.dwSize = sizeof(WSAQUERYSET);
sokBT.dwNameSpace = NS_BTH;
sokBT.lpBlob = NULL;
if (wsa_ansluten != 0)
{
printf("\tERROR: Kunde inte initialisera winsock.dll\n");
printf("\tFelkod: %id", WSAGetLastError());
WSACleanup();
system("Pause");
return 0;
}
else
{
printf("Initialiserar Winsock...\t\tOK!\n");
}
if (bt_ansluten != 0)
{
printf("\tERROR: Kunde inte initialisera bluetooth.dll\n");
printf("\tFelkod: %id", WSAGetLastError());
WSACleanup();
system("Pause");
return 0;
}
else
{
printf("Initialiserar Bluetooth...\t\tOK!\n");
system("cls");
}
//Sök efter bluetoothenheter
while (wsa_ansluten && bt_ansluten == 0)
{
enheter_hittade = WSALookupServiceNext(hittaBT, LUP_RETURN_NAME | LUP_CONTAINERS | LUP_RETURN_ADDR |
LUP_FLUSHCACHE | LUP_RETURN_TYPE | LUP_RETURN_BLOB | LUP_RES_SERVICE, &bufferLangdBT, hittadeBTresultat);
if (enheter_hittade == 0)
{
adressBT = ((SOCKADDR_BTH *)hittadeBTresultat->lpcsaBuffer->RemoteAddr.lpSockaddr)->btAddr;
BT = hittadeBTresultat->lpszServiceInstanceName;
namnrymd = hittadeBTresultat->dwNameSpace;
wprintf(L"\tENHET\tNAP ADRESS\tSAP ADRESS\tNAMNRYMD\n");
wprintf(L"\t%s\t0X%04X\t\t0X%08X\t0X%0X\n", BT, GET_NAP(adressBT), GET_SAP(adressBT), namnrymd);
}
}
WSACleanup();
system("PAUSE");
return 0;
};
使用它:
@echo off
cd %~dp$PATH:1