First published on TECHNET on Jul 25, 2006
Many thanks to Dan Lovinger for providing this code.
#define UNICODE 1
#include <stdio.h>
#include <windows.h>
#include <lm.h>
#include <lmdfs.h>
VOID usage(PWCHAR prog)
{
fprintf( stderr, "usage: %S <DfsEntryPath> <ServerName> <SharePathName> [<on|off>]n", prog );
}
__cdecl wmain(ULONG argc, PWCHAR *argv)
{
DFS_INFO_101 DfsInfo101;
ULONG Status;
LPWSTR DfsEntryPath, ServerName = NULL, SharePathName = NULL;
LPWSTR ResultString;
if (argc != 5) {
usage(argv[0]);
return 1;
}
DfsEntryPath = argv[1];
ServerName = argv[2];
SharePathName = argv[3];
if (!wcscmp( argv[4], L"on" )) {
DfsInfo101.State = DFS_STORAGE_STATE_ONLINE;
ResultString = L"enabled";
} else if (!wcscmp( argv[4], L"off" )) {
DfsInfo101.State = DFS_STORAGE_STATE_OFFLINE;
ResultString = L"disabled";
} else {
usage(argv[0]);
return 1;
}
//
// ... and modify it.
//
Status = NetDfsSetInfo( DfsEntryPath,
ServerName,
SharePathName,
101,
(LPBYTE) &DfsInfo101 );
if (Status == NERR_Success) {
printf( " \\%S\%S -> %Sn", ServerName, SharePathName, ResultString );
} else {
fprintf( stderr, "error: %dn", Status );
}
return 0;
}
Many thanks to Dan Lovinger for providing this code.
#define UNICODE 1
#include <stdio.h>
#include <windows.h>
#include <lm.h>
#include <lmdfs.h>
VOID usage(PWCHAR prog)
{
fprintf( stderr, "usage: %S <DfsEntryPath> <ServerName> <SharePathName> [<on|off>]n", prog );
}
__cdecl wmain(ULONG argc, PWCHAR *argv)
{
DFS_INFO_101 DfsInfo101;
ULONG Status;
LPWSTR DfsEntryPath, ServerName = NULL, SharePathName = NULL;
LPWSTR ResultString;
if (argc != 5) {
usage(argv[0]);
return 1;
}
DfsEntryPath = argv[1];
ServerName = argv[2];
SharePathName = argv[3];
if (!wcscmp( argv[4], L"on" )) {
DfsInfo101.State = DFS_STORAGE_STATE_ONLINE;
ResultString = L"enabled";
} else if (!wcscmp( argv[4], L"off" )) {
DfsInfo101.State = DFS_STORAGE_STATE_OFFLINE;
ResultString = L"disabled";
} else {
usage(argv[0]);
return 1;
}
//
// ... and modify it.
//
Status = NetDfsSetInfo( DfsEntryPath,
ServerName,
SharePathName,
101,
(LPBYTE) &DfsInfo101 );
if (Status == NERR_Success) {
printf( " \\%S\%S -> %Sn", ServerName, SharePathName, ResultString );
} else {
fprintf( stderr, "error: %dn", Status );
}
return 0;
}
Updated Apr 10, 2019
Version 2.0FileCAB-Team
Iron Contributor
Joined April 10, 2019
Storage at Microsoft
Follow this blog board to get notified when there's new activity