how to make a .bat file "activate" when the PC sleeps - batch-file

Is there a way that I can make a batch program begin when I put my computer to sleep?
I would like to disable a USB port when I put my computer to sleep. Is this possible if so, how would I go a out doing so?

As this has not been marked as closed I am assuming the author has not been able to piece together the answer from the comments. This answer is derived from those comment hints and gives the detail that perhaps the questioner requires....
If you search for information on using the task scheduler to trigger on the sleep event you get to this page at Microsoft, which contains the following:
Input “Task Scheduler” in search box and press Enter
Click “Create task…” on the Task Scheduler---Action
Go to Triggers, create new triggers
On “Begin the task”, select “On an event”
Select Log to “system” , set “Source” to “Kernel-Power” , Event ID
is “42” and click “Ok”
Go to “Actions” and create a new actions
You can select “Start a program”, “Send an e-mail” and “Display a
message” on action as you need.
Save the task scheduler
On conditions tab, check the box “Wake the computer to run this task”. Click OK.
The information about using devcon.exe is on this microsoft page which shows the following command does the trick:
devcon disable *MSLOOP
You can either make a batch-file calling devcon, or have the task scheduler call devcon directly with the appropriate arguments.
Is that enough detail to explain the solution?

Related

How to protect files(docs) form being downloaded

I have some documents on a subdirectory for example www.example.com/documents, inside the document folder i have files(e.g. File1.doc, file2.docx, and So on). I want users to view the files But not to download it.
How can i do this?
In order to view the file the user need to download them... Maybe I don't fully get your point but I think this is not an option
(Programmer's Lore-Keepers) forgive my suggestions here...
This is a bit of a 'grey-area-programming'.
Have you considered perhaps using a technology of your choice javascript/jQuery to capture the "known" ways of copying while on your page?
Positive test : suppose the user clicks enter on a textbox and you're using jQuery to trap the enter command to then set off your trigger that is a default action to a control of your choice.
Think about this as a negative test... if the user uses key combinations such as Ctrl+A or Ctrl+P or Ctrl+S then you intercept it and interrupt their action in theory...
Other factors to consider would be how to capture the mouse drags and perhaps even right-click actions.
Hope this helps.

Installshield 2011: Take path from one window, take text from second

Good day, everyone. I have that task assigned which consists in creating simple installscript-only project, that should have 2 windows: first will prompt user to enter a path and create text file in this specified location, while second will promt for text input and save anything user writes into this text file.
Funny point is that I have small installshield experience (completed tutorials... well, yeah, that's all) and very little programming experience on top of that. As far as i understand, I should first create two custom dialog windows (for example by cloning them from standard ones), then create .rul files with functions, determining behavior for each. After which, include them into main setup.rul and call functions at specific point of time.
Question is - what exact dialog windows/functions/points of time will be best for such task? For reference i searched into "Serial Number Validation Sample Project" but, honestly, the way it customized default window is just confused me even more... So, please, can anybody help? Thank you.
For future reference, here's working solution.
Asked that same question at flexera forums, and here's what I got:
Off the top of my head (without InstallShield handy to check this) 1)
Create an InstallScript project, just accept all of the defaults in
the new project wizard unless you want to add localization or
something. 2) Your description implies that you do not need
maintenance (repair, modify, uninstall) support. If correct go to
Project\Settings and on the Maintenance tab select 'no uninstall or
maintenance'. 3) You can put your code at the top of the
OnFirstUIBefore function and then call Exit so that the rest of that
default code is never executed, since you are not installing anything.
As part of your InstallShield IDE, in the Start menu (for IS2012
Spring) is a tool that demonstrates all of the built in dialogs. You
can look through those choices and select the dialog that is best for
your situation. It sounds like you want to:
Call AskPath or SdAskDestPath (there are several other possibilities)
Then call AskText and save that string.
If you need to make layout or text changes to the default dialogs look
at your Dialogs view and select which ever dialog you selected above
and edit it. (If you decide to use skins make sure you select the skin
before you make any dialog layout changes.)
Then do something similar to the functional body of the WriteLine
example http://kb.flexerasoftware.com/doc/Helpnet/installshield14langref/LangrefWriteLine_Example.htm
The actual WriteLine example function prototype is for a MSI custom
action which is not what you want. Ignore the function protoype and
just use the code in your project to create the file at the path you
already collected and write the line of text that you collected.
Then call Exit;
(big thanks to user phill_mn for that answer)
And here's the code for setup.rul:
#include "ifx.h"
function OnFirstUIBefore()
number nvFileHandle;
string svResult;
string szTargetPath, szFeatures;
BOOL bLicenseAccepted;
begin
AskPath ("Please choose a path where text file will be saved","c:\\",szTargetPath);
MessageBox("File yourtext.txt wiil be created or overwritten at " +szTargetPath, INFORMATION);
AskText ("Please enter some text to save into that file", "Text goes here", svResult);
OpenFileMode (FILE_MODE_APPEND);
if (CreateFile (nvFileHandle, szTargetPath, "yourtext.txt") < 0) then
MessageBox ("Creating failed.", SEVERE);
abort;
else
if (WriteLine(nvFileHandle, svResult) < 0) then
MessageBox ("Writing failed.", SEVERE);
else
MessageBox ("Success.", INFORMATION);
endif;
endif;
CloseFile (nvFileHandle);
Do(EXIT);
return 0;
end;

Issue with configuring conTEXT to compile for Unrealscript

I have been going through Rachel Cordone's Unreal Development Kit Game Programming with UnrealScript Beginner's Guide book and having an issue using the conTEXT text editor.
As per instructed through the book I have followed all the steps to configure it but it won't compile once I press F9 - considering the last step to configure is to set the Enivronment Options/Execute Keys section. Here are the steps the book lays out (just that certain tab):
7) Now we are going to set up the conText to compile code. On the Execute Keys tab, click on Add, then type .uc into the Extensions field that comes up.
8) Once that's done four keys, F9 through F12, will show up in the User Exec Keys window. Let's click on F9 to make it convenient. Once clicked the option on the right become available.
9) For the Execute line, click on the button to the right of the field and navigate to out UDK installation's Binaries\Win64 folder, and select UDK.exe. For Start In, copy the Execute line but leave out UDK.exe.
10) In the Parameters field, type "make" without the quote marks. This tells UDK.exe that we want to compile code instead of opening the game.
11) Change Save to All Files Before Execution.
12) Check Capture Console Output and Scroll Console to the Last Line...
Then all I have to do is press F9 and it will compile - but it doesn't! It gives me:
No user command associated with extension '.uc'
Use 'Environment Options/Execute Keys' dialog to assign commands.
It seems it is not registering the changes no matter what I do (yes I clicked apply before saying okay but even still nothing). Any ideas?
The instructions may be out of date. You'll need to select your ".uc" entry, hit "Edit", and change it to just "uc".
Also, if you use UDK.com instead of UDK.exe the console output will go directly into Context instead of going to a separate popup.

I want to run a codeunit automatically in nav2009

I want a codeunit to run automatically at certain time intervals everyday or once every week.is there any procedure in nav to achieve that?i preferably would not like to run or start nav(from the program files) for that but without starting nav.
You can use the NAS (Nav Application Server) to achieve this.
I believe in order to set the job up you'll need to fire up the 2009 Classic Client (Rather than the RTC)
You should find the Job Queue in 'Administration' > 'Job Queue'
Once you've defined the job you wish to set up in there configure the NAS accordingly.
You can use the below to install the NAS:
nassql.exe appservername=[YourServiceName],
NETTYPE=TCP,
servername=[YourSqlServer],
database=[SqlDatabaseName],
company="[NavisionCompanyName]",
nettype=tcp,
startupparameter=”[StartUpParam]”,
objectcache=40000,
installasservice
Hope this helps.

How to start the associated program when selecting more than one files?

I have set .jpg file associated to my own program. I want to add the context menu to .jpg files, so I set the entry of HKCR.jpg\shell\open\command to "myProg.exe %1". After associating, there will be an item on the top of the context menu saying "Open image with myprog". This works right when I select a single .jpg file, but when I selected more than one file and click the top item of the context menu, nothing happended. How can I solve the problem?
Thank you very much
Each selected file will be sent to a new instance of your application. Your application should check if a previous version exists, or not. If a previous instance exists, it should sent its parameters to it (e.g. using Windows Messages) and then terminate.
Another approach is to use DDE (Dynamic Data Exchange), an old method used by Shell to send all files to one instance of your program.
You might need double quotes around the "%1".
Read this article for much more detailed information about how all this works.
http://msdn.microsoft.com/en-us/library/bb776883.aspx
Also, this blog entry talks about what you need to do specifically for multi-select command execution: http://blogs.msdn.com/pix/archive/2006/06/30/652889.aspx

Resources