Код: Выделить всё
set dest=\\path\to\share\pub
set dest="%dest%"
for %%i in (%dest%) do (set "fold=%%~ni")
if exist "c:\VOLUMES\%fold%" (goto:unmount) else (goto:mount)
:unmount
RD "c:\VOLUMES\%fold%"
net use %dest% /delete
pause
goto:eof
:mount
if not exist "C:\Volumes" MD "C:\Volumes"
mklink /d "c:\VOLUMES\%fold%" "%dest%"
net use %dest%
pause
goto:eof
Код: Выделить всё
private void ChangeLinkListBox(object sender, EventArgs e)
{
//Take path as string works
SymLinkSelect.Text = SymLinkList.SelectedItem.ToString();
//Only take final folder as string
//SymLinkFolder.Text = SymLinkList.SelectedItem.Path();
//SymLinkFolder.Text = SymLinkList.SelectedItem.ToPath();
//SymLinkFolder.Text = SymLinkList.SelectedItem.ToString();
//SymLinkFolder.Text = new DirectoryInfo(SymLinkList.SelectedItem.ToString()).Name;
}
Код: Выделить всё
private void MountShare(object sender, EventArgs e)
//Mount/Unmount symlinks here button change, check for mounts?
{
if (btnPos == false)
{
if (SymLinkSelect.Text.Length > 0)
{
btnPos = true;
//mounting script in here
//DoProcess("Net") - does not exist in the current context
//pass string to batch file?
btnMount.Text = "Unmount";
}
else
{
MessageBox.Show("Select a Link to Mount please", "SymLink Says: ");
}
}
else
{
btnMount.Text = "Mount";
//unmounting script in here
btnPos = false;
}
}
Код: Выделить всё
namespace ConsoleApplication
{
class Program
{
[DllImport("kernel32.dll")]
static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, SymbolicLink dwFlags);
enum SymbolicLink
{
File = 0,
Directory = 1
}
static void Main(string[] args)
{
string symbolicLink = @"c:\bar.txt";
string fileName = @"c:\temp\foo.txt";
using (var writer = File.CreateText(fileName))
{
writer.WriteLine("Hello World");
}
CreateSymbolicLink(symbolicLink, fileName, SymbolicLink.File);
}
}
}

Спасибо за помощь и извините за все вопросы.
Рори
Подробнее здесь: https://stackoverflow.com/questions/792 ... ndow-forms
Мобильная версия