Post Reply 
Hide Window on Startup
Author Message
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
Offline
Post: #6
RE: Hide Window on Startup
Sure it doesn't work over LAN?
Perhaps you've disabled whatever protocol it relies on.

Lol @ hijacking other computers on your network.


Anyway, I tried - can't get it to work :(
For some reason, it ignores me if I tell it to hide.  It works fine if I say to minimize etc.  Documentation says nothing about not being able to hide...

C Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <windows.h>
#include <string.h>

#include <wchar.h>

int main(void) {
	
	STARTUPINFOW si;
	PROCESS_INFORMATION pi;
	int result=1;
	WCHAR* cmdIn = (WCHAR*)GetCommandLineW();
	int numArgs, tmpLen;
	LPWSTR* cmdArgs = CommandLineToArgvW((LPCWSTR)cmdIn, &numArgs);
	WCHAR cmd[MAX_PATH];
	
	si.cb = sizeof(pi);
	si.lpReserved = NULL;
	si.lpDesktop = NULL;
	si.lpTitle = NULL;
	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_HIDE;
	si.cbReserved2 = 0;
	si.lpReserved2 = NULL;
	
	// utilise existing command line
	tmpLen = wcslen(*cmdArgs);
	if(cmdIn[0] == L'"') tmpLen += 2; // take quotes into consideration
	cmdIn += tmpLen;
	// chomp spaces
	while(cmdIn[0] == L' ')
		cmdIn++;
	
	wcscpy(cmd, cmdIn);
	
	ShellExecuteW(NULL, L"open", (LPWSTR)cmd, NULL, NULL, SW_HIDE);
	//result = CreateProcessW(NULL, (LPWSTR)cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
	//CloseHandle(pi.hThread);
	//CloseHandle(pi.hProcess);
	
	
	LocalFree(cmdArgs);
	return !result;
}



EDIT:
I'm not sure if user mode applications can be run as services, but actually SchmilK has a good idea.  Try using psexec and running it on the SYSTEM account.

(This post was last modified: 13/08/2010 06:55 AM by ZiNgA BuRgA.)
13/08/2010 06:53 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
Hide Window on Startup - S7* - 13/08/2010, 03:09 AM
RE: Hide Window on Startup - ZiNgA BuRgA - 13/08/2010, 04:54 AM
RE: Hide Window on Startup - S7* - 13/08/2010, 05:03 AM
RE: Hide Window on Startup - SchmilK - 13/08/2010, 06:07 AM
RE: Hide Window on Startup - S7* - 13/08/2010, 06:47 AM
RE: Hide Window on Startup - ZiNgA BuRgA - 13/08/2010 06:53 AM
RE: Hide Window on Startup - Slushba132 - 13/08/2010, 07:18 AM
RE: Hide Window on Startup - S7* - 13/08/2010, 07:35 AM
RE: Hide Window on Startup - Slushba132 - 13/08/2010, 05:12 PM
RE: Hide Window on Startup - ZiNgA BuRgA - 13/08/2010, 05:27 PM
RE: Hide Window on Startup - S7* - 13/08/2010, 05:53 PM
RE: Hide Window on Startup - asdfganon - 19/01/2012, 01:01 PM
RE: Hide Window on Startup - S7* - 19/01/2012, 02:20 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: