service load fails through createprocess? - windows

I have a windows service.
I can install it through cmd with "c:\serviceName -install"
when I do createProcess and pass command line -install it does not appear in the Service Control manager. The createProcess returns non-zero value
"GetExitCodeProcess" gives 0.
Following is a line from the code:
CreateProcess(Process,pCmdLine,NULL,NULL,FALSE,DETACHED_PROCESS,NULL,NULL,&stStartupInfo,pProcessInfo);
Variable name are fairly self-explained.
Please comment.

Related

Error while trying to run shell script using OS process sampler in jmeter

one.jmx file takes command line arguments so i am putting the long command to run one.jmx in a shell script(RUN_GET_CALLS.sh). Now i am using Two.jmx which calls One.jmx via the shell script using OS process sampler.
When i execute Two.jmx it is giving error
timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
1548833794770,4,"Patient_""_id""",500,"Exception occurred whilst executing system call: java.io.IOException: Cannot run program ""bash /home/ubuntu/HSDP_Suit/TestSuite/JMX_files/RUN_GET_CALLS.sh"" (in directory ""/home/ubuntu/JMeter/apache-jmeter-5.0/bin""): error=2, No such file or directory",Patient 1-4,text,false,,0,0,6,6,null,0,0,0
I tried putting path in Working directory box also but it is not working
Your syntax is a little bit incorrect you should configure the OS Process Sampler as follows:
Command: /bin/bash
Working directory: /home/ubuntu/HSDP_Suit/TestSuite/JMX_files
Argument #1: -c
Argument #2: ./RUN_GET_CALLS.sh ${PROPERTY_FILE} ${RESOURCE} ${PARAMETERS_STRING} ${FILE_NAME} ${RESULT_FILE}
Example configuration screenshot:
As per bash man page
-c string
If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.
More information: How to Run External Commands and Programs Locally and Remotely from JMeter

How to redirect Windows cmd output to a text file?

I am trying to monitor the cmd output of a certain executable .exe and use it for another process running at the same time.
The problem is that all cmd redirecting functions ( '>','>>','<' and '|') would only redirect the output after a successful return of the last command.
What I wanted to do is to generate some kind of streaming log of my cmd.
You can run in your process in background by using
start /b something.exe > somefile.txt
Windows 20H2: Redirection works fine when logged in as true administrator but will NOT work when logged in as a created administrative user. I have used it for years to redirect the output of a multi target backup system using Hobo copy to put the console output in a log file. I have never been able to get it to work successfully in Windows 10 ver 19 or 20 on a created administrative user.
You can prefix the command with "cmd /c" to start a new command prompt, and redirect the output of the command prompt:
cmd /c YOUR CODE > TextFileName.txt
Note : Use ONLY single greater than (>)
Since the output of cmd is going to TextFileName.txt.
Whereas this misses the error output, so you are not able to see : Request to UnKnown timed-out for each failed address.

Not Able to Run PowerShell Script from CMD

I want to execute a PowerShell script from Command Prompt. I have verified script from PowerShell, it worked fine. I went to script location and executed it as
./hyperv_disk_ops.ps1 -op 'getDiskAttachmentInfo' -vmid '{6612D0CB-BCC3-44D4-988B-526500578D54}' -disk_ids ("Microsoft:7B036CE0-5D67-46BA-AF7B-B2AFD8DD7946\83F8638B-8DCA-4152-9EDA-2CA8B33039B4\0\0\D")
But when I tried running it from command prompt as
powershell.exe C:\hyperv_disk_ops.ps1 -op 'getDiskAttachmentInfo' -vmid '{6612D0CB-BCC3-44D4-988B-526500578D54}' -disk_ids ("Microsoft:7B036CE0-5D67-46BA-AF7B-B2AFD8DD7946\83F8638B-8DCA-4152-9EDA-2CA8B33039B4\0\0\D")
it gave me an error
ERROR: Failed to find object of [Microsoft:7B036CE0-5D67-46BA-AF7BB2AFD8DD794683F8638B-8DCA-4152-9EDA-2CA8B33039B400D] disk which is associated with [{6612D0CB-BCC3-44D4-988B-526500578D54}] VM.
Both are exact same but why it is not running from Command Prompt?
Try running from the command prompt with double backslashes, like so:
powershell.exe C:\hyperv_disk_ops.ps1 -op 'getDiskAttachmentInfo' -vmid '{6612D0CB-BCC3-44D4-988B-526500578D54}' -disk_ids ("Microsoft:7B036CE0-5D67-46BA-AF7B-B2AFD8DD7946\\83F8638B-8DCA-4152-9EDA-2CA8B33039B4\\0\\0\\D")
It looks like, in the error you provided, all of the slashes are being omitted in the disk path.

how do you run arguments in a custom monitor on uptime

i am trying to run a custom monitor in the up-time monitoring system and when i have it open a .bat that i have created it gives me an error stating that the #echo off is not a command.
the .bat file contains
#echo off
start c:\OpenSSL-Win64\bin\openssl.exe
when i run the .bat in windows it opens up openssl and lets me pass in information
the error i am getting when running on uptime is
Status: OK Message:
D:\uptime software\scripts\custom>#echo off
D:\uptime software\scripts\custom>start
c:\OpenSSL-Win64\bin\openssl.exe , error data returned: '#echo' is
not recognized as an internal or external command, operable program or
batch file. Output:
D:\uptime software\scripts\custom>#echo off
D:\uptime software\scripts\custom>start
c:\OpenSSL-Win64\bin\openssl.exe Response time: 531 ms
I need the custom monitor to open the .bat and have it pass in commands to check the xml web sites through their corresponding ports.
for example i need this web site for XML to be checked "blank-xml.mycompany.com:4021"
i can run s_client -connect blank-xml.mycompany.com:4021 in openssl and see that the port is actually active and running. then i check the packages that have been loaded by running <BL30DOC><XPLN/></BL30DOC> and it returns information of the current packages that have been loaded.
how would i get the .bat to open with up-time and pass in arguments that are needed to run?
Update
I have changed the encoding to the .bat to be ANSI and now get this response from uptime
Status: OK Message: (No output) Output: Response time: 547 ms
the problem now seems to be that the argument i want to run is actually not doing anything.
the argument i am trying to run is s_client -connect blank-xml.mycompany.com:4021 and i still get the same response from up-time with the argument in place.

Ruby scripting - Telnet Hangs During Login

I am trying to do some basic scripting using ruby to log in to a windows machine via telnet and pull some files over using the dos command line ftp. When I do this manually everything goes swimmingly but when I try it via ruby I'm getting an error in the login call.
Here is my test program in its entirety:
require 'net/telnet'
tn = Net::Telnet::new("Host"=>"xxx.xxx.xxx.xxx", "Timeout"=>25, "Output_log"=>"output_log.log", "Dump_log"=> "dump_log.log", "Prompt"=>"C:.*>")
tn.login("administrator", "xxxxxxx") {}
tn.cmd('dir')
exit
The contents of output_log don't betray anything as being wrong:
Trying 208.10.202.187...
Connected to 208.10.202.187.
Welcome to Microsoft Telnet Service
login: administrator
password:
*===============================================================
Welcome to Microsoft Telnet Server.
*===============================================================
C:\Documents and Settings\Administrator>
Same for the dump_log which has very similar but awkwardly formatted contents. When I run the program it sits around for a while and then outputs the following error:
PS C:\code\tools\deployment> ruby test.rb
C:/Ruby/lib/ruby/1.8/net/telnet.rb:551:in `waitfor': timed out while waiting for more data (Timeout::Error)
from C:/Ruby/lib/ruby/1.8/net/telnet.rb:685:in `cmd'
from C:/Ruby/lib/ruby/1.8/net/telnet.rb:730:in `login'
from test.rb:3
Which leads me to suspect that the telnet class is not recognizing the command prompt. I've tried several different regex strings for the Prompt parameter, including the default and nothing seems to help.
I think the prompt field needs to be a regexp, not a string
Try
tn = Net::Telnet::new("Host"=>"xxx.xxx.xxx.xxx", "Timeout"=>25,
"Output_log"=>"output_log.log", "Dump_log"=> "dump_log.log",
"Prompt"=> /C:.*>/)

Resources