Mapowanie dysków sieciowych [use net]

0

Witam!
Pisze programik okienkowy który ma za zadanie mapowac kilka dysków sieciowych(każdy przycisk do innego dysku), lecz nie chce mi działać polecenie:
System.Diagnostics.Process.Start("net use x: \aaaaaaa.aaaaa.pl\xxxxx");

Przykładowo jeżeli chce odpalić z tego polecenia jakis inny proces np. "calc.exe", wtedy nie ma problemu i wszystko działa. A może to kwestia złych ustawień kompilacji? (W Visual studio 2010 pisze). Proszę o pomoc i ewentualne wskazówki.

Dostaje takie błędy:

 See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ComponentModel.Win32Exception (0x80004005): Nie można odnaleźć określonego pliku
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Dyski.Form1.button1_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.296 (RTMGDR.030319-2900)
    CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Dyski XP
    Assembly Version: 1.0.4733.25498
    Win32 Version: 
    CodeBase: file:///C:/Documents%20and%20Settings/Sebszty/Pulpit/Dyski%20XP.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.278 built by: RTMGDR
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.282 built by: RTMGDR
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.296 built by: RTMGDR
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
0

System.Diagnostics.Process.Start("net use x: \\aaaaaaa.aaaaa.pl\xxxxx");

0
_13th_Dragon napisał(a):

System.Diagnostics.Process.Start("net use x: \\aaaaaaa.aaaaa.pl\xxxxx");

Zrobiłem tak właśnie:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
		 System::Diagnostics::Process::Start("net use x: \\\\aaaaa.aaaaaa.aaaaa.pl\\xxxx");		 
		 }
 

i dalej mam błąd (gdy odpale program i nacisne na przycisk "podłącz dysk x"):

A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll

Additional information: Nie można odnaleźć określonego pliku
 

Do czego odnosi się do biblioteka system.dll skoro powyższe polecenie jest prawidłowe?
Pozdrawiam:)

0

Pod klawiszem F1 masz pomoc, dowiedz się jakie parametry przyjmuje metoda Start.

0
Azarien napisał(a):

Pod klawiszem F1 masz pomoc, dowiedz się jakie parametry przyjmuje metoda Start.

wyszukałem że należy dorzucić biblioteke: #using <System.dll>

Takie bliki nagłówkowe mam:

#pragma once
#include <cstdlib>
#include <stdlib.h>
#using <System.dll>


namespace Dyski {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System;
	using namespace System::Diagnostics;

Lecz dalej nie działa, próbowałem na dwa sposoby:

private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
		System::Diagnostics::Process::Start("net use x:\\\\aaaaaaa.aaaaaa.pl\\iiiiiiiii");							   
		 }																								    //dysk x
private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
		Process::Start("net use y:\\\\aaaaa.aaaaa.pl\\yyyyy");	                  //dysk y
		 }

za każdym razem mam błąd:

 'Dyski XP.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
'Dyski XP.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\ja\Desktop\dyski na xp\Dyski XP\Debug\Dyski XP.exe', Symbols loaded.
'Dyski XP.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'
'Dyski XP.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'
'Dyski XP.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll

Additional information: Nie można odnaleźć określonego pliku

Coś mi sie wydaje że w złym miejscu szukam, może to kwestia ustawień kompilacji? Mam tak:

Configuration type: Application (.exe)
Use of MFC: Use Standard Windows Libraries
Use of ALT: Not Using ATL
Charakter set: Use Multi-Byte Character Set
Common language runtime support: Pure MSIL Common Language Runtime Support (/clr:pure)
Whole program opyimization: No Whole Program Optimization
0

wyszukałem że należy dorzucić biblioteke: #using <System.dll>
Nie. Należy podać dwa parametry — w jednym nazwę programu (net.exe) a w drugim parametry.

http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx?cs-lang=cpp

0
Azarien napisał(a):

wyszukałem że należy dorzucić biblioteke: #using <System.dll>
Nie. Należy podać dwa parametry — w jednym nazwę programu (net.exe) a w drugim parametry.

http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx?cs-lang=cpp

Zrobiłem teraz według instrukcji:

private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
                System::Diagnostics::Process::Start("net.exe", net use y:\\\\aaaaa.aaaaa.pl\\yyyyy");                          //dysk y
                 }

Pierwszy parametr się uruchamia, natomiast jest problem z drugim parametrem (tak jakby był niewidoczny).

0

Witki opadają.

Teraz masz: net.exe net use y:\\\\aaaaa.aaaaa.pl\\yyyyy

1
Azarien napisał(a):

Witki opadają.

Teraz masz: net.exe net use y:\\\\aaaaa.aaaaa.pl\\yyyyy

W ten sposób:

private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
		System::Diagnostics::Process::Start("net.exe net use y:\\\\aaaaa.aaaaa.pl\\yyyyy");
																									 //dysk y
		 }

Uruchamia się ale po wciśnieciu przycisku mam błędy:

An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll

Additional information: Nie można odnaleźć określonego pliku

Przy takim sposobie:

private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
		System::Diagnostics::Process::Start('net.exe net use y:\\\\aaaaa.aaaaa.pl\\yyyyy');
																									 //dysk y
		 }

Kompilator sypie błędami:

1>------ Build started: Project: Dyski XP, Configuration: Debug Win32 ------
1>Build started 2012-12-19 22:27:55.
1>InitializeBuildStatus:
1>  Touching "Debug\Dyski XP.unsuccessfulbuild".
1>GenerateTargetFrameworkMonikerAttribute:
1>Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>ClCompile:
1>  All outputs are up-to-date.
1>  Dyski XP.cpp
1>c:\users\ja\desktop\dyski na xp\dyski xp\dyski xp\Form1.h(197): warning C4129: 'w' : unrecognized character escape sequence
1>c:\users\ja\desktop\dyski na xp\dyski xp\dyski xp\Form1.h(201): warning C4129: 'w' : unrecognized character escape sequence
1>c:\users\ja\desktop\dyski na xp\dyski xp\dyski xp\Form1.h(213): warning C4129: 'k' : unrecognized character escape sequence
1>c:\users\ja\desktop\dyski na xp\dyski xp\dyski xp\Form1.h(216): warning C4129: 'i' : unrecognized character escape sequence
1>c:\users\ja\desktop\dyski na xp\dyski xp\dyski xp\Form1.h(219): warning C4129: 'k' : unrecognized character escape sequence
1>c:\users\ja\desktop\dyski na xp\dyski xp\dyski xp\Form1.h(219): error C2015: too many characters in constant
1>c:\users\ja\desktop\dyski na xp\dyski xp\dyski xp\Form1.h(219): error C2665: 'System::Diagnostics::Process::Start' : none of the 6 overloads could convert all the argument types
1>          c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\system.dll: could be 'System::Diagnostics::Process ^System::Diagnostics::Process::Start(System::String ^)'
1>          c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\system.dll: or       'System::Diagnostics::Process ^System::Diagnostics::Process::Start(System::Diagnostics::ProcessStartInfo ^)'
1>          while trying to match the argument list '(int)'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.29
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

P.S. Dzięki za cierpliwość:)

0

Czy ma ktos jeszcze jakieś pomysły na powyższy problem? Pytałem kilka osób ale nikt nie jest w stanie okreslić dlaczego drugi parametr nie działa;/

1 użytkowników online, w tym zalogowanych: 0, gości: 1