I've written a very simple batch file that bluescreens windows 7 (ultimate,enterprise,home) beyond normal repair, by making an attempt of loading a Win32 exe-file (the well known notepad.exe) into the operating system's kernel. Feel free to test it in a Virtual Machine, just open it as an administrator. Do NOT run this as administrator on your primary computer.
#echo off
sc create bluescreener binpath = C:/Windows/System32/notepad.exe type= filesys start= boot
sc start bluescreener
timeout /t 30
However: When I run this program on windows 10, it successfully creates the service, but it doesn't start. Instead it returns the following error:
[SC] StartService Failed 2: The system cannot find the file specified.
It is referring to the binpath I set in the batch file. I am sure this path exists, and that this is the exact path name. I don't understand why it can't find the file. I have tried using backslashes instead of forward-slashes, and that didn't work either. (I have forward-slashes because I have a python program that writes this batch file, and the line break in python uses a backslash, and that conflicts with the path.)
I tried the "sc qc bluescreener" test that shows information about the service I have created. This is what comes up. (It is the same thing that comes up when I test it on windows 7, where it works.)
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: bluescreener
TYPE : 2 FILE_SYSTEM_DRIVER
START_TYPE : 0 BOOT_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : \SystemRoot\System32\notepad.exe
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : bluescreener
DEPENDENCIES :
SERVICE_START_NAME :
I can't find any explanation for why it can't find the file.
When I try to reboot windows 10 after creating the service, it can't boot, which means that the service is probably working and that the file was located. I just want to know why Windows 7 can find the file and immediately bluescreens, while Windows 10 can't find the file and needs to be rebooted for the service to run.
Any suggestions on how I might reproduce the same effect i get on Windows 7, but on Windows 10?
Related
I currently have an issue with psr.exe. Actually, it works perfectly with the following command :
C:\windows\system32\psr.exe
C:\windows\syswow64\psr.exe
psr.exe (with system32\cmd.exe and syswow64\cmd.exe).
BUT, it does not work when my program (a 32 bits program running on a 64 bits windows 7) use this bat to start the application. Nothing happens.
My programm can open a notepad from a bat files, or execute whatever you want, but it does not work with psr.exe.
Can you give me some tips? Maybe it is not a 32/64 bits compatibility issue but I have other no idea about why this does not works...
EDIT :
The batch file content is:
C:\windows\system32\psr.exe
The program running this bat is written in C, it uses this function to start it:
CreateProcessAsUser(
hTokenDup,
NULL,
"C:\\toto\\mybat.bat",
NULL,
NULL,
FALSE,
NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE,
lpEnvironment,
NULL,
&sInfo,
&ProcessInfo)
It works perfectly if the .bat file contains C:\windows\system32\notepad.exe instead of C:\windows\system32\psr.exe.
If I double click on my bat files containing C:\windows\system32\psr.exe from my desktop, it works perfectly, but from my C program, it does not work.
(NB : My c program works with other .exe files like notepad for example)
Many thanks.
Johan
If a 32-bit program running on 64-bit windows OS tries to access a file C:\windows\system32\psr.exe, Windows redirects the request to file C:\windows\syswow64\psr.exe.
To start a 64-bit system application from 32-bit environment you need to execute C:\windows\sysnative\psr.exe which will be redirected to "real" C:\windows\system32\psr.exe.
To run the bat-file entirely in a 64-bit environment, execute C:\windows\sysnative\cmd.exe with following parameters: /c "C:\toto\mybat.bat"
However, this does not appear to be a problem in your case.
Could it be that the user you are trying to impersonate has a corrupted profile, home folder, environment, or does not have some sort of privilege required by psr.exe application?
Or maybe the app requires user profile to be loaded but you didn't load it by calling LoadUserProfile() beforehand?
Try testing by running your batch file like this:
c:\windows\syswow64\runas.exe /noprofile /env /user:INSERT_USERNAME_HERE "C:\toto\mybat.bat"
Does it work? Now try removing /env and/or replacing /noprofile with /profile. Does it now?
I've been trying to get a Jenkins deploy job to work by running a batch script to do the install of an msi from the Jenkins build machine itself. I've given the appropriate access rights, but still am not able to run the following command remotely, using WMIC
wmic /node:myServerIp /user:"clientpc\my-user" /password:"my-password" process call create "D:\someDir\someOtherDir\test.bat"
The follow response from the above command:
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
ReturnValue = 9;
};
After some research, it looks like return value of '9' is 'Path not found' according to https://msdn.microsoft.com/en-us/library/aa389388(v=vs.85).aspx, but I've verified that the path exists on the remote server.
The test.bat file that I'm trying to run is very simple, and should just write to a text file.
#echo This is a test.> test.txt
I've verified that both files exist on the server, and have granted 'EVERYONE' to the shared folder 'someDir'.
I have tried prefixing 'cmd.exe /c' to the path called:
wmic /node:myServerIp /user:"clientpc\my-user" /password:"my-password" process call create "cmd.exe /c D:\someDir\someOtherDir\test.bat"
...for which I receive:
Invalid Verb Switch.
I've verified that the user access is correct by providing a bad password, in which case permission is denied.
EDIT:
Changed the path from D:\someDir\someOtherDir\test.bat to D:\\someDir\\someOtherDir\\test.bat but now receive the following error:
ERROR:
Description = The RPC server is unavailable.
EDIT 2:
Looks like the RPC user I was using was the cause for the error. Still troubleshooting, but when I use my AD user, as opposed to the administrator I created to run this, I get the following AGAIN...
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
ReturnValue = 9;
};
I was able to get the following to work on an Active Directory domain.
Wmic /node:"ComputerName" process call create "cmd.exe /c (net use o: /delete /y & net use o: \\Server\share /user:Domain\Administrator Password & o:\Dir\Subdir\test.cmd) >> c:\users\MyUser\testout2.txt"
The very simple contents of test.cmd:
echo Just a test >> c:\users\MyUser\testout.txt
date /t >> c:\users\MyUser\testout.txt
time /t >> c:\users\MyUser\testout.txt
The "job" is being sent to "ComputerName" on the domain. The batch/script file the job runs is on a network share. The job running on "ComputerName" will not see any mapped drives, so I delete and map a drive. I don't believe it is ever necessary to delete the drive, but I added that for completeness sake.
After execution, testout2.txt shows the batch file executing the commands and
testout.txt contains the results of the batch file commands as expected.
Things to watch out for:
As mentioned, mapped drives are not visible from the remote job
You are executing in the target machine's environment - drive letters need to make sense to that machine
Internal commands such as 'echo' require the job starts with 'CMD.EXE /c'
Group multiple commands inside parentheses and separate with ampersands (&)
Don't collide file access. I use testout.txt and testout2.txt files. If I had given them the same name, one set of outputs would have been lost.
Nothing you do this way will ever be visible to the user; the job is run in such a way that it can not display on the user's screen.
Sending a password in clear text as I show in the example is a security hazard and should be avoided. I'm not sure of a better way to map drives in this context however.
Good day! There are quite a few batch commands that are used to trigger events on three servers we have. I'm not really familiar with batch commands, but I have written a few. My problem is, I wrote a very simple batch command that calls and runs an .EXE file that automatically applies batches on a POS Server. Here is the command;
C:\grocery\sm2baply.exe /a
This has been working fine for weeks, but lately it just hangs until the next schedule task is ran with the same command and it overrides this. But the batches that should have been applied were not. About 3 out of 7 days it doesn't work.
Can someone help me please?
Thanks.
Schedule Tasks keep a log of what happened. So read the log.
In Scheduled Tasks select your task. History tab. EG one of mine failed with this.
- System
- Provider
[ Name] Microsoft-Windows-TaskScheduler
[ Guid] {de7b24ea-73c8-4a09-985d-5bdadcfa9017}
EventID 202
Version 0
Level 2
Task 202
Opcode 102
Keywords 0x8000000000000000
- TimeCreated
[ SystemTime] 2014-07-27T21:00:04.786Z
EventRecordID 2008255
- Correlation
[ ActivityID] {99694429-2673-4F4F-92E2-F55EDB9A20AC}
- Execution
[ ProcessID] 1700
[ ThreadID] 3140
Channel Microsoft-Windows-TaskScheduler/Operational
Computer Serenity
- Security
[ UserID] S-1-5-21-2820837959-2753176274-143444667-1000
- EventData
TaskName \Alarm2
TaskInstanceId {99694429-2673-4F4F-92E2-F55EDB9A20AC}
ActionName Hi
ResultCode 2147746317
2147746317 = 0x8004020d which is
//
// MessageId: EVENT_E_CANT_MODIFY_OR_DELETE_UNCONFIGURED_OBJECT
//
// MessageText:
//
// Cannot modify or delete an object that was not added using the COM+ Admin SDK
//
#define EVENT_E_CANT_MODIFY_OR_DELETE_UNCONFIGURED_OBJECT _HRESULT_TYPEDEF_(0x8004020DL)
If that doesn't work you need to monitor your batch. Echoing out things during execution (in case it's hanging). EG
Copy somefile.ext someotherfile.ext
echo Up to copy >> program.log
You can also start in a debugger.
windbg or ntsd (ntsd is a console program and maybe installed). Both are also from Debugging Tools For Windows.
Download and install Debugging Tools for Windows
http://msdn.microsoft.com/en-us/windows/hardware/hh852363
Install the Windows SDK but just choose the debugging tools.
Create a folder called Symbols in C:\
Start Windbg. File menu - Symbol File Path and enter
srv*C:\symbols*http://msdl.microsoft.com/download/symbols
then
windbg -o -g -G c:\windows\system32\cmd.exe /k batfile.bat
You can press F12 to stop it and kb will show the call stack (g continues the program). If there's errors it will also stop and show them.
well im trying to create a bat file that calls the php-cgi.exe with the file that it has to call , and the parameter that files need:
start "C:\Program Files (x86)\php\php-cgi.exe" \\\10.101.3.21\wiki\maintenance\importimages.php C:\wikimages jpg bmp
but i cant get it to work, it tries to open the importimages file instead of running it
First, check which OS you're using. The syntax for the 'start' command has changed over time.
You used to be able to do
start "iexplore.exe"
Now, you have to supply the window title before the command you're starting:
start "Title Goes Here" "iexplore.exe"
This change was made sometime around Windows XP, so if you're using Vista, 7, or 8 keep that in mind.
I think what you're looking for is something like:
start "" "C:\Program Files (x86)\php\php-cgi.exe \\\10.101.3.21\wiki\maintenance\importimages.php C:\wikimages jpg bmp"
I have a simple function f1(paramter) in a "functions.txt" file.
I write a batch file test.bat as follows
FOR /L %%G in (-100,1,100) do xgSubmit.exe /group=tt1Test /command Rscript.exe -e
"source('functions.txt');f1(%%G)" > "Out.%%G.txt"
In the windows command prompt I use
xgConsole.exe test.bat /openmonitor /AvoidLocal=ON
What I am trying to do is compute function f1() in different machines using incredibuild.
What I observe is the function that are running locally returns a value in files
Out.%%G.txt but the functions running remotely fails with the following error
Error in structure(.Internal(Sys.getenv(as.character(x), as.character(unset))), :
unsupported conversion to 'UCS-2LE' from codepage 1252
Calls: local ... eval -> eval -> as.vector -> Sys.getenv -> structure
Execution halted.
The remote machines do not have R program installed.
Am I doing the correct thing ?
Should incredibuild and Rscipt be able to work even though R program is not installed in the remote computer ?
It would be very kind to provide a detailed answer.
It seems like a Unicode problem in the remote machines.
Many Unicode problems have been fixed since this question was submitted.
I assume your bug is already fixed in the latest version of IncrediBuild.