Jump to content

Batch File not executing correctly.


itshero

Recommended Posts

Hello,

I have not been able to complete the execution of this batch file.  I have verified that it is indeed correct in syntax, as it runs locally just fine.  

TASKKILL /f /im iexplore.exe
CD "C:\Program Files (x86)\Internet Explorer"
timeout /t 5
start iexplore.exe

In essence the code is meant to close Internet Explorer, and restart it upon the 5 second timeout period.  But, it seems like it only executes the first part of the code successfully.  Internet Explorer closes, but nothing else happens. (no errors in pulseway log).  Feel free to run the code as it isn't malicious.  Am I missing something to make work?

Thanks and I hope to get a response soon.  I would greatly appreciate the continued support. 

Link to comment
Share on other sites

  • Administrators

Please note that scripts will run in an isolated session (session zero) which means that all GUI applications will run in a session that's not visible to the console. This has been done to enhance the security and privacy of the end user and to support running scripts while there is no logged in user. You could try using the Enter-PSSession PowerShell cmdlet to join a user session.

-Paul

Link to comment
Share on other sites

Hello,

I put in the Enter-PSSession, and saved it as a Powershell script.  

Enter-PSSession -ComputerName computer1
TASKKILL /f /im iexplore.exe
CD "C:\Program Files (x86)\Internet Explorer"
timeout /t 5
start iexplore.exe

It receives the following response. 

ERROR: Input redirection is not supported, exiting the process immediately.

It still closes the program, however still does nothing else. 

Link to comment
Share on other sites

I found out 

ERROR: Input redirection is not supported, exiting the process immediately.

Was associated with time timeout command.  Upon removing that, the command ignores the following:


CD "C:\Program Files (x86)\Internet Explorer"
start iexplore.exe

 

Link to comment
Share on other sites

  • Staff

Try to use something like this (via PowerShell):

$j = Start-Job -ScriptBlock {
TASKKILL /f /im iexplore.exe
}
Wait-Job $j -Timeout 5 | out-null
if ($j.State -eq "Completed") {
CD "C:\Program Files (x86)\Internet Explorer"
start iexplore.exe
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...