I do not receive any errors, the program simply does not execute remotely and I am looking for ideas as to why that may be occurring. The program runs fine locally when I run it from the remote computer using command prompt. The program itself takes 10 arguments, hence args[0] through [9] below. Any suggestions are appreciated.
NOTE: I tested this code using notepad and it worked fine, so it seems to be related to how I am calling my program with arguments (as notepad has no arguments).
Thanks
String programArgs = #"C:\Report\Report.exe " + "\"" + args[0] + "\"" + " " + args[1]
+ " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6]
+ " " + "\"" + args[7] + "\"" + " " + args[8] + " " + args[9];
object[] theProcessToRun = { programArgs, #"C:\Report" };
ManagementScope wmiScope = new ManagementScope(#"\\" + hostname + #"\root\cimv2");
wmiScope.Options.Impersonation = ImpersonationLevel.Impersonate;
wmiScope.Connect();
using (ManagementClass managementClass = new ManagementClass(wmiScope,
new ManagementPath("Win32_Process"), new ObjectGetOptions()))
{
managementClass.InvokeMethod("Create", theProcessToRun);
}
Related
How can I show the Debug.Log in 2 lines (like adding an enter or <br>) in C#?
I have lots of info to show and compare, yet it is not convenient to read it in one line.
Current result: Debug.Log("Pointer:" + " " + pointerPosX + " " + pointerPosY + " " + "target" + " " + targetPosX + " " + targetPosY);
Expected result:
Pointer: pointerPosX + " " + pointerPosY
Target: targetPosX " " " + targetPosY
P.S. This is my first question in StackOverflow - so, please, let me know if I did something wrong.
Option 1 (\n):
Debug.Log("Pointer:" + " " + pointerPosX + " "
+ pointerPosY + "\n" + "Target:" + " " + targetPosX + " " + targetPosY);
Option 2 (System.Environment.NewLine):
Debug.Log("Pointer:" + " " + pointerPosX + " " + pointerPosY +
System.Environment.NewLine + "Target:" + " " + targetPosX + " " + targetPosY);
Using $ - string interpolation
Option 1:
Debug.Log($"Pointer: {pointerPosX} {pointerPosY}\nTarget: {targetPosX} {targetPosY}");
Option 2:
Debug.Log($"Pointer: {pointerPosX} {pointerPosY}{System.Environment.NewLine}Target: {targetPosX} {targetPosY}");
Difference between "\n" and Environment.NewLine
I'm currently trying to make a minecraft launcher for my server. But some reason it wont start. This is the code I used. Can someone check what I did wrong ?
string installPath = GetJavaInstallationPath();
string filePath = System.IO.Path.Combine(installPath, "bin\\Javaw.exe");
Environment.SetEnvironmentVariable("APPDATA", "C:\\SCO\\");
Process process = new Process();
ProcessStartInfo info = new ProcessStartInfo();
string dir = #"C:\SCO\.minecraft\versions\";
info.FileName = filePath;
info.CreateNoWindow = true;
info.Arguments = "-cp \"" + dir + "1.8.3.jar;" + dir + "lwjgl.jar;" + dir + "lwjgl_util.jar;" + dir + "jinput.jar;\" ";
info.Arguments += "\"-Djava.library.path=" + dir + "natives\" -Xmx1024M -Xms512M net.minecraft.client.main.Main " + username + " " + session;
process.StartInfo = info;
process.Start();
try this code, it worked for me
private void StartMinecraft(string username, string accessToken, string uuid, string gameVersion)
{
ProcessStartInfo minecraft = new ProcessStartInfo
{
FileName = GetJavaInstallationPath() + #"\bin\javaw.exe",
CreateNoWindow = false,
Arguments = " -XX:+UseConcMarkSweepGC -XX:-UseAdaptiveSizePolicy -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseCMSInitiatingOccupancyOnly -Xmx1024M -Dfile.encoding=UTF-8 -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Djava.library.path=C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/versions/" + gameVersion + "/natives -Dminecraft.launcher.brand=java-minecraft-launcher -Dminecraft.launcher.version=1.6.84-j -cp C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/oshi-project/oshi-core/1.1/oshi-core-1.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/ibm/icu/icu4j/66.1/icu4j-66.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/mojang/javabridge/1.0.22/javabridge-1.0.22.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/io/netty/netty-all/4.1.25.Final/netty-all-4.1.25.Final.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/google/guava/guava/21.0/guava-21.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/commons-io/commons-io/2.5/commons-io-2.5.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/commons-codec/commons-codec/1.10/commons-codec-1.10.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/mojang/brigadier/1.0.17/brigadier-1.0.17.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/mojang/datafixerupper/4.0.26/datafixerupper-4.0.26.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/it/unimi/dsi/fastutil/8.2.1/fastutil-8.2.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/apache/logging/log4j/log4j-core/2.8.1/log4j-core-2.8.1.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl/3.2.2/lwjgl-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-jemalloc/3.2.2/lwjgl-jemalloc-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-openal/3.2.2/lwjgl-openal-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-opengl/3.2.2/lwjgl-opengl-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-glfw/3.2.2/lwjgl-glfw-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-stb/3.2.2/lwjgl-stb-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/org/lwjgl/lwjgl-tinyfd/3.2.2/lwjgl-tinyfd-3.2.2.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/com/mojang/text2speech/1.11.3/text2speech-1.11.3.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/libraries/by/ely/authlib/2.0.27.4/authlib-2.0.27.4.jar;C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/versions/" + gameVersion + "/" + gameVersion + ".jar net.minecraft.client.main.Main --username " + username + " --version " + gameVersion + " --gameDir C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft --assetsDir C:/Users/" + Environment.UserName + "/AppData/Roaming/.minecraft/assets --assetIndex " + gameVersion + " --uuid " + uuid + " --accessToken " + accessToken + " --userType legacy --versionType release --width 925 --height 530"
};
Process.Start(minecraft);
}
Must try this: info.CreateNoWindow = true; to info.CreateNoWindow = false;
or recheck parameters and must be Java path is valid
I develop a windows application for a small shop for generating invoices.
Now I want to give a functionality for the user to make backup of each day database on a button click from the windows application. Also he should be able to restore the database from these backup.
Please help me i searched many topics but not works.
Thanks..
You have to use the using Microsoft.SqlServer.Management.Smo name space and use the BackUp Method provided. It has various backup options.
Please See this link
using Microsoft.SqlServer;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.Data.SqlClient;
using System.Configuration;
public void BackupDatabase(string BackUpLocation, string BackUpFileName, string DatabaseName, string ServerName)
{
DatabaseName = "[" + DatabaseName + "]";
string fileUNQ = DateTime.Now.Day.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Year.ToString() +"_"+ DateTime.Now.Hour.ToString()+ DateTime.Now .Minute .ToString () + "_" + DateTime .Now .Second .ToString () ;
BackUpFileName = BackUpFileName + fileUNQ + ".bak";
string SQLBackUp = #"BACKUP DATABASE " + DatabaseName + " TO DISK = '" + BackUpLocation + #"\" + BackUpFileName + #"'";
string svr = "Server=" + ServerName + ";Database=" + DatabaseName + ";Integrated Security=True";
SqlConnection cnBk = new SqlConnection(svr);
SqlCommand cmdBkUp = new SqlCommand(SQLBackUp, cnBk);
try
{
cnBk.Open();
cmdBkUp.ExecuteNonQuery();
//MessageBox.Show("Done");
MessageBox.Show(SQLBackUp + " ######## Server name " + ServerName + " Database " + DatabaseName + " successfully backed up to " + BackUpLocation + #"\" + BackUpFileName + "\n\nBackUp Date : " + DateTime.Now.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
//MessageBox.Show(SQLBackUp + " ######## Server name " + ServerName + " Database " + DatabaseName + " successfully backed up to " + BackUpLocation + #"\" + BackUpFileName + "\n Back Up Date : " + DateTime.Now.ToString());
}
finally
{
if (cnBk.State == ConnectionState.Open)
{
cnBk .Close();
}
}
}
I want to fetch history from browser as soon as a web site is loaded in the browser. It should fetch clients' browser info and save it in a database so that admin may check out the website that is frequently opened and can do survey on the data.
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "Browser Capabilities\n"
+ "Type = " + browser.Type + "\n"
+ "Name = " + browser.Browser + "\n"
+ "Version = " + browser.Version + "\n"
+ "Major Version = " + browser.MajorVersion + "\n"
+ "Minor Version = " + browser.MinorVersion + "\n"
+ "Platform = " + browser.Platform + "\n"
+ "Is Beta = " + browser.Beta + "\n"
+ "Is Crawler = " + browser.Crawler + "\n"
+ "Is AOL = " + browser.AOL + "\n"
+ "Is Win16 = " + browser.Win16 + "\n"
+ "Is Win32 = " + browser.Win32 + "\n"
+ "Supports Frames = " + browser.Frames + "\n"
+ "Supports Tables = " + browser.Tables + "\n"
+ "Supports Cookies = " + browser.Cookies + "\n"
+ "Supports VBScript = " + browser.VBScript + "\n"
+ "Supports JavaScript = " +
browser.EcmaScriptVersion.ToString() + "\n"
+ "Supports Java Applets = " + browser.JavaApplets + "\n"
+ "Supports ActiveX Controls = " + browser.ActiveXControls
+ "\n";
Request.Browser is used to identify the browser info . Using this you can get all info of browser
IIS is already storing this information for you. See: http://msdn.microsoft.com/en-us/library/ms525410%28v=vs.90%29.aspx
To make that data useful you will then need to use a Log Analyzer tool.
Google this term for some options to use: iis log analyzer
Im trying to access and extract message from Exchange Server 2003. I need to get them by dates but im having problem with it.
Here's the code lsQuery = "<?xml version=\"1.0\"?>"
+ "<D:searchrequest xmlns:D = \"DAV:\" xmlns:m=\"urn:schemas:httpmail:\">"
+ "<D:sql>SELECT \"urn:schemas:httpmail:hasattachment\", \"DAV:displayname\", "
+ "\"urn:schemas:httpmail:from\", \"urn:schemas:httpmail:subject\", "
+ "\"urn:schemas:httpmail:htmldescription\" FROM \"" + lsRootUri
+ "\" WHERE \"DAV:ishidden\" = false "
+ "AND \"DAV:isfolder\" = false "
+ "AND \"urn:schemas:httpmail:hasattachment\" = true "
+ "AND \"urn:schemas:httpmail:read\" = false "
+ "AND \"urn:schemas:httpmail:date \" \">=\" CAST(\"2009/11/17\" as 'dateTime') "
+ "AND \"urn:schemas:httpmail:date \" \"<=\" CAST(\"2009/11/19\" as 'dateTime') "
+ "</D:sql></D:searchrequest>";
http://msdn.microsoft.com/en-us/library/aa123600%28EXCHG.65%29.aspx