Click here to Skip to main content
15,893,814 members
Home / Discussions / C#
   

C#

 
QuestionTimer in C# Pin
Håkan Axheim8-Jun-09 23:11
Håkan Axheim8-Jun-09 23:11 
AnswerRe: Timer in C# Pin
Christian Graus8-Jun-09 23:26
protectorChristian Graus8-Jun-09 23:26 
AnswerRe: Timer in C# Pin
Mirko19808-Jun-09 23:29
Mirko19808-Jun-09 23:29 
QuestionMultiple bitmaps into one final image. Pin
E3pO8-Jun-09 23:01
E3pO8-Jun-09 23:01 
GeneralRe: Multiple bitmaps into one final image. Pin
harold aptroot8-Jun-09 23:09
harold aptroot8-Jun-09 23:09 
GeneralRe: Multiple bitmaps into one final image. Pin
E3pO8-Jun-09 23:15
E3pO8-Jun-09 23:15 
AnswerRe: Multiple bitmaps into one final image. Pin
Christian Graus8-Jun-09 23:25
protectorChristian Graus8-Jun-09 23:25 
QuestionTarget machine Pin
arkiboys8-Jun-09 22:24
arkiboys8-Jun-09 22:24 
Hello,
I have created a vbscript called sample.vbs
This file contains a simple script to create a Test.Log file on the C drive of the target machine. This script works as it has been tested.

The code below runs the script (sample.vbs) located on mylocalmachine against a remote machine i.e. Servermachine
There is no error but the file i.e. Test.Log does not appear in the c drive of the target machine i.e. Servermachine

please note that if I make the target machine as the local machine i.e. myLocalMachine then the Test.Log file does appear in the c drive.

Question:
can you please let me know why this code does not create the file on the target machine?
The vbscript in sample.vbs in case you are interested is shown at the bottom of this message.

Thank you

try
{
string stringCommandLine = @"cscript.exe \\myLocalMachine\c$\work\sample.vbs";

System.Management.ManagementOperationObserver observer = new System.Management.ManagementOperationObserver();
System.Management.ConnectionOptions conn = new System.Management.ConnectionOptions();

conn.Impersonation = ImpersonationLevel.Impersonate;
conn.EnablePrivileges=true;
conn.Authentication=AuthenticationLevel.Default;

System.Management.ManagementScope ms = new System.Management.ManagementScope("\\\\" + "Servermachine" + "\\root\\cimv2", conn);
//System.Management.ManagementScope ms = new System.Management.ManagementScope("\\\\" + "myLocalMachine" + "\\root\\cimv2", conn);

ms.Connect();

System.Management.ManagementPath path = new System.Management.ManagementPath("Win32_Process");

System.Management.ManagementClass processClass = new System.Management.ManagementClass(ms, path, null);

object[] methodArgs = { stringCommandLine, null, null, 0 };

uint result = (uint)processClass.InvokeMethod("Create", methodArgs);

}
catch (ManagementException err)
{
MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
}
catch (System.UnauthorizedAccessException unauthorizedErr)
{
MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);
}


///////////////////////////
////sample.vbs
Dim fso ' FileSystemObject
Dim f

Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.CreateTextFile("c:\test.log", True, True)

f.WriteLine("This is generated by test.vbs at " & Now)
f.Close()
QuestionSuggest me Datagrid view event Pin
deepseeindeepsy8-Jun-09 21:39
deepseeindeepsy8-Jun-09 21:39 
AnswerRe: Suggest me Datagrid view event Pin
Mycroft Holmes8-Jun-09 21:56
professionalMycroft Holmes8-Jun-09 21:56 
GeneralRe: Suggest me Datagrid view event Pin
deepseeindeepsy8-Jun-09 22:01
deepseeindeepsy8-Jun-09 22:01 
GeneralRe: Suggest me Datagrid view event Pin
Mycroft Holmes8-Jun-09 22:10
professionalMycroft Holmes8-Jun-09 22:10 
GeneralRe: Suggest me Datagrid view event Pin
Nagy Vilmos8-Jun-09 22:11
professionalNagy Vilmos8-Jun-09 22:11 
GeneralRe: Suggest me Datagrid view event Pin
Mycroft Holmes8-Jun-09 22:14
professionalMycroft Holmes8-Jun-09 22:14 
GeneralRe: Suggest me Datagrid view event Pin
Luc Pattyn9-Jun-09 1:41
sitebuilderLuc Pattyn9-Jun-09 1:41 
GeneralRe: Suggest me Datagrid view event Pin
deepseeindeepsy8-Jun-09 22:17
deepseeindeepsy8-Jun-09 22:17 
GeneralRe: Suggest me Datagrid view event Pin
Nagy Vilmos8-Jun-09 22:11
professionalNagy Vilmos8-Jun-09 22:11 
Questionremoting and client devices that switch network cards on the fly Pin
Martijn van Kleef8-Jun-09 21:24
Martijn van Kleef8-Jun-09 21:24 
QuestionCall OnPaint from other form Pin
Ankata8-Jun-09 21:05
Ankata8-Jun-09 21:05 
AnswerRe: Call OnPaint from other form Pin
Nagy Vilmos8-Jun-09 21:36
professionalNagy Vilmos8-Jun-09 21:36 
AnswerRe: Call OnPaint from other form Pin
Christian Graus8-Jun-09 23:27
protectorChristian Graus8-Jun-09 23:27 
QuestionTo record hearbeat of web application in event viewer. Pin
pravinkgarg8-Jun-09 21:00
pravinkgarg8-Jun-09 21:00 
AnswerRe: To record hearbeat of web application in event viewer. Pin
saanj8-Jun-09 21:24
saanj8-Jun-09 21:24 
GeneralRe: To record hearbeat of web application in event viewer. Pin
pravinkgarg9-Jun-09 2:47
pravinkgarg9-Jun-09 2:47 
GeneralRe: To record hearbeat of web application in event viewer. Pin
saanj9-Jun-09 3:02
saanj9-Jun-09 3:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.