Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Execute a command for Bat file did not run

Created: 10 Sep 2013 | 6 comments

Hi Everyone,

Kindly help me to resolve this task.

We are using ghost console 11.5.1.2266, we have created a bat file and created a task : 1st is to transfer the bat file to target computers and it was successful but it did not run the bat file althoug it says "successful".

here is the setting at the command line: C:\TEMP\CentralTimeZone.bat

and choosed : Execute command in the target Operating System

Tha bat file should run this reg file

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]

"Bias"=dword:00000168
"DaylightBias"=dword:ffffffc4
"DaylightName"="Central Standard Time"
"DaylightStart"=hex:00,00,03,00,02,00,02,00,00,00,00,00,00,00,00,00
"StandardBias"=dword:00000000
"StandardName"="Central Standard Time"
"StandardStart"=hex:00,00,0b,00,01,00,02,00,00,00,00,00,00,00,00,00
"TimeZoneKeyName"="Central Standard Time"
"DynamicDaylightTimeDisabled"=dword:00000000
"ActiveTimeBias"=dword:0000012c
 
 
Any suggestions is highly appreciated
 
thanks in advance!
Operating Systems:

Comments 6 CommentsJump to latest comment

EdT's picture

BAT is not an executable file extension. You cannot assume that file associations are automatically available in any situation.

You need to call: c:\windows\system32\cmd.exe /c C:\TEMP\CentralTimeZone.bat

Equally, if you are calling regedit.exe in your bat file, you need to provide the full path to it as you cannot assume that a path environment variable is set during the imaging process.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

zer0_c00L's picture

Hi EdT,

I tried your suggestion but it still does not work.

Thanks!

EdT's picture

OK, What operating system are you doing this on?  If it is Windows 7 then there may be a problem if the script is erroring out for any reason, and you will not see any error messages because interaction with desktop is no longer an option for service based tasks. You need to add some logging code into your batch files to see if the file is being called and is running and maybe stalled - you can also check if CMD.EXE is shown as running in task manager.

For logging in batch files, create a folder C:\logs. Then in your batch file, as the first line, enter

echo Batch file has started execution > c:\logs\logfile.txt

For any subsequent log entries type this

echo Your message here >> c:\logs\logfile.txt    (the >> causes the message to be appended to the logfile)

If you cannot solve your problem from here then please post the content of the batch files.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

zer0_c00L's picture

Hi EdT,

Target station are WIN7 64 bit:

Here is my batch file:

----------------------------------------------------------------------------------------------

@echo off

REGEDIT /S "\\host\sharedrive$\time\CentralTimeZone.reg"

exit

----------------------------------------------------------------------------------------------

here is the reg file it calls:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"Bias"=dword:00000168
"DaylightBias"=dword:ffffffc4
"DaylightName"="Central Standard Time"
"DaylightStart"=hex:00,00,03,00,02,00,02,00,00,00,00,00,00,00,00,00
"StandardBias"=dword:00000000
"StandardName"="Central Standard Time"
"StandardStart"=hex:00,00,0b,00,01,00,02,00,00,00,00,00,00,00,00,00
"TimeZoneKeyName"="Central Standard Time"
"DynamicDaylightTimeDisabled"=dword:00000000
"ActiveTimeBias"=dword:0000012c

The created task sucessfully copy the BAT file to target station but it did execute the BAT file.

since when i check the registry it did not replicate the entries from the reg file

Please advise

Klim_Belchev's picture

Just an idea - check if the Ghost Solution agent installed your Win7 x64 machines is a 64 bit one. If it is a 32 bit one the import into the x64 HCLM\SYSTEM will not be successful.

Try this:

Run c:\windows\SysWOW64\cmd.exe

This is the 32 bit cmd. Run regedit from within and look for your imported data - is it there?

EdT's picture

Now that I have seen the batch file, I'm pretty sure that the problem is caused by the fact that a local service has NO network access so your network based REG file is not going to be accessible when the batch file runs.

As a test, place a copy of the reg file on the local hard disk and change your batch file to call the local copy, and then run the task as before. If it now works you will know what the problem is, and wil either ensure that the REG file is copied locally first, or change the batch file to specify the registry entries directly.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.